blakeblackshear пре 6 година
родитељ
комит
7e3d2f6611
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      detect_objects.py

+ 5 - 0
detect_objects.py

@@ -193,6 +193,9 @@ def process_frames(shared_arr, shared_output_arr, shared_frame_time, frame_shape
             if no_frames_available > 0 and (datetime.datetime.now().timestamp() - no_frames_available) > 30:
                 time.sleep(1)
                 print("sleeping because no frames have been available in a while")
+            else:
+                # rest a little bit to avoid maxing out the CPU
+                time.sleep(0.01)
             continue
         
         # we got a valid frame, so reset the timer
@@ -202,6 +205,8 @@ def process_frames(shared_arr, shared_output_arr, shared_frame_time, frame_shape
         if (datetime.datetime.now().timestamp() - shared_frame_time.value) > 0.5:
             # signal that we need a new frame
             shared_frame_time.value = 0.0
+            # rest a little bit to avoid maxing out the CPU
+            time.sleep(0.01)
             continue
         
         # make a copy of the frame