Best way to count number of "White Blobs" in a Thresholded IplImage in OpenCV 2.3.0
Asked Answered
C

3

1

I need to count the number of white blobs in a Thresholded image. I'm counting small squares on a marker. But due to the poor image quality of the webcam, these squares don't appear as squares. This is why I decided to use Blob detection. This is for an Augmented reality application. Is my decision right?

Camera placed near the marker

enter image description here

Camera placed far from the marker

enter image description here

Cryogenics answered 24/11, 2011 at 15:55 Comment(1)
Have you found a solution?Lazaro
B
3

What about the cvFindContours function? It's been a while since I've used it, but I think you can then iterate in the CvSeq of found contours and work with them the way you like.

I know it's an old thread but maybe it can help you!

Bermudez answered 23/1, 2013 at 19:13 Comment(0)
U
2

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.

Unsound answered 24/11, 2011 at 16:37 Comment(2)
Thanks for the reply. I followed those steps. But Build failed due to various errors. 1) im on OpenCV2.3, Visual C++ 2008 and it requires cxtypes.h which is not found on my machine. I used types_c.h instead 2) cvBlobsLib requires afx.h and afxwin.h. Again, not found! :(Cryogenics
I have just come across the following page which discusses blob detection, and the various libraries available: shervinemami.co.cc/blobs.html Perhaps it will be of some use to you?Unsound
L
1

I have used findContours function. Here is the piece of code:

    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
Lazaro answered 13/8, 2014 at 9:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.