Java 中的 OpenCV Mat 如何表示二元向量?
How are two-element vector represented in a OpenCV Mat in Java?
我在看 Opencv Java documentation of Hough Transform。
return 值 lines
属于 Mat
数据类型,描述为:
Output vector of lines. Each line is represented by a two-element
vector (rho, theta). rho is the distance from the coordinate origin
(0,0) (top-left corner of the image). theta is the line rotation angle
in radians (0 ~ vertical line, pi/2 ~ horizontal line).
奇怪的是,这个描述与 the C++ interface's description, but the data type not: in C++ you can use a std::vector<cv::Vec2f> lines
as described in this tutorial 相符。在 C++ 中,根据描述,returned 数据表示很简单,但在 Java 中则不然。
那么,在Java中,returned Mat中的二元向量represented/stored如何?
这是我不久前使用的一些代码,我认为是在 2.4.8 版本中。 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];
//...
}
我在看 Opencv Java documentation of Hough Transform。
return 值 lines
属于 Mat
数据类型,描述为:
Output vector of lines. Each line is represented by a two-element vector (rho, theta). rho is the distance from the coordinate origin (0,0) (top-left corner of the image). theta is the line rotation angle in radians (0 ~ vertical line, pi/2 ~ horizontal line).
奇怪的是,这个描述与 the C++ interface's description, but the data type not: in C++ you can use a std::vector<cv::Vec2f> lines
as described in this tutorial 相符。在 C++ 中,根据描述,returned 数据表示很简单,但在 Java 中则不然。
那么,在Java中,returned Mat中的二元向量represented/stored如何?
这是我不久前使用的一些代码,我认为是在 2.4.8 版本中。 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];
//...
}