Wenbin Xu
Wenbin Xu

Reputation: 134

cv2 show video stream & add overlay after another function finishes

I am current working on a real time face detection project.

What I have done is that I capture the frame using cv2, do detection and then show result using cv2.imshow(), which result in a low fps.

I want a high fps video showing on the screen without lag and a low fps detection bounding box overlay.

Is there a solution to show the real time video stream (with the last detection result bounding box), and once a new detection is finished, show the new bounding box and the background was not delayed by the detection function.

Any help is appreciated!

Thanks!

Upvotes: 0

Views: 712

Answers (1)

Rupaksh Paul
Rupaksh Paul

Reputation: 112

A common approach would be to create a flag that allows the detection algorithim to only run once every couple of frames and save the predicted reigons of interest to a list, whilst creating bounding boxes for every frame.

So for example you have a face detection algorithim, process every 15th frame to detect faces, but in every frame create a bounding box from the predictions. Even though the predictions get updated every 15 frames.

Another approach could be to add an object tracking layer. Run your heavy algorithim to find the ROIs and then use the object tracking library to hold on to them till the next time it runs the detection algorithim.

Hope this made sense.

Upvotes: 0

Related Questions