/
Nemo_499
/
DecodingX-rayImages
Обзор
Документация
Войти
/
Nemo_499
/
DecodingX-rayImages
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CheckingFramework.py
39 строк
1 KB
Вдовин Денис
Много чего
08 апр 2026, 16:28
08 апр 2026, 16:28
30a9cd7
Код
Авторство
О чём код?
import cv2 import os import matplotlib.pyplot as plt def polygon_to_bbox(coords): xs = coords[0::2] ys = coords[1::2] return min(xs), min(ys), max(xs), max(ys) image = cv2.imread('D:/The Welding Defect Dataset - v2/train/images/0e538f39-1d30436c-c23_jpg.rf.3ce38b0e86b3cd83db06acc794de04f0.jpg.', cv2.IMREAD_COLOR) with open("D:/The Welding Defect Dataset - v2/train/labels/0e538f39-1d30436c-c23_jpg.rf.3ce38b0e86b3cd83db06acc794de04f0.txt", "r") as f: for line in f: parts = list(map(float, line.split())) coords = parts[1:] x_min, y_min, x_max, y_max = coords[0], coords[1], coords[2], coords[3] print(x_min, y_min, x_max, y_max) h,w = image.shape[:2] x1_c = int(x_min * h) x2_w = int(x_max * h) y1_c = int(y_min * w) y2_h = int(y_max * w) print(x1_c, y1_c, x2_w, y2_h) x1 = x1_c - x2_w // 2 x2 = x1_c + x2_w // 2 y1 = y1_c - y2_h // 2 y2 = y1_c + y2_h // 2 cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), thickness = 5, lineType = cv2.LINE_8) plt.imshow(image) plt.show()