我正在进入神经网络,并尝试过此页面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"}
在此先感谢您的回复!
答案 0 :(得分:0)
尝试CV_8UC3已解决它,而没有使用空层名称。 我确定我之前曾尝试过,因为CV_32FC3无法正常工作。 非常感谢!