gpt4 book ai didi

java - 请有人帮助将 opencv 代码转换为 javacv?

转载 作者:太空宇宙 更新时间:2023-11-03 22:34:32 25 4
gpt4 key购买 nike

我找到了一些识别特定图像中的圆圈的代码,并且我能够将其中 90% 的代码转换为 javacv。但不幸的是,我无法将以下行转换为 javacv。那么请有人帮我把这些行转换成 javacv 吗?

CvSeq circles = cvHoughCircles(gry, mem, CV_HOUGH_GRADIENT, 1, 40.0, 100, 100,0,0);
cvCvtColor(canny, rgbcanny, CV_GRAY2BGR);

for (int i = 0; i < circles->total; i++)
{
// round the floats to an int
float* p = (float*)cvGetSeqElem(circles, i);
cv::Point center(cvRound(p[0]), cvRound(p[1]));
int radius = cvRound(p[2]);

// draw the circle center
cvCircle(img, center, 3, CV_RGB(0,255,0), -1, 8, 0 );

// draw the circle outline
cvCircle(img, center, radius+1, CV_RGB(0,0,255), 2, 8, 0 );

printf("x: %d y: %d r: %d\n",center.x,center.y, radius);
}

我只需要知道如何转换 for 循环内的 5 行代码。请善待分享您的经验。谢谢。

最佳答案

好吧,我不会为您转换该代码(我不懂 JavaCV),但这里有一些对您有用的链接:


// Draw lines on the canny contour image
val colorDst = cvCreateImage(cvGetSize(src), src.depth(), 3)
cvCvtColor(src, colorDst, CV_GRAY2BGR)
for (i <- 0 until circles.total) {
val point = new CvPoint3D32f(cvGetSeqElem(circles, i))
val center = cvPointFrom32f(new CvPoint2D32f(point.x, point.y))
val radius = math.round(point.z)
cvCircle(colorDst, center, radius, CV_RGB(255, 0, 0), 1, CV_AA, 0)
print(point)
}
show(colorDst, "Hough Circles")

这正是您要找的。

关于java - 请有人帮助将 opencv 代码转换为 javacv?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11175539/

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