修正部分英文拼写;修正图片传递;修正页码解析
This commit is contained in:
@@ -172,12 +172,14 @@ def invert_rotate_rectangle(rectangle, center, angle):
|
||||
return [new_top_left[0], new_top_left[1], new_bot_right[0], new_bot_right[1]]
|
||||
|
||||
|
||||
def expand_to_a4_size(image):
|
||||
def expand_to_a4_size(img_path):
|
||||
"""
|
||||
以尽量少的方式将图片扩充到a4大小
|
||||
:param image: 图片NumPy数组
|
||||
:param img_path: 图片路径
|
||||
:return: 扩充后的图片NumPy数组和偏移量
|
||||
"""
|
||||
image = cv2.imread(img_path)
|
||||
img_name, img_ext = parse_save_path(img_path)
|
||||
height, width = image.shape[:2]
|
||||
x_offset, y_offset = 0, 0
|
||||
hw_ratio = height / width
|
||||
@@ -205,7 +207,10 @@ def expand_to_a4_size(image):
|
||||
exp_img = numpy.zeros((y_offset, width, 3), dtype='uint8')
|
||||
exp_img.fill(255)
|
||||
image = numpy.vstack([exp_img, image, exp_img])
|
||||
return image, x_offset, y_offset
|
||||
# todo:未拓展时不要生成新的图片
|
||||
save_path = get_save_path(f'{img_name}.a4.{img_ext}')
|
||||
cv2.imwrite(save_path, image)
|
||||
return save_path, x_offset, y_offset
|
||||
|
||||
|
||||
def combined(img1, img2):
|
||||
|
||||
Reference in New Issue
Block a user