The Problem is you perform object detection in the "frame read loop". Decouple "frame reading" and detection, use a Queue to push frames from the read thread, and pull it from the detection thread. See my comment