-4

I am working on a project that detects signs, I am currently using haar training to obtain the hand detection. I have trained XML files for different signs. I am unable to use multiple XML files in my detection program. Is there anyway by which I can include different XML files to detect different signs or another method that I can follow to detect multiple signs

Thanks in advance.

Code:

if( cascade1)
{

    // There can be more than one hand in an image. So create a growable sequence of hands.
    // Detect the objects and store them in the sequence
    CvSeq* hands1 = cvHaarDetectObjects( img, cascade1, storage,
                                        1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
                                        cvSize(40, 40) );
     // Loop the number of hands found.
    for( i = 0; i < (hands1 ? hands1->total : 0); i++ )
    {
       // Create a new rectangle for drawing the hand
        CvRect* r = (CvRect*)cvGetSeqElem( hands1, i );

        // Find the dimensions of the hand,and scale it if necessary
        pt1.x = r->x*scale;
        pt2.x = (r->x+r->width)*scale;
        pt1.y = r->y*scale;
        pt2.y = (r->y+r->height)*scale;

        // Draw the rectangle in the input image
        cvRectangle( img, pt1, pt2, CV_RGB(230,20,232), 3, 8, 0 );
        //text



          // Show the image in the window named "result"
cvShowImage( "result", img );
}
}
else if (cascade2)
{
    CvSeq* hands2 = cvHaarDetectObjects( img, cascade2, storage,
                                        1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
                                        cvSize(40, 40) );
     // Loop the number of hands found.
    for( i = 0; i < (hands2 ? hands2->total : 0); i++ )
    {
       // Create a new rectangle for drawing the hand
        CvRect* r = (CvRect*)cvGetSeqElem( hands2, i );

        // Find the dimensions of the hand,and scale it if necessary
        pt3.x = r->x*scale;
        pt4.x = (r->x+r->width)*scale;
        pt3.y = r->y*scale;
        pt4.y = (r->y+r->height)*scale;

        // Draw the rectangle in the input image
        cvRectangle( img, pt3, pt4, CV_RGB(230,20,232), 3, 8, 0 );
        //text


         // Show the image in the window named "result"
cvShowImage( "result", img );

It detects only onexml file

Ramesh-X
  • 4,853
  • 6
  • 46
  • 67
  • 1
    please stop living under a rock, and use opencv's c++ api instead of the deprecated c one – berak Jul 14 '14 at 05:46

1 Answers1

1

The most simple way is to detect signs with different XML files one after another and then combine the results.

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
  • i tried doing that ,i create two cascade classifiers but only one image gets detected..i have added the code seg above – user3422458 Mar 17 '14 at 05:56