opencv Tracker is too slow in high revolution!
System information (version)
OpenCV => 3.4.2:
Operating System / Platform => Android:
Compiler => cmake
Detailed description
Hi, Is there any way to improve the Tracking frame rate? When I use high resolution, the efficiency is very slow. example: I set the resolution of my phone to 1280 * 720. the fps is 20 or less. in TrackerKCF algorithm. when set resolution to 640 * 480 .the fps will arrive at More than 20 close to 30. But my needs here are at 1280 * 720, reaching a frame rate close to 30 or 30+.
Please help me,thanks!
detail code:
i invoke startTracking by JNI in Camera's onPreviewCallback.
void startTracking(uint8_t* src_frame, int w, int h){
if(!isRectInit) return;
image = Mat(h,w,CV_8UC1,src_frame);
if(!isInit){
tracker = TrackerKCF::create();
isInit = tracker->init(image, bbox);
}
//cv::rectangle(image, bbox, Scalar( 255, 0, 0 ), 2, 1 );
//updates the tracker
if(isInit){
// Start timer
double timer = (double)getTickCount();
// Update the tracking result
bool isOk = tracker->update(image, bbox);
// Calculate Frames per second (FPS)
LOGD("startTracking 5 -- isOk = %d -- after update :%f--%f--%f--%f",isOk,bbox.x,bbox.y
,(bbox.x+bbox.width),(bbox.height+bbox.y));
float fps = getTickFrequency() / ((double)getTickCount() - timer);
LOGD("startTracking 6 -- %f ",fps);
}
yes, KCF is slow. but you have 7 alternatives to choose from there. try medianflow, CSRT, or MOSSE instead.
(and please close your issue here . it's the wrong repository (opencv_contrib) and you are not reporting a bug.)
hi berak, I closed the issue new . But I have tried the algorithms you mentioned, I found that the KCF effect is the best in those algorithms.
@berak Is there any other solution?
there is a benchmark program in the samples. i came to the opposite conclusion
@rainY what kind of objects do you want to track?
Why do you need to work at full resolution? You are on a mobile platform. Try to resize your image to a lower resolution, perform the tracking at this scale and update the bounding box to match the full resolution?
You have out of the box tracking algorithms. If you need better accuracy, you would probably need to implement yourself a modified tracking algorithm. Maybe track at low resolution and try to refine somehow the tracking at high resolution using a prior information from the tracking at low resolution?
@sturkmen Track anything,I only need to specify a region to track which area I am delineating.
@Eduardo "Try to resize your image to a lower resolution, perform the tracking at this scale and update the bounding box to match the full resolution?" I don't understand this sentence very well. Can you give me some code examples?
@berak Did your conclusion be tested with this code?
Tracking sample Is fps too low or not caused by VideoCapture? My data is obtained from the camera's onPreviewCallback, without VideoCapture. Is there any other way to improve fps besides replacing the algorithm?
I try medianflow. Occur this issue . app crash in TrackerMedianFlow