Unable to track faces. How to update trackers ???

asked 2017-04-12 07:21:56 -0600

ManuVISION gravatar image

updated 2017-04-12 07:50:14 -0600

I am doing a multiple faces detection & tracking. But the trackers are not updating properly.

The code runs without errors when compiling. During runtime I get the below message (not error tho)

''Trackers are initialized correctly.

unable to track"

Here is the code:

    // Detect faces
    std::vector<Rect> faces;
    Rect2d face_rect2d;
    face_cascade.detectMultiScale( image, faces, 1.2, 2, 0|CV_HAAR_SCALE_IMAGE, Size(min_face_size, min_face_size),Size(max_face_size, max_face_size) );



  for(unsigned int i = 0; i < faces.size(); ++i)
  {        


    face_rect2d = faces[i];

    rectangle(image,face_rect2d, Scalar( 255, 255, 0 ), 1, 4 ); // Draw the detections


    Ptr<Tracker> tracker = Tracker::create( "MEDIANFLOW" ); // Create tracker

    if (tracker.empty())
{
    std::cerr << "***Error in the instantiation of the tracker...***\n";
    return -1;
    }



      // Check if they are initialized
     if (!tracker->init(image, face_rect2d))
     {
    std::cerr << "***Could not initialize tracker...***\n";
    return -1;
 }
 else
 {

        std::cout << "Trackers are initialized correctly." << std::endl;
     }



     // Check if they are updated

     if (!(tracker->update(image, face_rect2d))) {
                printf("unable to track\n"); 
              }



     cv::rectangle(image,face_rect2d, cv::Scalar(255, 0, 255), 2, 1);

  }
edit retag flag offensive close merge delete

Comments

You should use the multitracker interface, take a look at this sample.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-04-12 07:54:21 -0600 )edit

Thanks. I already tried MultiTracking for people tracking a while ago. No good results. Can u please help where i'm going wrong here?? The code is in the link: http://answers.opencv.org/question/124457/why-this-code-is-not-able-to-track-people/ (http://answers.opencv.org/question/12...)

ManuVISION gravatar imageManuVISION ( 2017-04-12 08:06:27 -0600 )edit

Can you please focus everything into a single topic. It is all about not being able to get the tracking going ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-04-14 07:43:52 -0600 )edit