@@ -29,6 +29,7 @@ class OpenCV_GUI_Parameters:
2929 fps_smoothing_factor : int = 100
3030 window_name_prefix : str = "MTFG"
3131 notification_sound_file = NOTIFICATION_SOUND_FILE
32+ use_zoom : bool = SETTINGS ["use_zoom" ]
3233 zoom_factor : float = max ((1.0 , float (SETTINGS ['zoom_factor' ])))
3334 text_border_width : int = 6
3435
@@ -469,18 +470,17 @@ def min_max_selector(self,
469470
470471
471472
472- def bbox_selector (self , image : np .ndarray , txt : str , use_zoom = False ) -> tuple :
473+ def bbox_selector (self , image : np .ndarray , txt : str ) -> tuple :
473474 """ Window to get an bounding box from user input
474475
475476 Args:
476477 image (np.ndarray): opencv image e.g. the first frame to determine the bounding box
477478 txt (str): additional text to display on the selection window
478- use_zoom (bool): use zoom window
479479
480480 Returns:
481481 tuple: user input bounding box tuple (x,y,w,h)
482482 """
483- if use_zoom :
483+ if self . params . use_zoom :
484484 self .set_background_image (image , copy_image = True )
485485 self .print_text ("Select area with Mouse and Press 'space' or 'enter' to continue" )
486486 self .print_text ("Zoom selected area" )
@@ -496,6 +496,13 @@ def bbox_selector(self, image: np.ndarray, txt: str, use_zoom = False) -> tuple:
496496
497497 break
498498
499+ zoom_bbox = (
500+ round (zoom_bbox [0 ]/ self .monitor_preview_scaling ),
501+ round (zoom_bbox [1 ]/ self .monitor_preview_scaling ),
502+ round (zoom_bbox [2 ]/ self .monitor_preview_scaling ),
503+ round (zoom_bbox [3 ]/ self .monitor_preview_scaling )
504+ )
505+
499506 image = image [zoom_bbox [1 ]:zoom_bbox [1 ]+ zoom_bbox [3 ], zoom_bbox [0 ]:zoom_bbox [0 ]+ zoom_bbox [2 ]]
500507 image = cv2 .resize (image , None , fx = self .params .zoom_factor , fy = self .params .zoom_factor )
501508
@@ -523,7 +530,7 @@ def bbox_selector(self, image: np.ndarray, txt: str, use_zoom = False) -> tuple:
523530 )
524531
525532 # revert the zoom
526- if use_zoom :
533+ if self . params . use_zoom :
527534 bbox = (
528535 round (bbox [0 ]/ self .params .zoom_factor + zoom_bbox [0 ]),
529536 round (bbox [1 ]/ self .params .zoom_factor + zoom_bbox [1 ]),
0 commit comments