How can I run the object detection model in the background

I have a project developed with OpenCV C++ where I process images taken from the camera. Normally my project runs smoothly at 30fps. Now I am trying to add an object detection algorithm working with yolov5s lbtorch to develop the project. But the hardware I’m using can run the object detection model at around 10fps. But 1 fps is enough for my project.

My problem is when I add object detection model to my project it works as 8-9 fps. Can I run object detection in the background at 1fps and run normal operations at 30fps? I tried to briefly explain what I want to do in the picture below. How can I do that?

I have a similar question. Can you help me. I want to run trained yolov5s -“best.pt” weight file in a normal CPU computer

I did it by creating a thread. As the thread completes the process, it continues to work by taking a new frame. I process by using intermediate outputs in the main thread.