@@ -296,8 +296,7 @@ def min_max_selector(self,
296296 cv2 .putText (image , "Use 'space' to quit and set the trackbar values" ,
297297 (self .x_text_start , 100 ), cv2 .FONT_HERSHEY_SIMPLEX , self .font_size , (255 ,0 ,0 ), 2 )
298298
299- # beep_thread = threading.Thread(target=self.beep)
300- # beep_thread.start()
299+ self .beep ()
301300 self .clear_keypress_queue ()
302301 trackbarValueMin = lower_limit
303302 trackbarValueMax = upper_limit
@@ -320,13 +319,17 @@ def min_max_selector(self,
320319
321320 def beep (self ) -> None :
322321 """ Play an sound to signal an event """
323- if False :
324- # we have problems on windows with this
325- if NOTIFICATION_SOUND_FILE is not None :
326- if os .path .exists (NOTIFICATION_SOUND_FILE ):
327- playsound (NOTIFICATION_SOUND_FILE )
328- else :
329- self .logger .warning ("Notification sound file not found (%s)" , NOTIFICATION_SOUND_FILE )
322+ if NOTIFICATION_SOUND_FILE is not None :
323+ if os .path .exists (NOTIFICATION_SOUND_FILE ):
324+ def play_beep ():
325+ try : playsound (NOTIFICATION_SOUND_FILE )
326+ except : pass
327+ try :
328+ self .beep_thread = threading .Thread (target = play_beep )
329+ self .beep_thread .start ()
330+ except : pass
331+ else :
332+ self .logger .warning ("Notification sound file not found (%s)" , NOTIFICATION_SOUND_FILE )
330333
331334
332335 def calculate_score (self , bboxes ) -> None :
@@ -860,8 +863,7 @@ def tracking(self) -> str:
860863
861864 scene_change_quit_flag = False
862865 if scene_detector .is_scene_change (frame_num - 1 + self .params .start_frame ):
863- # beep_thread = threading.Thread(target=self.beep)
864- # beep_thread.start()
866+ self .beep ()
865867 cv2 .putText (last_frame , "Scene change detected, Press 'space' to continue tracking or press 'q' to finalize tracking" ,
866868 (self .x_text_start , 75 ), cv2 .FONT_HERSHEY_SIMPLEX , self .font_size , (255 ,0 ,0 ), 2 )
867869 cv2 .imshow (self .window_name , self .preview_scaling (last_frame ))
0 commit comments