← Back to list

การแปลง bbox แบบ xmin,ymin, xmax, ymax to YOLO bbox

x1,y1,x2,y2, = item[0], item[1],item[2], item[3] width = #pict width height = #pict height

Jettnipith Thantong · 2022-09-04 15:42 · 0 claps · 0.7 min read
#bbox #yolo
Open on Medium ↗

การแปลง bbox แบบ xmin,ymin, xmax, ymax to YOLO bbox

x1,y1,x2,y2, = item[0], item[1],item[2], item[3] width = #pict width height = #pict height

x_min = x1/width y_min = y1/height

x_max = x2/width y_max = y2/height

x_mid = (x_max+x_min)/2 #this is data at index 0 for YOLO y_mid = (y_max+y_min)/2 #this is data at index 1 for YOLO w = (x_max-x_min) #this is data at index 2 for YOLO h = (y_max-y_min) #this is data at index 3 for YOLO

area = w*h

Use Case1 : การเอา Label เข้าไปใช้ร่วมกับ CiRA Core

โจทย์กำหนดให้ x1= 100 y1 = 200 x2= 300 y2 = 400 width = 880 height = 660

ต้องหา x_min, y_min, w, h เพื่อเอาไปใส่ใน .gt ของ CiRA Core

จาก x_min = x1/width y_min = y1/height x_max = x2/width y_max = y2/height จะได้ x_min = 100 y_min = 200 x_max = 300 y_max = 400 เพราะไฟล์ .gt ของ CiRA Core รับค่าแบบ pixel

จาก x_mid = (x_max+x_min)/2 จะได้ x_mid = (300+100)/2 = 200

y_mid = (y_max+y_min)/2 จะได้ y_mid = (200+200)/2 = 200

w = (x_max-x_min) จะได้ w = (300–100) = 200

h = (y_max-y_min) จะได้ h = (400–200) = 200

ตอบ: 100,200,200,200


메타데이터
post_id
b0be2fef8d93
slug
การแปลง-bbox-แบบ-xmin-ymin-xmax-ymax-to-yolo-bbox-b0be2fef8d93
url
https://medium.com/@jettnipiththantong/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%9B%E0%B8%A5%E0%B8%87-bbox-%E0%B9%81%E0%B8%9A%E0%B8%9A-xmin-ymin-xmax-ymax-to-yolo-bbox-b0be2fef8d93
canonical_url
https://medium.com/@jettnipiththantong/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%9B%E0%B8%A5%E0%B8%87-bbox-%E0%B9%81%E0%B8%9A%E0%B8%9A-xmin-ymin-xmax-ymax-to-yolo-bbox-b0be2fef8d93
author_url
https://medium.com/@jettnipiththantong
status
ok
fetched_at
2026-07-26 17:05:25