Ask Your Question

Revision history [back]

Line Detection.

After increasing the minLineLength and decreasing maxLineGap program is still showing number of lines and also the gap is also visible. Can someone tell me the problem in the program? Image is:-image description Code is-:

#include "stdafx.h"

include <cv.h>

include <highgui.h>

include <math.h>

using namespace cv; int main(int argc, char** argv) { Mat src, dst, color_dst; src = imread("line2.jpg", 0); Canny(src, dst, 50, 200, 3); cvtColor(dst, color_dst, CV_GRAY2BGR);

vector<Vec4i> lines;
HoughLinesP(dst,lines,1,CV_PI/180,80,600,300);
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);

}

click to hide/show revision 2
No.2 Revision

Line Detection.

After increasing the minLineLength and decreasing maxLineGap program is still showing number of lines and also the gap is also visible. Can someone tell me the problem in the program? Image is:-image description Code is-:

#include include "stdafx.h"

include <cv.h>

include <highgui.h>

include <math.h>

include <cv.h> include <highgui.h> include <math.h> using namespace cv; int main(int argc, char** argv) { Mat src, dst, color_dst; src = imread("line2.jpg", 0); Canny(src, dst, 50, 200, 3); cvtColor(dst, color_dst, CV_GRAY2BGR);

CV_GRAY2BGR);


    vector<Vec4i> lines;
 HoughLinesP(dst,lines,1,CV_PI/180,80,600,300);
 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);
}

}