OpenCV Houghline函数创建无限行 [英] OpenCV Houghline function create unlimited lines
问题描述
我对OpenCV还是很陌生,最近遇到了Houghline函数.我在Visual Studio 2015中使用OpenCV 3.2.我尝试了HoughlineP的示例代码,但未成功.该代码可以很好地编译,但是可以无休止地运行,有时当我按停止调试"时,它会弹出未处理的异常在.........访问冲突读取位置..."错误.当我调试它时,似乎是由HoughlinsP函数引起的(Canny和cvtColor效果很好). HoughlinesP函数之后的行大小= 1152921504603840390(一个荒谬的巨大数字).能否请您指教?谢谢.
I am still very new to OpenCV and recently came across the Houghline function. I am using OpenCV 3.2 with Visual Studio 2015. I tried the sample code for HoughlineP without success. The code compiles fine but it runs endless, and sometimes when I push "stop debugging" it popup "Unhandled exception at.........Access violation reading location ..." errors. When I debugged it, it seems cause by the HoughlinsP function (the Canny and cvtColor works good). The lines size=1152921504603840390 (a ridiculous huge number) after the HoughlinesP function. Could you please advice? Thank you.
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat src, dst, color_dst;
src = imread("C:\\\Temp\\\img.jpg");
if (src.empty())
return -1;
Canny(src, dst, 50, 200, 3);
cvtColor(dst, color_dst, COLOR_GRAY2BGR);
vector<Vec4i> lines;
HoughLinesP(dst, lines, 1, CV_PI / 180, 80, 30, 10);
for (size_t i = 0; i < lines.size(); i++)
{
line(color_dst, Point(lines[i][0], lines[i][1]),
Point(lines[i][2], lines[i][3]), Scalar(0, 0, 255), 3, 8);
}
namedWindow("Source", 1);
imshow("Source", src);
namedWindow("Detected Lines", 1);
imshow("Detected Lines", color_dst);
waitKey(0);
return 0;
}
推荐答案
感谢您的关注.通过从调试链接器输入中删除opencv_world320.lib可以解决此问题.
Thank you for your attention. It is solved by taking opencv_world320.lib out of the debug linker input.
这篇关于OpenCV Houghline函数创建无限行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!