CT算法详细解析可以参考:快速压缩跟踪(fast compressive tracking)(CT)算法剖析
论文源码在作者主页上下载,我测试了一下,主要是比较一下各个算法,看如何往嵌入式上移植。
程序也比较简单,论文也值得看一下。
int main(int argc, char * argv[])
{
CompressiveTracker ct;
Mat grayImg;
VideoCapture cap;
char c;
cap.open("E:\\dataSet\\xinpingtai_video\\xidian.mp4");
//cap.open("E:\\dataSet\\155\\test1.mp4");
//cap.open("E:\\dataSet\\zx\\sd2 截取视频.mp4");
// get bounding box
cap >> frame;
//blur(frame, frame, Size(3, 3));
namedWindow("tracker", CV_WINDOW_NORMAL);
Rect roi = selectROI("tracker", frame, true, false);
ct.init(grayImg, roi);
long frameNum = 0;
long frameSum = cap.get(CAP_PROP_FRAME_COUNT);
while (frameNum < frameSum)
{
cap >> frame;
frameNum++;
clock_t begin = clock();
cvtColor(frame, grayImg, CV_RGB2GRAY);
ct.processFrame(grayImg, roi);// Process frame
rectangle(frame, roi, Scalar(255, 0, 0));//能够实时显示在画矩形窗口时的痕迹
clock_t end = clock();
cout << (double)(end - begin) / 1000 << endl;
imshow("tracker", frame);
if (waitKey(10) == 'r') {
Rect roi = selectROI("tracker", frame, true, false);
// initialization
ct.init(grayImg, roi);
}
if (waitKey(10) == 27)
break;
imshow("frame", frame);
}
return 0;
}