#include<opencv2\highgui\highgui.hpp>
#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace std;
using namespace cv;
char *output_title = "output Image";
Mat src, canny_dst, gray_image, dst;
int main()
{
src = imread("E:\\vs2015\\opencvstudy\\1.jpg", 1);
if (src.empty())
{
cout << "could not load the src image!" << endl;
return -1;
}
char *input_title = "input Image";
imshow(input_title, src);
Canny(src, canny_dst, 150, 200);
cvtColor(canny_dst, gray_image, CV_GRAY2BGR);
gray_image = Mat::zeros(gray_image.size(), gray_image.type());
imshow("canny", canny_dst);
vector<Vec4f> plines;
HoughLinesP(canny_dst, plines, 1, CV_PI / 180.0, 500, 100, 10);
Scalar color = Scalar(0, 0, 255);
for (size_t i = 0; i < plines.size(); i++)
{
Vec4f hline = plines[i];
line(gray_image, Point(hline[0], hline[1]), Point(hline[2], hline[3]), color,3, LINE_AA);
}
imshow("dst", gray_image);
waitKey(0);
return 0;
}