Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem: http://www.0up.ir/do.php?downf=4_e2aa9.mp4

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem: http://www.0up.ir/do.php?downf=4_e2aa9.mp4

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem: http://www.0up.ir/do.php?downf=4_e2aa9.mp4

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

http://www.0up.ir/do.php?downf=4_e2aa9.mp4

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

http://www.0up.ir/do.php?downf=4_e2aa9.mp4

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

http://www.0up.ir/do.php?downf=4_e2aa9.mp4http://www.0up.ir/do.php?downf=4_e2aa9.mp4 (if you can't download it, please copy link and paste it in your browser address bar)

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

http://www.0up.ir/do.php?downf=4_e2aa9.mp4 http://www.0up.ir/do.php?downf=4_e2aa9.mp4

(if you can't download it, please copy link and paste it in your browser address bar)

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

http://www.0up.ir/do.php?downf=4_e2aa9.mp4www.0up.ir/do.php?downf=4_e2aa9.mp4

(if you can't download it, please copy link and paste it in your browser address bar)

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

www.0up.ir/do.php?downf=4_e2aa9.mp4

(if you can't download it, please copy link and paste it in your browser address bar)

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

Hello I am using KCF tracking algorithm, my problem is when the target exit from window, the tracker won't reset and show it's rectangle on edge of window wrongly. in ideal state tracker should delete the rectangle when it lose the target.

These are my codes:

int main(int argc, char** argv) {
        Rect2d roi;
        Mat frame;

        // create a 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 was not selected
        if (roi.width == 0 || roi.height == 0)
            return 0;
        // initialize the tracker
        tracker->init(frame, roi);
        // perform the tracking process
        printf("Start the tracking process, press ESC to quit.\n");
        for (;; ) {

                // get frame from the video
            cap >> frame;
            resize(frame, frame, Size(frame.cols / 2, frame.rows / 2));
            // stop the program if no more images
            if (frame.rows == 0 || frame.cols == 0)
                break;
            // update the tracking result
            tracker->update(frame, roi);

            rectangle(frame, roi, Scalar(255, 0, 0), 2, 1);

            imshow("tracker", frame);
            if (waitKey(1) == 27)break;
        }
}

Also you can see a short video of my simulation and see the problem:

www.0up.ir/do.php?downf=4_e2aa9.mp4

(if you can't download it, please copy link and paste it in your browser address bar)