我需要计算阈值图像中白色斑点的数量。我正在数一个标记上的小方块。但是由于网络摄像头的图像质量很差,这些正方形不会显示为正方形。这就是我决定使用 Blob 检测的原因。这适用于增强现实应用程序。我的决定对吗?
相机放置在标记附近
相机远离标记
我需要计算阈值图像中白色斑点的数量。我正在数一个标记上的小方块。但是由于网络摄像头的图像质量很差,这些正方形不会显示为正方形。这就是我决定使用 Blob 检测的原因。这适用于增强现实应用程序。我的决定对吗?
相机放置在标记附近
相机远离标记
cvFindContours
功能呢?自从我使用它已经有一段时间了,但我认为您可以在找到的轮廓的 CvSeq 中进行迭代,并以您喜欢的方式使用它们。
我知道这是一个旧线程,但也许它可以帮助你!
How about using the cvBlobsLib. This detects connected regions which you should easily be able to count, and obtain further information such as their size.
我使用了 findContours 函数。这是一段代码:
std::vector<std::vector<cv::Point> > contours;
cv::findContours(m, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
for( unsigned int i = 0; i < contours.size(); i++ )
{
if( contours[i].size() < 3 ) // at least a triangular area?
continue;
double area = cv::contourArea(Mat(contours[i]) );
if ( (area > min * min) && ( area < max * max ) )
{
//... use or count blob