I have code from tutorial and I want to detect straight lines in image. I have this code, but for 1 line HoughLinesP generates hundreds of points instead 2 points (start point and end point - [x1,y1] and [x2, y2]). Even if I use empty image, I get 99 points... Thank you all very much.
Mat src = Highgui.imread("C:/Users/Daniel/Desktop/line.png",Highgui.CV_LOAD_IMAGE_COLOR);
Mat lines = new Mat();
Mat grey = new Mat();
Imgproc.cvtColor(m, grey, Imgproc.COLOR_BGR2GRAY);
Imgproc.HoughLinesP(grey, lines, 1, Math.PI / 180, 50, 50, 10);
for (int x = 0; x < lines.cols(); x++)
{
double[] vec = lines.get(0, x);
double x1 = vec[0],
y1 = vec[1],
x2 = vec[2],
y2 = vec[3];
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
Core.line(grey, start, end, new Scalar(100,100,100), 1);
}
//just show image
new LoadImage("C:/Users/Daniel/Desktop/cdst.jpg",cdst);
//print matrix of points of all lines - here I get a lot of points for 1 line
System.out.println(lines.dump());


