feat(新功能):

fix(修复bug): 关键点模型预处理后处理增加白边框
docs(文档变更):
refactor(重构):
test(增加测试):
This commit is contained in:
zhouchengrong
2025-01-20 11:26:42 +08:00
parent 001ae5b10b
commit f21b7203bb

View File

@@ -25,6 +25,7 @@ from app.core.config import *
def keypoint_preprocess(img_path):
img = mmcv.imread(img_path)
img = cv2.copyMakeBorder(img, 25, 25, 25, 25, cv2.BORDER_CONSTANT, value=[255, 255, 255])
img_scale = (256, 256)
h, w = img.shape[:2]
img = cv2.resize(img, img_scale)
@@ -62,7 +63,11 @@ def keypoint_postprocess(output, scale_factor):
scale_matrix = np.diag(scale_factor)
nan = np.isinf(scale_matrix)
scale_matrix[nan] = 0
return np.ceil(np.dot(segment_result, scale_matrix) * 4)
# 应用缩放因子
scaled_result = np.ceil(np.dot(segment_result, scale_matrix) * 4)
# 补偿边框偏移
compensated_result = scaled_result - 25
return compensated_result
"""