KCF核相关滤波(阉割版)
BOOSTING(机器学习)、MIL、MEDIANFLOW、TLD
#include <opencv2/opencv.hpp>
#include <iostream>
#include <opencv2/tracking.hpp>//KCF核相关滤波
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
VideoCapture capture;
capture.open("../path.avi");
//capture.open(0);
if (!capture.isOpened())
{
cout << "could not load video..." << endl;
return -1;
}
namedWindow("Video_demo", WINDOW_AUTOSIZE);
Mat frame;
capture.read(frame);//读取第一帧
Ptr<TrackerKCF> tracker = TrackerKCF::create();//KCF跟踪//一种阉割版跟踪算法
Rect2d ROI = selectROI("Video_demo", frame);//用鼠标框选ROI
if (ROI.width == 0 || ROI.height == 0)
{
return -2;
}
tracker->init(frame, ROI);
while (capture.read(frame))
{
tracker->update(frame, ROI);
rectangle(frame, ROI, Scalar(255, 0, 255), 2, 8, 0);
imshow("Video_demo", frame);
char c = waitKey(100);
if (c == 27)
{
break;
}
}
capture.release();
waitKey(0);
return 0;
}
输出结果:
来源:CSDN
作者:丶小早
链接:https://blog.csdn.net/weixin_45553439/article/details/104373642