【发布时间】:2012-01-17 00:50:48
【问题描述】:
我正在尝试使用以下代码在图像的某个位置应用 Canny 运算符:
//region of interest from my RGB image
Mat devilROI = img(Rect(r->x+lowerRect.x,
r->y + lowerRect.y,
lowerRect.width,
lowerRect.height));
Mat canny;
//to grayscale so I can apply canny
cvtColor(devilROI, canny, CV_RGB2GRAY);
//makes my region of interest with Canny
Canny(canny, canny, low_threshold, high_threshold);
//back to the original image
addWeighted(devilROI, 1.0, canny, 0.3, 0., devilROI);
执行 addWeighted 时出现以下错误:
OpenCV错误:输入参数的大小不匹配(操作既不是'array op array'(其中数组具有相同的大小和相同的通道数),也不是'array op scalar',也不是'scalar op array') arithm_op,文件 C:\OpenCV2.3\opencv\modules\core\src\arithm.cpp,第 1227 行 在抛出 'cv::Exception' 的实例后调用终止 what(): C:\OpenCV2.3\opencv\modules\core\src\arithm.cpp:1227: error: (-209) 该操作既不是“数组运算数组”(其中数组具有相同的大小和相同的通道数),也不是函数 arithm_op 中的“array op scalar”,也不是“scalar op array”您对可能出现的问题有什么建议吗? 这个问题我纠结了好久……
谢谢。
【问题讨论】:
-
哪一行特别抛出错误? -- 不用担心,我看到是
addWeighted。 -
@mathematical.coffee addWeighted,编辑了问题。谢谢。