title: opencv cvblob -- render blobs other than white
body: <p>I am trying to detect objects with cvblob. Somehow, my code only marks the white objects. How to mark objects of other colors, like a can of beer or a bottle of water.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include "highgui.h"
  #include "cv.h"
  #include "cvaux.h"
  #include "iostream"
  #include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  
  #include &lt;cvblob.h&gt;
  
  using namespace cv;
  using namespace std;
  using namespace cvb;
  
  int main(int argc, char** argv) {
      CvTracks tracks;
  
      cvNamedWindow("frame", CV_WINDOW_AUTOSIZE);
      cvMoveWindow("frame", 50, 100);
  
      CvCapture* capture;
  
      IplImage* frame = 0;
  
      capture = cvCreateCameraCapture( 0 ); //capture frames from cam on index 0: /dev/video0/
  
      if (!capture) {
          return -1;
      }
  
      cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
      cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
  
      frame = cvQueryFrame(capture);
  
      while(frame) {
          IplImage *gray = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
          cvCvtColor(frame, gray, CV_BGR2GRAY);
          cvThreshold(gray, gray, 150, 255, CV_THRESH_BINARY);
  
          IplImage *labelImg=cvCreateImage(cvGetSize(gray), IPL_DEPTH_LABEL, 1);
          CvBlobs blobs;
          unsigned int result=cvLabel(gray, labelImg, blobs);
  
          cvFilterByArea(blobs, 500, 1000000);
  //        cvRenderBlobs(labelImg, blobs, frame, frame, CV_BLOB_RENDER_BOUNDING_BOX);
          cvRenderBlobs(labelImg, blobs, frame, frame, CV_BLOB_RENDER_CENTROID);
          cvUpdateTracks(blobs, tracks, 200., 5);
          cvRenderTracks(tracks, frame, frame, CV_TRACK_RENDER_ID|CV_TRACK_RENDER_BOUNDING_BOX);
  
  
          for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it) {
              cout &lt;&lt; "Blob #" &lt;&lt; it-&gt;second-&gt;label &lt;&lt; ": Area=" &lt;&lt; it-&gt;second-&gt;area &lt;&lt; ", Centroid=(" &lt;&lt; it-&gt;second-&gt;centroid.x &lt;&lt; ", " &lt;&lt; it-&gt;second-&gt;centroid.y &lt;&lt; ")" &lt;&lt; endl;
          }
  
          cvShowImage("frame", frame);
  
          cout &lt;&lt; "----------------------------" &lt;&lt; endl;
  
          frame = cvQueryFrame(capture);
  
          char c = cvWaitKey(10);
          if(c==27)
              break;
  
      }
  }
  </code></pre>
  
  <p>Any tip is appreciated.</p>
  
  <p>Milo</p>