Skip to content

Commit

Permalink
code update with opencv 3.4 tracking module
Browse files Browse the repository at this point in the history
  • Loading branch information
gloomyfish1998 committed Dec 5, 2018
1 parent 8590f95 commit d891b29
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions dnn_tutorial/tracking_demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <opencv2/opencv.hpp>
#include <opencv2/tracking.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int artc, char** argv) {
Rect2d roi;
Mat frame;

// create a tracker object
Ptr<Tracker> tracker = TrackerKCF::create();
VideoCapture capture("D:/images/video/balltest.mp4");

// select roi
capture.read(frame);
roi = selectROI("tracker", frame);
// roi = selectROI(frame);

// init tracker with roi
tracker->init(frame, roi);

// update tracking roi for each frame
while (true) {
bool ret = capture.read(frame);
if (!ret) break;
tracker->update(frame, roi);
rectangle(frame, roi, Scalar(0, 0, 255), 2, 8, 0);
imshow("tracker", frame);
char c = waitKey(50);
if (c == 27) {
break;
}
}

waitKey(0);
return 0;
}

0 comments on commit d891b29

Please sign in to comment.