我想使用cvHoughCircles
Visual 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”的公共定义。
有什么方法可以避免这个错误。