Advertisement
kzbr93

new

May 8th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. // Standard include files
  2. #include <opencv2/opencv.hpp>
  3. #include <opencv2/tracking.hpp>
  4. #include "opencv2/imgcodecs.hpp"
  5.  
  6. using namespace cv;
  7. using namespace std;
  8.  
  9. int main(int argc, char **argv)
  10. {
  11. // Set up tracker.
  12. // Instead of MIL, you can also use
  13. // BOOSTING, KCF, TLD, MEDIANFLOW or GOTURN
  14. Ptr<Tracker> tracker = Tracker::create(const String& TrackerMIL );
  15.  
  16. // Read video
  17. VideoCapture video("videos/chaplin.mp4");
  18.  
  19. // Check video is open
  20. if(!video.isOpened())
  21. {
  22. cout << "Could not read video file" << endl;
  23. return 1;
  24. }
  25.  
  26. // Read first frame.
  27. Mat frame;
  28. video.read(frame);
  29.  
  30. // Define an initial bounding box
  31. Rect2d bbox(287, 23, 86, 320);
  32.  
  33. // Uncomment the line below if you
  34. // want to choose the bounding box
  35. // bbox = selectROI(frame, false);
  36.  
  37. // Initialize tracker with first frame and bounding box
  38. tracker->init(frame, bbox);
  39.  
  40. while(video.read(frame))
  41. {
  42. // Update tracking results
  43. tracker->update(frame, bbox);
  44.  
  45. // Draw bounding box
  46. rectangle(frame, bbox, Scalar( 255, 0, 0 ), 2, 1 );
  47.  
  48. // Display result
  49. imshow("Tracking", frame);
  50. int k = waitKey(1);
  51. if(k == 27) break;
  52.  
  53. }
  54.  
  55. return 0;
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement