feat(新功能):

fix(修复bug):  dev 代码同步
docs(文档变更):
refactor(重构):
test(增加测试):

代码回溯
This commit is contained in:
zhouchengrong
2025-02-13 15:49:01 +08:00
parent 516bbf40e4
commit e42393c076
2 changed files with 32 additions and 9 deletions

View File

@@ -17,6 +17,22 @@ class PrintPainting:
element_print = result['print']['element']
result['single_image'] = None
result['print_image'] = None
# TODO 给result['pattern_image'] resize 到resize_scale的大小
# TODO 给result['mask'] resize 到resize_scale的大小
if result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0:
pass
else:
height, width = result['pattern_image'].shape[:2]
new_width = int(width * result['resize_scale'][0])
new_height = int(height * result['resize_scale'][1])
result['pattern_image'] = cv2.resize(result['pattern_image'], (new_width, new_height))
result['final_image'] = cv2.resize(result['final_image'], (new_width, new_height))
result['mask'] = cv2.resize(result['mask'], (new_width, new_height))
result['gray'] = cv2.resize(result['gray'], (new_width, new_height))
print(1)
if overall_print['print_path_list']:
painting_dict = {'dim_image_h': result['pattern_image'].shape[0], 'dim_image_w': result['pattern_image'].shape[1]}
result['print_image'] = result['pattern_image']
@@ -449,11 +465,8 @@ class PrintPainting:
angle: 旋转的角度
crop: 是否需要进行裁剪,布尔向量
"""
if not isinstance(crop, bool):
raise ValueError("The 'crop' parameter must be a boolean.")
crop_image = lambda img, x0, y0, w, h: img[y0:y0 + h, x0:x0 + w]
h, w = img.shape[:2]
w, h = img.shape[:2]
# 旋转角度的周期是360°
angle %= 360
# 计算仿射变换矩阵
@@ -465,7 +478,7 @@ class PrintPainting:
if crop:
# 裁剪角度的等效周期是180°
angle_crop = angle % 180
if angle_crop > 90:
if angle > 90:
angle_crop = 180 - angle_crop
# 转化角度为弧度
theta = angle_crop * np.pi / 180