Comparison of blob detection and structural analysis and form descriptors in opencv

I need to use the blob definition and structural analysis and shape descriptors (more specifically findContours, drawContoursand moments) to detect color circles in the image. I need to know the pros and cons of each method and which method is better. Can someone show me the differences between the two methods?

+3
source share
1 answer

As @ scap3y explained in the comments, I would go for a much simpler approach. What I always do in these cases looks like this:

// Convert your image to HSV color space
Mat hsv;
hsv.create(originalImage.size(), CV_8UC3);
cvtColor(originalImage,hsv,CV_RGB2HSV);

// Chose the range in each of hue, saturation and value and threshold the other pixels
Mat thresholded;
uchar loH = 130, hiH = 170;
uchar loS = 40, hiS = 255;
uchar loV = 40, hiV = 255;
inRange(hsv, Scalar(loH, loS, loV), Scalar(hiH, hiS, hiV), thresholded);

// Find contours in the image (additional step could be to 
// apply morphologyEx() first)
vector<vector<Point>> contours;
findContours(thresholded,contours,CV_RETR_EXTERNAL,CHAIN_APPROX_SIMPLE);

// Draw your contours as ellipses into the original image
for(i=0;i<(int)valuable_rectangle_indices.size();i++) {
    rect=minAreaRect(contours[valuable_rectangle_indices[i]]);
    ellipse(originalImage, rect, Scalar(0,0,255));  // draw ellipse
}

The only thing left for you to do is find out in what range your markers are in the HSV color space .

+1

All Articles