Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
opencv程序中出错:输入参数的大小不匹配_C_Opencv - Fatal编程技术网

opencv程序中出错:输入参数的大小不匹配

opencv程序中出错:输入参数的大小不匹配,c,opencv,C,Opencv,我尝试用OpenCV比较C语言中的两个图像。我尝试了以下代码: cv::Mat diff; cv::absdiff(src,dst,diff); cv::Mat image; cv::cvtColor(diff,image,CV_BGR2GRAY); if (CountNonZero(image)==0) printf("welcome you are autorised"); else printf("Sorry you are not welcome"); return 0; } 这是

我尝试用OpenCV比较C语言中的两个图像。我尝试了以下代码:

cv::Mat diff;
cv::absdiff(src,dst,diff);
cv::Mat image;
cv::cvtColor(diff,image,CV_BGR2GRAY);
if (CountNonZero(image)==0)
printf("welcome you are autorised");
else 
printf("Sorry you are not welcome");

return 0;
}
这是我在运行程序时遇到的错误:

 OpenCV Error: Sizes of input arguments do not match (The operation is 
neither 'array op array' (where arrays have the same size and the same 
number of channels), nor 'array op scalar', nor 'scalar op array') in 
arithm_op, file /build/opencv-ys8xiq/opencv- 
2.4.9.1+dfsg/modules/core/src/arithm.cpp, line 1287
terminate called after throwing an instance of 'cv::Exception'
what():  /build/opencv-ys8xiq/opencv- 
2.4.9.1+dfsg/modules/core/src/arithm.cpp:1287: error: (-209) The operation 
is neither 'array op array' (where arrays have the same size and the same 
number of channels), nor 'array op scalar', nor 'scalar op array' in 
function arithm_op

Aborted (core dumped)

有人能帮我吗?

cv::absdiff输入应具有相同的大小和通道。确保(src、dst)具有相同的大小和通道。Thnx I将尝试解决此问题。