gpt4 book ai didi

java - Java 中的 OpenCV Mat 中如何表示二元 vector ?

转载 作者:搜寻专家 更新时间:2023-10-31 20:01:43 24 4
gpt4 key购买 nike

我在看 Opencv Java documentation of Hough Transform .

返回值linesMat数据类型描述为:

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数据类型不是:在 C++ 中,您可以使用 std::vector<cv::Vec2f> linesthis tutorial 中所述.在 C++ 中,返回的数据表示(根据描述)很简单,但在 Java 中则不然。

那么,在 Java 中,二元 vector 如何表示/存储在返回的 Mat 中?

最佳答案

这是我不久前使用的一些代码,我认为是在 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];
//...
}

关于java - Java 中的 OpenCV Mat 中如何表示二元 vector ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29517069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com