1

我想使用cvHoughCirclesVisual c# 中的方法检测对象。如果有人知道如何做到这一点,请帮助我。

编辑细节:

gray.HoughCircles我在网上搜索了有使用方法的例子。
这是我的代码。

 Image<Bgr, Byte> image = capture.QueryFrame();
 MCvScalar hsv_min = new MCvScalar(150, 84, 130, 0);
 MCvScalar hsv_max = new MCvScalar(358, 256, 255, 0);
 IntPtr hsv_frame = CvInvoke.cvCreateImage(new System.Drawing.Size(640,         480),IPL_DEPTH.IPL_DEPTH_8U, 3);
 IntPtr thresholded = CvInvoke.cvCreateImage(new System.Drawing.Size(640, 480), IPL_DEPTH.IPL_DEPTH_8U, 1);


 CvInvoke.cvCvtColor(image, hsv_frame, COLOR_CONVERSION.CV_BGR2HSV);
 CvInvoke.cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);

 IntPtr storage = CvInvoke.cvCreateMemStorage(0);
  CvInvoke.cvSmooth(thresholded, thresholded, SMOOTH_TYPE.CV_GAUSSIAN, 9, 9, 0, 0);

IntPtr circles= CvInvoke.cvHoughCircles(thresholded,   storage,HOUGH_TYPE.CV_HOUGH_GRADIENT , 2, 4, 100, 50, 10, 400);   

在下面的链接中有代码。但它在 pythen 中。所以我正在做的是试图将它转换为可视化 c#。

http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision/#comment-847

我想将所有检测到的圆圈放入 for 循环中,然后像在 pythen 代码中一样将圆圈绘制到相应的对象。

我尝试使用 foreach 循环但出现错误,

foreach 语句无法对“System.IntPtr”类型的变量进行操作,因为“System.IntPtr”不包含“GetEnumerator”的公共定义。

有什么方法可以避免这个错误。

4

1 回答 1

1

你试过这个教程吗?
CSharp 中的形状(三角形、矩形、圆形、线)检测

这包含很好的教程,可能会对您有所帮助。

于 2011-06-10T14:36:28.313 回答