TLD tracking too slow [closed]
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;
}
With i7-5820 OCV 3.2 using win 10 in release mode It works at 10fps
you can try the code here
@LBerger, the TLD tracker has opencl support, is that "on" ?
@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);
Could it be, that my code is so slow, because i run it in Debug Mode?
@mirnyy , that's very likely ;)
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!
thanks! i am going to build OpenCV in Release mode and then testing it again
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
I can't help without code