使用 OpenCV /C++ 应用精明边缘检测器后出现"Unhandled exception"错误

getting "Unhandled exception" error after applying canny edge detector using opencv /c++

本文关键字:Unhandled 错误 exception 检测器 边缘检测 C++ OpenCV 应用 边缘 使用      更新时间:2023-10-16

当我试图将Canny边缘检测器应用到我的图像中时,我得到了"未处理的异常"错误。

int width;
int height;
cv::Mat dis = Mat(width, height, CV_32FC1,Dis);
cv::Mat cannyEdge(dis.rows, dis.cols, CV_32FC1);
GaussianBlur( dis, dis, Size(3, 3), 2, 2 );
Canny( dis, cannyEdge , 100 , 100 * 3, 3);
imshow("canny_edge",cannyEdge);
}

似乎一切都是正确的,但我在Canny函数调用行中出错。。。

提前谢谢。。

根据OpenCV文档,Canny()函数的参数

源图像–单通道8位
需求——与来源尺寸和类型相同。

您使用的是32位浮点图像。

尝试

cv::Mat dis = Mat(width, height, CV_8UC1,Dis);