Currently I’m getting less than 1fps using CSRT tracker on my Jetson Nano B01 with this code using opencv 4.10.0. 30 fps or more is what I’m shooting for. How can I change this code to improve the performance? I was getting 25-30 fps with this code on opencv 4.5.0. Could it be a version change that’s the difference? Or is there something I’m missing here?
void track_target(void)
{
/* Don't wrap the image from jetson inference until a valid image has been received.
That way we know the memory has been allocaed and is ready. */
if (valid_image_rcvd && !initialized_cv_image)
{
image_cv_wrapped = cv::Mat(input_video_height, input_video_width, CV_8UC3, image); // Directly wrap uchar3*
initialized_cv_image = true;
}
else if (valid_image_rcvd && initialized_cv_image)
{
if (target_valid && !initialized_tracker)
{
target_bounding_box = cv::Rect(target_left, target_top, target_width, target_height);
tracker_init(target_tracker, image_cv_wrapped, target_bounding_box);
initialized_tracker = true;
}
if (initialized_tracker)
{
target_tracked = tracker_update(target_tracker, image_cv_wrapped, target_bounding_box);
}
if (target_tracked)
{
std::cout << "Tracking" << std::endl;
cv::rectangle(image_cv_wrapped, target_bounding_box, cv::Scalar(255, 0, 0));
tracking = true;
}
else
{
std::cout << "Not Tracking" << std::endl;
initialized_tracker = false;
tracking = false;
}
}
}
25-30 FPS in v4.5.0 and 1 FPS in 4.10.0 with the exact same code, camera/image size and format?
The things I would be looking for:
Was the 4.10.0 version built the same as 4.5.0? The obvious thing to look for is debug vs release build - OpenCV in debug mode can be very significantly slower - 1fps vs 30fps isn’t out of the question.
Is there anything that has changed with your camera / image source? The obvious thing is image size - but a factor of 30 slowdown is hard to imagine. Any chance your image source is providing images at a slower rate? 1 FPS frame rate would do it.
Are you running it on the same data? I don’t know how the tracker works, but I could imagine that runtime performance could vary significantly with the bounding box size, for example.
Have you tried switching back to 4.5.0 to confirm the performance? Is there a specific reason you want to use 4.10.0?
Hi @Steve_in_Denver sorry for the late reply, I promise I read your response I’ve just been quite down about this particular issue.
I believe I’m using the release build of opencv, but that is worth double checking. Let me share the scripts I used to install them so you can see exactly how they were built. One thing I did have to change in the 4.10.0 install script was to build tracking explicitly. And in the script to install 4.5.0 I didn’t actually see the tracking module specifically called out in the cmake options, but yet it was available. That’s the main difference I can think of. Also 4.5.0 uses the redct2d object and 4.10.0 uses the rect object. Here are the scripts I used to build each version
My camera is pretty fast lol, I’m sure that’s fine. I’m getting 20-25 fps with object detection using SSD Mobilenet.
The data is similar, it’s just me in my house when I turn on the camera.
The reason I switched to opencv 4.10.0 is because I have cuda 12.6 on my laptop and I wanted to have as much similarities between my build platforms as possible. I did try switching back to 4.5.0 per your suggestion, but had the same results. But since it’s been awhile now I’m open to trying that again, just to triple check. At this point anything is worth a shot. I’ll do that, try again on 4.5.0