From d5457e02cabfcd306b094401425fe0e4d5715d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=90=89=E7=92=83=E6=9C=88=E5=85=89?= <15630071+llyg777@user.noreply.gitee.com> Date: Thu, 8 Jan 2026 17:38:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=80=E6=96=B0=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E7=94=A8point=5Fdiff=5Fmain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- point_diff_main/calculate_diff3.0.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/point_diff_main/calculate_diff3.0.py b/point_diff_main/calculate_diff3.0.py index e060251..4176b34 100644 --- a/point_diff_main/calculate_diff3.0.py +++ b/point_diff_main/calculate_diff3.0.py @@ -173,8 +173,8 @@ def visualize_result(image, keypoints, bbox, fixed_point, offset_info, save_path # ====================== 主函数 ====================== -def calculate_offset_from_image(image_path, visualize=False): - orig = cv2.imread(image_path) +def calculate_offset_from_image(orig, visualize=False): + if orig is None: return {'success': False, 'message': f'Failed to load image: {image_path}'} @@ -213,7 +213,8 @@ def calculate_offset_from_image(image_path, visualize=False): # ====================== 示例调用 ====================== if __name__ == "__main__": image_path = "11.jpg" - result = calculate_offset_from_image(image_path, visualize=False) + orig = cv2.imread(image_path) + result = calculate_offset_from_image(orig, visualize=False) if result['success']: print(f"Center point: ({result['cx']:.1f}, {result['cy']:.1f})") print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")