c++ - How to reset or update KCF tracker ROI when it lose the target -


i using kcf tracking algorithm, problem when target exit window, tracker won't reset , show it's rectangle on edge of window wrongly. in ideal state tracker should delete rectangle when lose target.

these codes:

int main(int argc, char** argv) {         rect2d roi;         mat frame;          // create tracker object         ptr<tracker> tracker = tracker::create("kcf");          videocapture cap("c2_0002.mp4");          cap >> frame;         resize(frame, frame, size(frame.cols / 2, frame.rows / 2));         roi = selectroi("tracker", frame);         //quit if roi not selected         if (roi.width == 0 || roi.height == 0)             return 0;         // initialize tracker         tracker->init(frame, roi);         // perform tracking process         printf("start tracking process, press esc quit.\n");         (;; ) {                  // frame video             cap >> frame;             resize(frame, frame, size(frame.cols / 2, frame.rows / 2));             // stop program if no more images             if (frame.rows == 0 || frame.cols == 0)                 break;             // update tracking result             tracker->update(frame, roi);              rectangle(frame, roi, scalar(255, 0, 0), 2, 1);              imshow("tracker", frame);             if (waitkey(1) == 27)break;         } } 

also can see short video of simulation , see problem: http://www.0up.ir/do.php?downf=4_e2aa9.mp4

can specify little more?
a) want delete whole tracker
b) don't want print rectangle if there no update on tracker

i not sure if tracker work again if object returns (returns @ same position or @ position next old exit position), think simple solution displaying is:

create variable count steps tracker->update(frame, roi) returns false , set 0 if tracker->update(frame, roi) returns true. above number(threshold) rectangle(frame, roi, scalar(255, 0, 0), 2, 1) should not called or can delete tracker/break loop(like said before not sure if work again, additionally tracker uses active learning - learns every step: false training samples lead wrong behaviour)

fyi->the original paper: http://www.robots.ox.ac.uk/~joao/publications/henriques_eccv2012.pdf)


Comments

Popular posts from this blog

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - SSE Emitter : Manage timeouts and complete() -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -