Skip to content

Commit

Permalink
fix bug: show title
Browse files Browse the repository at this point in the history
  • Loading branch information
nachifur committed Aug 22, 2021
1 parent 31972d0 commit e29998c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def img_left_release(self, event):
show_scale = [float(x) for x in show_scale]
points = self.ImgManager.ImgF.sort_box_point(
[x_0, y_0, x, y], show_scale, self.ImgManager.img_resolution_origin, first_point=True)
self.xy_magnifier.append(points+show_scale)
self.xy_magnifier.append(points+show_scale+[self.title_down_up.Value])
self.refresh(event)

def img_right_click(self, event):
Expand All @@ -535,7 +535,7 @@ def img_right_click(self, event):
show_scale = self.show_scale.GetLineText(0).split(',')
show_scale = [float(x) for x in show_scale]
points = self.move_box_point(x, y, show_scale)
self.xy_magnifier.append(points+show_scale)
self.xy_magnifier.append(points+show_scale+[self.title_down_up.Value])
except:
self.SetStatusText_(
["-1", "Drawing a box need click left mouse button!", "-1", "-1"])
Expand Down
18 changes: 12 additions & 6 deletions utils_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def draw_rectangle(self, img, xy_grids, bounding_boxs, color_list, line_width=2,
i = 0
k = 0
for bounding_box in bounding_boxs:
x_0, y_0, x, y = bounding_box
x_0, y_0, x, y = bounding_box[0:4]
height = y-y_0
width = x - x_0
color = color_list[k]
Expand Down Expand Up @@ -761,7 +761,7 @@ def stitch_img_init(self, img_mode, draw_points):
self.magnifier_flag = 0
if self.magnifier_flag:
layout_level_2.append(1)
self.crop_points_process(draw_points)
self.crop_points_process(copy.deepcopy(draw_points))
# get magnifier size
crop_width = self.crop_points[0][2]-self.crop_points[0][0]
crop_height = self.crop_points[0][3]-self.crop_points[0][1]
Expand Down Expand Up @@ -795,7 +795,7 @@ def stitch_img_init(self, img_mode, draw_points):

# Since the title is up, we need to correct crop_points
if self.magnifier_flag:
self.crop_points_process(draw_points,title_up = self.title_setting[2])
self.crop_points_process(copy.deepcopy(draw_points),title_up = self.title_setting[2])

# Two-dimensional arrangement
# arrangement of sub-images, title image, original image, magnifier image
Expand Down Expand Up @@ -998,14 +998,20 @@ def crop_points_process(self, crop_points,title_up=False, img_mode=0):
crop_point[2] = int(crop_point[2]*scale[0])
crop_point[3] = int(crop_point[3]*scale[1])

if title_up:
if title_up and (not crop_point_scale[6]):
if self.vertical:
crop_point[0] = crop_point[0]+self.title_max_size[0]+self.layout_params[3][3]
crop_point[2] = crop_point[2]+self.title_max_size[0]+self.layout_params[3][3]
else:
crop_point[1] = crop_point[1]+self.title_max_size[1]+self.layout_params[3][3]
crop_point[3] = crop_point[3]+self.title_max_size[1]+self.layout_params[3][3]

if (not title_up) and crop_point_scale[6]:
if self.vertical:
crop_point[0] = crop_point[0]-self.title_max_size[0]-self.layout_params[3][3]
crop_point[2] = crop_point[2]-self.title_max_size[0]-self.layout_params[3][3]
else:
crop_point[1] = crop_point[1]-self.title_max_size[1]-self.layout_params[3][3]
crop_point[3] = crop_point[3]-self.title_max_size[1]-self.layout_params[3][3]
crop_points_.append(crop_point)

self.crop_points = crop_points_
Expand All @@ -1024,7 +1030,7 @@ def magnifier_preprocessing(self, img, img_mode=0, id=0):
else:
crop_point[1] = crop_point[1]-self.title_max_size[1]-self.layout_params[3][3]
crop_point[3] = crop_point[3]-self.title_max_size[1]-self.layout_params[3][3]
img_list.append(img.crop(tuple(crop_point)))
img_list.append(img.crop(tuple(crop_point[0:4])))

gap = self.layout_params[3][4]

Expand Down

0 comments on commit e29998c

Please sign in to comment.