更新最新直接用point_diff_main
This commit is contained in:
@ -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):
|
def calculate_offset_from_image(orig, visualize=False):
|
||||||
orig = cv2.imread(image_path)
|
|
||||||
if orig is None:
|
if orig is None:
|
||||||
return {'success': False, 'message': f'Failed to load image: {image_path}'}
|
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__":
|
if __name__ == "__main__":
|
||||||
image_path = "11.jpg"
|
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']:
|
if result['success']:
|
||||||
print(f"Center point: ({result['cx']:.1f}, {result['cy']:.1f})")
|
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")
|
print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")
|
||||||
|
|||||||
Reference in New Issue
Block a user