[英]Please can some one help on convert opencv code in to javacv?
我发现了一些识别特定图像中的圆圈的代码,并且我能够将 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),但这里有一些对您有用的链接:
samples/HoughLines.java
。 它与从 repo 中删除的HoughCircles.java
非常相似。OpenCV2_Cookbook/src/opencv2_cookbook/chapter07/ex4HoughCircles.scala
。 这是该文件中的部分代码:// 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")
这正是您正在寻找的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.