Caffe Net.Forward 尝试使用 OpenCV 进行人脸检测时出错

Caffe Net.Forward Error trying face detection with OpenCV

我正在学习神经网络并尝试了此页面中的一些示例代码 Link

在我到达部分之前一切正常

cv::Mat detection = net.forward("detection_out");

可能是一些重要的代码部分:

Scalar meanVal = Scalar(104.0, 177.0, 123.0);
const size_t inWidth = 300;
const size_t inHeight = 300;
const double inScaleFactor = 1.0;
const float confidenceThreshold = 0.7;

#define CAFFE
    const std::string caffeConfigFile = "./deploy.prototxt";
    const std::string caffeWeightFile = "./res10_300x300_ssd_iter_140000_fp16.caffemodel";

,..
,..
,..

Mat inputBlob = cv::dnn::blobFromImage(image, inScaleFactor, cv::Size(inWidth, inHeight), meanVal, false, false, 5);
net.setInput(inputBlob, "data");
cv::Mat detection = net.forward("detection_out");

,.. 
,..
,..

int main(){

Mat image(YRes, XRes, CV_32F, PixelPointerOut);
.............................

我收到以下错误消息:

{msg="OpenCV(4.0.1-dev) C:\OpenCV\opencv-master\modules\dnn\src\layers\convolution_layer.cpp:267: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 1 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes"}

提前感谢您的回复!

尝试 CV_8UC3 已经在不使用空层名称的情况下解决了这个问题。 我确信我之前尝试过,因为 CV_32FC3 没有用。 非常感谢!