Example #1
0
  void cvFilterByArea(CvBlobs &blobs, unsigned int minArea, unsigned int maxArea)
  {
    CvBlobs::iterator it=blobs.begin();
    while(it!=blobs.end())
    {
      CvBlob *blob=(*it).second;
      if ((blob->area<minArea)||(blob->area>maxArea))
      {
	cvReleaseBlob(blob);

	CvBlobs::iterator tmp=it;
	++it;
	blobs.erase(tmp);
      }
      else
	++it;
    }
  }
Example #2
0
bool cvbCvBlobsAdd(cvb::CvBlobs* blobs, unsigned int label, cvb::CvBlob* blob)
{
   if (!blob) return false;

   cvb::CvBlob* newBlob = new cvb::CvBlob();
   memcpy(newBlob, blob, sizeof(cvb::CvBlob));

   std::pair< cvb::CvBlobs::iterator, bool > result = blobs->insert(cvb::CvLabelBlob(label, newBlob));

   if (!result.second)
   {  //key already exist
      //blob is not added
      //we should delete the newBlob to avoid memory leak
      cvReleaseBlob(newBlob);
      delete newBlob;
   }
   return result.second;
}