Yolo_mark icon indicating copy to clipboard operation
Yolo_mark copied to clipboard

annotatiom file conversion.

Open BlcaKHat opened this issue 5 years ago • 2 comments

@AlexeyAB I have openImage annotation for images.

The for mat of annotation file is : (class_name X_end Y_end X_start Y_start).

where is X_start & Y_start is starting of rectangle box and X_end, Y_end is end co-ordinate of rectangle.

can you explain your logic so I can conver them to yolo format

BlcaKHat avatar Sep 28 '18 06:09 BlcaKHat

Yolo format is: <object-class> <x> <y> <width> <height> So:

<x_center> = ((X_end + X_start) / 2) / image_width

<y_center> = ((Y_end + Y_start) / 2) / image_height

<width> = (X_end - X_start) / image_width

<height> = (Y_end - Y_start) / image_height

https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

You should label each object on images from your dataset. Use this visual GUI-software for marking bounded boxes of objects and generating annotation files for Yolo v2 & v3: https://github.com/AlexeyAB/Yolo_mark

It will create .txt-file for each .jpg-image-file - in the same directory and with the same name, but with .txt-extension, and put to file: object number and object coordinates on this image, for each object in new line:

Where:

- integer object number from 0 to (classes-1) <x_center> <y_center> - float values relative to width and height of image, it can be equal from (0.0 to 1.0] for example: = <absolute_x> / <image_width> or = <absolute_height> / <image_height> atention: <x_center> <y_center> - are center of rectangle (are not top-left corner) For example for img1.jpg you will be created img1.txt containing:

1 0.716797 0.395833 0.216406 0.147222
0 0.687109 0.379167 0.255469 0.158333
1 0.420312 0.395833 0.140625 0.166667

AlexeyAB avatar Sep 28 '18 10:09 AlexeyAB

Hi @AlexeyAB I was just wondering how can I convert the

1 0.716797 0.395833 0.216406 0.147222 0 0.687109 0.379167 0.255469 0.158333 1 0.420312 0.395833 0.140625 0.166667

to a format like

0 240 240 100 150

where the image is 480x480, the box from the yolo mark has center at (240, 240) and has width of 100 and height of 150?

Thank you!

kenrubiooo avatar Nov 23 '18 04:11 kenrubiooo