| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import dataclasses
- import cv2
- import numpy as np
- import json
- from app.utils.defect_inference.AnalyzeCenter import analyze_centering_rotated, draw_rotated_bounding_boxes
- if __name__ == "__main__":
- img_path = r"C:\Code\ML\Project\CheckCardBoxAndDefectServer\temp\250805_pokemon_0001.jpg"
- inner_file_path = r"C:\Code\ML\Project\CheckCardBoxAndDefectServer\temp\inner\250805_pokemon_0001.json"
- outer_file_path = r"C:\Code\ML\Project\CheckCardBoxAndDefectServer\temp\outer\250805_pokemon_0001.json"
- # center_result = analyze_centering_rotated(inner_file_path, outer_file_path)
- # draw_rotated_bounding_boxes(img_path, inner_file_path, outer_file_path)
- with open(inner_file_path, "r", encoding="utf-8") as f:
- inner_data = json.load(f)
- with open(outer_file_path, "r", encoding="utf-8") as f:
- outer_data = json.load(f)
- inner_points = inner_data['shapes'][0]['points']
- outer_points = outer_data['shapes'][0]['points']
- center_result = analyze_centering_rotated(inner_points, outer_points)
- data = {
- "img_id": 2,
- "img_url": "",
- "inference_result": {
- "center_inference": {
- "angel_diff": center_result[2],
- "center_left": center_result[0][0],
- "center_right": center_result[0][1],
- "center_top": center_result[1][0],
- "center_bottom": center_result[1][1]
- }
- }
- }
- data['inference_result']['inner_box'] = inner_data
- data['inference_result']['outer_box'] = outer_data
- print(data)
|