square detected problem in Touchlib
Posted: 16 May 2008 02:38 PM   [ Ignore ]
New Member
Avatar
Rank
Total Posts:  16
Joined  2008-03-26

Hi guys,
My blobs are very clear in Touchlib, the calibration also works fine and it detects my fingers on the right place.
But when I run the “Vision.bat” it keeps telling me “square detected 0” and when i touch it with one finger it says “square detected 1”, with 2 finger “"square detected 2” and so on. So it doesn’t tell me that any blob is detected. Anyone an idea what to do?
Tnx

 Signature 

Interfaces for pre-schoolchildren on interactive tables
http://cmdstud.khlim.be/~kstals/blog/

Profile
 
 
Posted: 17 May 2008 09:39 AM   [ Ignore ]   [ # 1 ]
New Member
Avatar
Rank
Total Posts:  16
Joined  2008-03-26

Is there a function that maybe kills these square detecting function? I don’t use squares in this project, only blobs…

 Signature 

Interfaces for pre-schoolchildren on interactive tables
http://cmdstud.khlim.be/~kstals/blog/

Profile
 
 
Posted: 21 May 2008 03:56 AM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  2
Joined  2008-05-21

I have a similar problem.
I configured the xml with the configapp.exe successfully but when i start a demo(smoke for example) it only prints “Square Detected” to the console.
Can anyone give a hint ?
Thx in advance.

Profile
 
 
Posted: 21 May 2008 01:14 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  1368
Joined  2007-04-08

Try hitting ‘b’ when the apps load to recapture the background. It’s probably seeing some kind of border around the screen and thinking it’s a square. If you recapture the background ‘b’ it should get rid of it.

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 21 May 2008 01:54 PM   [ Ignore ]   [ # 4 ]
New Member
Avatar
Rank
Total Posts:  16
Joined  2008-03-26

I wish it was that simple smile
He gives the number of the key when I hit “b” and than continues with “square detecting 0” every frame.
I really don’t understand what it could be...I’ve mailed Whitenoise a few times but he doesn’t know it eighter, my setting are correct.
There are bright blobs on a total black background and in the calibrationmode he does the job fine whitout disturbence.

Is there maybe someone who can adjust the code of touchlib and take this square detecting function out?
Or any other sollutions?

Image Attachments
rectify.jpgir-frame.jpg
 Signature 

Interfaces for pre-schoolchildren on interactive tables
http://cmdstud.khlim.be/~kstals/blog/

Profile
 
 
Posted: 21 May 2008 03:23 PM   [ Ignore ]   [ # 5 ]
New Member
Avatar
Rank
Total Posts:  16
Joined  2008-03-26

Yes, I’ve finally found it!
The problem was the edgy view of my blobs in the rectify-window. In reactivision the squares are always surounded by edgy noise. I’ve made them more smooth, and no square detecting anymore. So play a little with the filters and make the blobs as smooth as possible, it will work I think.

 Signature 

Interfaces for pre-schoolchildren on interactive tables
http://cmdstud.khlim.be/~kstals/blog/

Profile
 
 
Posted: 21 May 2008 04:09 PM   [ Ignore ]   [ # 6 ]
New Member
Rank
Total Posts:  2
Joined  2008-05-21

I commented the Square-Detection-Code in the CBlobTracker.cpp
now it looks like this:

void CBlobTracker::findBlobs_contour(BwImage &imgBwImage &label_img)
{

    blobList
.clear();
    
CvMemStoragestorage cvCreateMemStorage(0);
    
CvSeqcont 0
    
CvBox2D32f box;
    
float halfx,halfy;
    
CBlob blob;
    
float temp;
    
CvSeq *result;
    
//CvSeq *squares = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvPoint), storage );

    
double st;
    
unsigned int i;

    
bool isSquare false;

    
cvFindContoursimg.imgpstorage, &contsizeof(CvContour), CV_RETR_TREECV_CHAIN_APPROX_SIMPLE );

    for( ; 
cont != 0cont 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 cvApproxPolycontsizeof(CvContour), storage,
            
CV_POLY_APPROX_DPcvContourPerimeter(cont)*0.02);

        
/* 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(contstorage);        
            
}
            blob
.center.box.center.x;
            
blob.center.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(
>= reject_min_dimension && >= reject_min_dimension && reject_max_dimension && 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))

Profile