TLD tracking too slow [closed]

asked 2017-03-23 12:18:24 -0600

mirnyy gravatar image

updated 2017-03-23 12:20:31 -0600

Hello,
i am using the Tracking module in OpenCV to track several objects.

I tried few algorithms (MIL, MEDIANFLOW, TLD, ...) and the TLD is looking like the most accurate one.
But it is very slow (every frame takes about 1 second to calculate). The resolution is 640 x 480.

Does anyone know to speed it up?

#include <opencv2/opencv.hpp>
#include <opencv2/tracking.hpp>

using namespace std;
using namespace cv;

int main(int argc, char **argv){

    Ptr<Tracker> tracker = Tracker::create("TLD");
    VideoCapture cap(0);

    Mat frame;
    cap >> frame;

    Rect2d bbox;
    bbox = selectROI("tracker", frame, false);

    tracker->init(frame, bbox);

    while (true)
    {
        cap >> frame;

        tracker->update(frame, bbox);
        rectangle(frame, bbox, Scalar(255, 0, 0), 2, 1);

        imshow("Tracking", frame);
        waitKey(1);
    }

    return 0;
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-12-18 14:59:36.383981

Comments

1

With i7-5820 OCV 3.2 using win 10 in release mode It works at 10fps

LBerger gravatar imageLBerger ( 2017-03-23 14:51:34 -0600 )edit

you can try the code here

sturkmen gravatar imagesturkmen ( 2017-03-23 15:52:43 -0600 )edit

@LBerger, the TLD tracker has opencl support, is that "on" ?

berak gravatar imageberak ( 2017-03-24 04:02:04 -0600 )edit
2

@berak yes opencl is on in my configuration. I use tracker sample changing line 114 in cap.open( 0 ); then running tracking-example-tracker TLD TOTO :25fps with setUseOpenCL(true) and may be 7 fps with setUseOpenCL(false);

LBerger gravatar imageLBerger ( 2017-03-24 05:28:14 -0600 )edit
3

Could it be, that my code is so slow, because i run it in Debug Mode?

mirnyy gravatar imagemirnyy ( 2017-03-24 07:49:55 -0600 )edit

@mirnyy , that's very likely ;)

berak gravatar imageberak ( 2017-03-24 07:55:19 -0600 )edit

Also, keep in mind that the more objects you track, the slower your system will be. This is inherit behaviour for all trackers/object detectors/... As to the debug, switch your OpenCV build to Release and you will be amazed what a speed gain you get!

StevenPuttemans gravatar imageStevenPuttemans ( 2017-03-24 08:13:41 -0600 )edit
1

thanks! i am going to build OpenCV in Release mode and then testing it again

mirnyy gravatar imagemirnyy ( 2017-03-24 08:37:44 -0600 )edit

Thanks for the code. I used the selectROI for manual selection. After that there is no tracking. What am I missing here ?? Someone plz tell

ManuVISION gravatar imageManuVISION ( 2017-04-12 15:04:16 -0600 )edit

I can't help without code

mirnyy gravatar imagemirnyy ( 2017-04-28 06:53:15 -0600 )edit