I commented the Square-Detection-Code in the CBlobTracker.cpp
now it looks like this:
void CBlobTracker::findBlobs_contour(BwImage &img, BwImage &label_img)
{
blobList.clear();
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* cont = 0;
CvBox2D32f box;
float halfx,halfy;
CBlob blob;
float temp;
CvSeq *result;
//CvSeq *squares = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvPoint), storage );
double s, t;
unsigned int i;
bool isSquare = false;
cvFindContours( img.imgp, storage, &cont, sizeof(CvContour), CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE );
for( ; cont != 0; cont = cont->h_next ) {
int count = cont->total; // This is number point in contour
// First we check to see if this contour looks like a square..
isSquare = false;
result = cvApproxPoly( cont, sizeof(CvContour), storage,
CV_POLY_APPROX_DP, cvContourPerimeter(cont)*0.02, 0 );
/* if( result->total == 4 &&
fabs(cvContourArea(result,CV_WHOLE_SEQ)) > 1000 &&
cvCheckContourConvexity(result) )
{
s = 0;
for( i = 0; i < 5; i++ )
{
// find minimum angle between joint
// edges (maximum of cosine)
if( i >= 2 )
{
t = fabs(cosAngle(
(CvPoint*)cvGetSeqElem( result, i ),
(CvPoint*)cvGetSeqElem( result, i-2 ),
(CvPoint*)cvGetSeqElem( result, i-1 )));
s = s > t ? s : t;
}
}
// if cosines of all angles are small
// (all angles are ~90 degree) then this is a square..
if( s < 0.5 )
{
box = cvMinAreaRect2(cont, storage);
blob.center.X = box.center.x;
blob.center.Y = box.center.y;
blob.angle = box.angle;
halfx = box.size.width*0.5f;
halfy = box.size.height*0.5f;
blob.box.upperLeftCorner.set(box.center.x-halfx,box.center.y-halfy);
blob.box.lowerRightCorner.set(box.center.x+halfx,box.center.y+halfy);
blob.area = blob.box.getArea();
// FIXME: it might be nice if we could get the actual weight..
// It also might be nice to find the weighted center..
blob.weight = 0;
// use v_next..
if(cont->v_next)
blob.tagID = getTag(cont->v_next);
printf("Square Detected %d\n", blob.tagID);
blobList.push_back(blob);
isSquare = true;
}
}*/
// fallback, if it's a regular blob.
if(!isSquare)
{
// Number point must be more than or equal to 6 (for cvFitEllipse_32f).
if( count >= 6)
{
// Fits ellipse to current contour.
box = cvFitEllipse2(cont);
} else {
box = cvMinAreaRect2(cont, storage);
}
blob.center.X = box.center.x;
blob.center.Y = box.center.y;
blob.angle = box.angle;
halfx = box.size.width*0.5f;
halfy = box.size.height*0.5f;
blob.box.upperLeftCorner.set(box.center.x-halfx,box.center.y-halfy);
blob.box.lowerRightCorner.set(box.center.x+halfx,box.center.y+halfy);
blob.area = blob.box.getArea();
// FIXME: it might be nice if we could get the actual weight..
// It also might be nice to
blob.weight = 0;
blob.tagID = 0;
int h=(int)blob.box.getHeight(), w=(int)blob.box.getWidth();
if(w >= reject_min_dimension && h >= reject_min_dimension && w < reject_max_dimension && h < reject_max_dimension)
blobList.push_back(blob);
}
} // end cont for loop
cvReleaseMemStorage(&storage);
}
Thats just because i dont know why i should know wether the Blobs are more Square-like or Sphere-Shaped.
It could mean some trouble with touchlib-using applications if they use the SquareDetection( but i want to programm my own app’s for it, so i dont care :D )
I recognized the noisy edges at my blobs as well and will try to reduce them tomorrow.
Could you maybe post your config.xml ?
Did you added some filters ?
What kind of camera are you using right now ? ( i have a simple Logitech Webcam Quickcam Fusion( removed IR-filter))