使用OpenCV检测小圆圈(图像质量差)

我正试图检测你在这张照片中央可以看到的四个点: 在此处输入图像描述 这个转换为png,我实际上使用ppm格式(从相机的原始输出转换后)。 实际处理的图像可在此处获得

我是opencv的新手,因此在检测这些点时遇到了很大的问题。 这是我迄今为止最好的结果: 在此处输入图像描述

正如你所看到的,我已经检测到了3个点,但除此之外,图片中的许多其他东西都被识别为圆圈。

这是代码:

IplImage* img; if((img = cvLoadImage( "photos/img-000012.ppm", 1)) == 0 ) { perror("cvLoadImage"); return 1; } cvNamedWindow( "Image view", 1 ); cvShowImage( "Image view", img ); // cvWaitKey(0); IplImage* gray = cvCreateImage( cvGetSize(img), 8, 1 ); // allocate a 1 channel byte image CvMemStorage* storage = cvCreateMemStorage(0); cvCvtColor( img, gray, CV_BGR2GRAY ); cvShowImage( "Image view", gray ); // cvWaitKey(0); cvSmooth( gray, gray, CV_GAUSSIAN, 3, 3, 0, 0 ); cvShowImage( "Image view", gray ); cvWaitKey(0); CvSeq* circles = cvHoughCircles(gray, storage, CV_HOUGH_GRADIENT, 4, // inverse ratio of the accumulator resolution 1, // minimum distance between circle centres 100, // higher threshold value for Canny 20, // accumulator threshold for the circle centers; smaller->more false circles 1, // minimum radius 10 ); // maximum radius printf("circles == %d\n", circles->total); int i; for (i = 0; i total; i++) { float *p = (float*)cvGetSeqElem(circles, i); CvPoint center = cvPoint(cvRound(p[0]),cvRound(p[1])); CvScalar val = cvGet2D(gray, center.y, center.x); if (val.val[0] < 1) continue; printf("%d %d %d\n", cvRound(p[0]),cvRound(p[1]), cvRound(p[2])); cvCircle(img, center, cvRound(p[2]), CV_RGB(0,255,0), 1, CV_AA, 0); } cvShowImage( "Image view", img ); cvWaitKey(0); 

你知道如何帮助吗? 我将非常感激。 我认为人眼很容易发现斑点,所以我希望我能用电​​脑检测它们。

你应该看一下这篇文章 。

在我基于它开发的应用程序中,我得到了:

在此处输入图像描述

您基本上可以根据您的情况调整此方法并使其更有效 :“5。” (“在形状的大小,面积,凸度……上validation或使轮廓无效。” 在你的情况下可能会更加严格,因为你没有圆圈簇 。你可以只绘制几乎完美的物体另外,你知道你的圈子有相同的大小/相对强度……

告诉我,如果有什么不清楚,

祝好运,

我认为霍夫变换不是最好的情况。 您可以对它们进行分段,然后使用它们的颜色和几何参数进行识别。