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.
afaik, you have to re-init the tracker with the new ROI.
i think you can use roi.clear() to erase the old values
@ManuVISION that won't clear tracker history
yes, that won't clear, i solved it. i use Ptr<tracker> tracker = Tracker::create("KCF") every where need to reset.