Best way to count number of “White Blobs” in a Thresholded IplImage in OpenCV 2.3.0

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

<img src="https://i.stack.imgur.com/F1Y9J.jpg" alt="enter image description here">

Camera placed far from the marker

<img src="https://i.stack.imgur.com/fI7aF.jpg" alt="enter image description here">


What about the cvFindContours function? It's been a while since I use 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!


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.


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


  • why do I need glut.h, glut32.lib, glut32.dll ALL to compile an openGL program?
  • What do the Android camera zoom numbers mathematically represent?
  • comparing two floats to see if they're both negative, or both positive
  • Viola-Jones Algorithm - “Sum of Pixels”?
  • EaselJS custom font lineheight cross browser issues
  • Breaking a video into frames with python
  • Edit scikit-learn decisionTree
  • How to implement collision detection on nodes which are in StackPane (in JavaFX)?
  • How to debug CUDA kernels in Visual studio or Parallel Nsight
  • Is it possible to insert three numbers into 2 bytes variable?
  • In PHP, are objects methods code duplicated or shared between instances?
  • How to give photo to dialog from user's blob id?
  • Is it possible to instantiate an object of one class in two different ways?
  • Regarding RandomTree in Weka
  • Get content from jquery CLEditor
  • Angular dynamic component loading
  • Rendering complete camera view(16:9) onto a texture in Unity3d
  • OpenCL bytecode running on another card
  • Resource for understanding view, projection, 'virtual camera' in OpenGL or graphics in gen
  • How to realize with WinForms in C# something like an image with map areas in a homepage (at hooverin
  • How to make VBA count from 0 and not 1 in Excel Macro
  • Ensure Ruby version in Nix Dev Environment when using latest version
  • How to get a list of all blobs in a repository in Git
  • Git Merge Adds New File Instead of Conflict Markers - CONFLICT (rename/add)
  • Unable to scan Code 128
  • Using self.id to populate other fields in Django
  • How to get or calculate size of Azure File/Share or Service
  • Efficiently getting XML into Elasticsearch
  • Neo4j one-to-many fetch data
  • Phonegap GA plugin not working
  • Selecting a subset of data in ServiceStack.OrmLite
  • Negating Regex PO BOX
  • Galaxy S4 Android Custom Camera Issue
  • Using Nested Table variables / Collections in SQL inside PL/SQL blocks
  • WPF version of .ScaleControl?
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • How to include full .NET prerequisite for Wix Burn installer
  • Is it possible to post an object from jquery to bottle.py?