This commit is contained in:
@ -332,9 +332,10 @@ async def generate_dice_image(number: str) -> BytesIO:
|
|||||||
up_direction = (51 - 16, 5 - 30) # 右上角点 - 左上角点
|
up_direction = (51 - 16, 5 - 30) # 右上角点 - 左上角点
|
||||||
|
|
||||||
move_distance = (up_direction[0] * (stretch_k - 1), up_direction[1] * (stretch_k - 1))
|
move_distance = (up_direction[0] * (stretch_k - 1), up_direction[1] * (stretch_k - 1))
|
||||||
|
|
||||||
# 加载背景图像,保留透明通道
|
# 加载背景图像,保留透明通道
|
||||||
background = cv2.imread(ASSETS_PATH / "img" / "dice" / "template.png", cv2.IMREAD_UNCHANGED)
|
background = cv2.imread(str(ASSETS_PATH / "img" / "dice" / "template.png"), cv2.IMREAD_UNCHANGED)
|
||||||
|
assert background is not None
|
||||||
|
|
||||||
height, width = background.shape[:2]
|
height, width = background.shape[:2]
|
||||||
|
|
||||||
@ -352,7 +353,7 @@ async def generate_dice_image(number: str) -> BytesIO:
|
|||||||
], dtype=np.float32)
|
], dtype=np.float32)
|
||||||
corners[:, 0] += offset_x
|
corners[:, 0] += offset_x
|
||||||
corners[:, 1] += offset_y
|
corners[:, 1] += offset_y
|
||||||
|
|
||||||
|
|
||||||
# 对文本图像进行3D变换(保持透明通道)
|
# 对文本图像进行3D变换(保持透明通道)
|
||||||
transformed_text, transform_matrix = perspective_transform(text_image, background, corners)
|
transformed_text, transform_matrix = perspective_transform(text_image, background, corners)
|
||||||
|
|||||||
Reference in New Issue
Block a user