Преглед на файлове

get a lock when copying frame for mjpeg stream

blakeblackshear преди 6 години
родител
ревизия
8525f05f29
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      detect_objects.py

+ 3 - 1
detect_objects.py

@@ -266,8 +266,10 @@ def main():
             time.sleep(0.2)
             # make a copy of the current detected objects
             detected_objects = DETECTED_OBJECTS.copy()
-            # make a copy of the current frame
+            # lock and make a copy of the current frame
+            frame_lock.aquire()
             frame = frame_arr.copy()
+            frame_lock.release()
             # convert to RGB for drawing
             frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
             # draw the bounding boxes on the screen