@@ -471,8 +471,9 @@ def img_left_release(self, event):
471471
472472 show_scale = self .show_scale .GetLineText (0 ).split (',' )
473473 show_scale = [float (x ) for x in show_scale ]
474- self .xy_magnifier .append (
475- self .ImgManager .sort_box_point ([x , y , x_0 , y_0 ])+ show_scale )
474+ points = self .ImgManager .sort_box_point (
475+ [x_0 , y_0 , x , y ], show_scale , first_point = True )
476+ self .xy_magnifier .append (points + show_scale )
476477 self .refresh (event )
477478
478479 def img_right_click (self , event ):
@@ -488,9 +489,7 @@ def img_right_click(self, event):
488489 show_scale = self .show_scale .GetLineText (0 ).split (',' )
489490 show_scale = [float (x ) for x in show_scale ]
490491 points = self .move_box_point (x , y , show_scale )
491- points_show_scale = self .ImgManager .sort_box_point (
492- points )+ show_scale
493- self .xy_magnifier .append (points_show_scale )
492+ self .xy_magnifier .append (points + show_scale )
494493 except :
495494 self .SetStatusText_ (
496495 ["-1" , "Drawing a box need click left mouse button!" , "-1" , "-1" ])
@@ -500,39 +499,16 @@ def move_box_point(self, x, y, show_scale):
500499 x_0 , y_0 , x_1 , y_1 = self .xy_magnifier [0 ][0 :4 ]
501500 show_scale_old = self .xy_magnifier [0 ][4 :6 ]
502501 scale = [show_scale [0 ]/ show_scale_old [0 ],
503- show_scale [1 ]/ show_scale_old [1 ]]
502+ show_scale [1 ]/ show_scale_old [1 ]]
504503 x_0 = int (x_0 * scale [0 ])
505504 x_1 = int (x_1 * scale [0 ])
506505 y_0 = int (y_0 * scale [1 ])
507506 y_1 = int (y_1 * scale [1 ])
508- x_center_old , y_center_old , width , height = self .get_center_box (
509- [x_0 , y_0 , x_1 , y_1 ], more = True )
507+ x_center_old , y_center_old = self .get_center_box (
508+ [x_0 , y_0 , x_1 , y_1 ])
510509 delta_x = x - x_center_old
511510 delta_y = y - y_center_old
512-
513- img_resolution = (np .array (self .ImgManager .img_resolution_origin ) * np .array (show_scale )).astype (np .int )
514-
515- if x_1 + delta_x > img_resolution [0 ]:
516- x = img_resolution [0 ]
517- x_0 = img_resolution [0 ]- width
518- elif x_0 + delta_x < 0 :
519- x_0 = 0
520- x = width
521- else :
522- x_0 = x_0 + delta_x
523- x = x_1 + delta_x
524-
525- if y_1 + delta_y > img_resolution [1 ]:
526- y = img_resolution [1 ]
527- y_0 = img_resolution [1 ]- height
528- elif y_0 + delta_y < 0 :
529- y_0 = 0
530- y = height
531- else :
532- y_0 = y_0 + delta_y
533- y = y_1 + delta_y
534-
535- return [x_0 , y_0 , x , y ]
511+ return self .ImgManager .sort_box_point ([x_0 + delta_x , y_0 + delta_y , x_1 + delta_x , y_1 + delta_y ], show_scale )
536512
537513 def get_center_box (self , box , more = False ):
538514 x_0 , y_0 , x_1 , y_1 = box
0 commit comments