@@ -138,6 +138,7 @@ def __reset_print_positions(self):
138138 self .text_y_pos = {
139139 'left' : self .params .text_start_y ,
140140 'center' : self .params .text_start_y ,
141+ 'column2' : self .params .text_start_y ,
141142 'right' : self .params .text_start_y
142143 }
143144
@@ -293,7 +294,7 @@ def print_text(self, txt, color: tuple = (0,0,255), text_position_x: str = 'left
293294 Args:
294295 txt (str, list): the text to plot on the image
295296 colot (tuple): BGR Color tuple
296- text_position_x (str): text position ['left', 'right', 'center']
297+ text_position_x (str): text position ['left', 'right', 'center', 'column2' ]
297298 """
298299 assert self .preview_image is not None
299300 assert text_position_x in self .text_y_pos .keys ()
@@ -308,6 +309,9 @@ def print_text(self, txt, color: tuple = (0,0,255), text_position_x: str = 'left
308309 (text_w , _ ), _ = cv2 .getTextSize (line , cv2 .FONT_HERSHEY_SIMPLEX , self .params .font_size , 2 )
309310 x = max ([0 , int (self .preview_image .shape [1 ] - self .params .text_start_x - text_w ) ])
310311 elif text_position_x .lower () == 'center' :
312+ (text_w , _ ), _ = cv2 .getTextSize (line , cv2 .FONT_HERSHEY_SIMPLEX , self .params .font_size , 2 )
313+ x = max ([0 , round ((self .preview_image_origin_width / 2 ) - (text_w / 2 ))])
314+ elif text_position_x .lower () == 'column2' :
311315 x = round (self .preview_image_origin_width / 2 + self .params .text_start_x )
312316 else :
313317 raise NotImplementedError ("Print Text at position %s is not implemented" , text_position_x )
@@ -447,10 +451,10 @@ def min_max_selector(self,
447451 try :
448452 self .set_background_image (image , copy_image = True )
449453 self .print_text (title_min if title_min != "" else "Min" )
450- self .print_text (title_max if title_max != "" else "Max" , text_position_x = 'center ' )
454+ self .print_text (title_max if title_max != "" else "Max" , text_position_x = 'column2 ' )
451455 self .print_text (info )
452456 self .print_text ("Set {} to {}" .format ('Min' , trackbarValueMin ))
453- self .print_text ("Set {} to {}" .format ('Max' , trackbarValueMax ), text_position_x = 'center ' )
457+ self .print_text ("Set {} to {}" .format ('Max' , trackbarValueMax ), text_position_x = 'column2 ' )
454458 ret = self .show (25 )
455459
456460 if self .was_space_pressed () or ret == ord (' ' ):
0 commit comments