Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

clear ROI history from kcf tracking in opencv

I am using KCF tracking in OpenCV. everything is okay and i can track an object as well, but i have a problem: i set a ROI and algorithm work fine, sometimes i need change my ROI. there for tracker should reset and track my new ROI but it won't. in fact last ROI will remain in history and it effect on new location.

also this is my codes summary, i wrote important lines:

Rect2d roi;
Mat frame;
Ptr<Tracker> tracker = Tracker::create("KCF");
VideoCapture cap("C1_0001.mp4");
cap >> frame;
roi = selectROI("tracker", frame);

if (Condition = true)
{
roi = selectROI("tracker", frame);
}

tracker->init(frame, roi);
for (;; ) 
{
        cap >> frame;
        tracker->update(frame, roi);
}

i want change ROI when Condition is true.

if need i can upload a video clip for more explanation.