How is a two-element vector represented in Matrix OpenCV in Java?

I looked at the Opencv Java documentation for the Hough conversion .

The return value of lines is in the Mat type, described as:

Output line vector. Each row is represented by a two-element vector (rho, theta). rho - distance from the origin (0,0) (upper left corner of the image). theta is the angle of rotation of the line in radians (0 ~ vertical line, pi / 2 ~ horizontal line).

It is curious that this description corresponds to the description of the C ++ interface , but does not apply to the data type: in C ++ you can use std::vector<cv::Vec2f> lines as described in this tutorial . In C ++, the return representation of the data given in the description is simple, but not in Java.

So, in Java, how is a two-element vector represented / stored in the returned Mat?

+5
source share
1 answer

Here is the code that I used some time ago in version 2.4.8, I think. matLines :

 Imgproc.HoughLinesP(matOutline, matLines, 1, Math.PI / 180, houghThreshCurrent, houghMinLength, houghMaxGap); 

...

 Point[] points = new Point[]{ new Point(), new Point() }; for (int x = 0; x < matLines.cols(); x++) { double[] vec = matLines.get(0, x); points[0].x = vec[0]; points[0].y = vec[1]; points[1].x = vec[2]; points[1].y = vec[3]; //... } 
+5
source

All Articles