请教HoughLinesP正确使用方法
自认为调用没有出错,但是运行一直出错,请大神们看下问题
代码如下
#include<opencv2\opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
Mat src, src_gray, dst;
src = imread("1.bmp");
src_gray.create(src.rows, src.cols,CV_8UC1 );
namedWindow("原始图片", WINDOW_AUTOSIZE);
imshow("原始图片", src);
cout << "src depth " << src.depth() << endl;
cout << "src type " << src.type() << endl;
cout << "src cannels " << src.channels() << endl;
Canny(src, src_gray, 0, 255);
cvtColor(src_gray, dst, CV_GRAY2BGR);
namedWindow("提取边缘", WINDOW_AUTOSIZE);
imshow("提取边缘", src_gray);
cout << "src_gray depth " << src_gray.depth() << endl;
cout << "src_gray type " << src_gray.type() << endl;
cout << "src_gray cannels " << src_gray.channels() << endl;
vector<Vec4f>plines;
HoughLinesP(src_gray, plines, 1, CV_PI / 180.0, 10, 0, 0);
Scalar color = Scalar(0, 0, 255);
for (size_t i = 0; i < plines.size(); i++)
{
Vec4f hline = plines[i];
line(dst, Point(hline[0], hline[1]), Point(hline[2], hline[3]), color, 1, LINE_AA);
}
namedWindow("最终的结果", WINDOW_AUTOSIZE);
imshow("最终的结果", dst);
waitKey(0);
return 0;
}