简体   繁体   English

使用JavaCV在Java中使用OpenCV语句的等效项

[英]Equivalent of OpenCV statement in Java using JavaCV

I want to know how to construct the following C++ statement in OpenCV using JavaCV: 我想知道如何使用JavaCV在OpenCV中构造以下C ++语句:

float* p = (float*)cvGetSeqElem(circles, i);
int radius = cvRound(p[2]);

To get the Radius of a circle detected using cvHoughCircles(). 使用cvHoughCircles()检测圆的半径。 Obviously Java doesn't use pointer so I have no idea how to do this in Java. 显然Java不使用指针,所以我不知道如何在Java中这样做。 The code I have so far so you can see it context: 到目前为止我的代码所以你可以看到它的上下文:

lines = cvHoughCircles(frame2, storage, CV_HOUGH_GRADIENT, 1, 50, 300, 60, 10, 600);
for (int i = 0; i < lines.total(); i++) {
    //Would like the code to go here
    CvPoint2D32f point = new CvPoint2D32f(cvGetSeqElem(lines, i));
    cvCircle(src, cvPoint((int)point.x(), (int)point.y()), 3, CvScalar.WHITE, -1, 8, 0);
    Point p = new Point((int)point.x(), (int)point.y());
    points.add(p);
}

JavaCPP maps C/C++ arrays/pointers to Pointer objects, so we can access it in the same way as in C/C++, ie: JavaCPP将C / C ++数组/指针映射到Pointer对象,因此我们可以像在C / C ++中一样访问它,即:

FloatPointer p = new FloatPointer(cvGetSeqElem(circles, i));
int radius = Math.round(p.get(2));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM