Full width home advertisement

OpenCV

HTML

Post Page Advertisement [Top]

    OpenCV 3.4+ Introduce different single object tracking algorithm such as CSRT, MIL, KCF, TLD, GOTURN, MEDIANFLOW, MOSSE and BOOSTING

OpenCV Object Tracking

    Below is the C++ code which will give the idea how the Tracking API can be used to track single Object. Here I have used TrackerCSRT

C++ Code


    Rect2d roi;
    Mat frame;
    namedWindow("tracker",1);

    // create a tracker object
    Ptr tracker = TrackerCSRT::create();
    std::string video = "track.mp4";
    VideoCapture cap(video);
    cap >> frame;
    resize(frame,frame,Size(1080,720));
    roi=selectROI("tracker",frame);

    //quit if ROI was not selected
    if(roi.width==0 || roi.height==0)
      return;

    //initialize the tracker
    tracker->init(frame,roi);
    printf("Press ESC to quit.\n");
    for ( ;; ){
      cap >> frame;
      resize(frame,frame,Size(1080,720));
      if(frame.rows==0 || frame.cols==0)
        break;

      // update the tracking result
      tracker->update(frame,roi);

      rectangle( frame, roi, Scalar( 255, 0, 0 ), 2, 1 );
      imshow("tracker",frame);
      if(waitKey(1)==27)break;
    }

Demo



No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib