@@ -116,6 +116,24 @@ def print_help():
116116 info ('\n \n ' )
117117
118118
119+ def draw_fps (frame , fps , timing , x0 = 10 , y0 = 20 , ystep = 30 , fontsz = 0.5 , color = (255 , 255 , 255 )):
120+ frame = frame .copy ()
121+ cv2 .putText (frame , f"FPS: { fps :.1f} " , (x0 , y0 + ystep * 0 ), 0 , fontsz * IMG_SIZE / 256 , color , 1 )
122+ cv2 .putText (frame , f"Model time (ms): { timing ['predict' ]:.1f} " , (x0 , y0 + ystep * 1 ), 0 , fontsz * IMG_SIZE / 256 , color , 1 )
123+ cv2 .putText (frame , f"Preproc time (ms): { timing ['preproc' ]:.1f} " , (x0 , y0 + ystep * 2 ), 0 , fontsz * IMG_SIZE / 256 , color , 1 )
124+ cv2 .putText (frame , f"Postproc time (ms): { timing ['postproc' ]:.1f} " , (x0 , y0 + ystep * 3 ), 0 , fontsz * IMG_SIZE / 256 , color , 1 )
125+ return frame
126+
127+
128+ def draw_calib_text (frame , thk = 2 , fontsz = 0.5 , color = (0 , 0 , 255 )):
129+ frame = frame .copy ()
130+ cv2 .putText (frame , "FIT FACE IN RECTANGLE" , (40 , 20 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
131+ cv2 .putText (frame , "W - ZOOM IN" , (60 , 40 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
132+ cv2 .putText (frame , "S - ZOOM OUT" , (60 , 60 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
133+ cv2 .putText (frame , "THEN PRESS X" , (60 , 245 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
134+ return frame
135+
136+
119137def select_camera (config ):
120138 cam_config = config ['cam_config' ]
121139 cam_id = None
@@ -128,7 +146,7 @@ def select_camera(config):
128146 cam_frames = cam_selector .query_cameras (config ['query_n_cams' ])
129147
130148 if cam_frames :
131- cam_id = cam_selector .select_camera (cam_frames )
149+ cam_id = cam_selector .select_camera (cam_frames , window = "CLICK ON YOUR CAMERA" )
132150 log (f"Selected camera { cam_id } " )
133151
134152 with open (cam_config , 'w' ) as f :
@@ -393,17 +411,10 @@ def select_camera(config):
393411 preview_frame = cv2 .putText (preview_frame , display_string , (10 , 220 ), 0 , 0.5 * IMG_SIZE / 256 , (255 , 255 , 255 ), 1 )
394412
395413 if show_fps :
396- timing_string = f"FPS/Model/Pre/Post: { fps :.1f} / { timing ['predict' ]:.1f} / { timing ['preproc' ]:.1f} / { timing ['postproc' ]:.1f} "
397- preview_frame = cv2 .putText (preview_frame , timing_string , (10 , 240 ), 0 , 0.3 * IMG_SIZE / 256 , (255 , 255 , 255 ), 1 )
414+ preview_frame = draw_fps (preview_frame , fps , timing )
398415
399416 if not is_calibrated :
400- color = (0 , 0 , 255 )
401- thk = 2
402- fontsz = 0.5
403- preview_frame = cv2 .putText (preview_frame , "FIT FACE IN RECTANGLE" , (40 , 20 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
404- preview_frame = cv2 .putText (preview_frame , "W - ZOOM IN" , (60 , 40 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
405- preview_frame = cv2 .putText (preview_frame , "S - ZOOM OUT" , (60 , 60 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
406- preview_frame = cv2 .putText (preview_frame , "THEN PRESS X" , (60 , 245 ), 0 , fontsz * IMG_SIZE / 255 , color , thk )
417+ preview_frame = draw_calib_text (preview_frame )
407418
408419 if not opt .hide_rect :
409420 draw_rect (preview_frame )
0 commit comments