0

How can i Converting Screen space Coordinates to DarkNet Yolo format?

Image Dimensions:

width: 1024
height: 768

Box Dimensions:

x: 51.84
y: 175.359741
width: 988.16
height: 639.999756

Normalization i understand with the division of point to image, as x = x/width but to convert the x,y,width,height coordination to darknet format.

if anyone can point me in a c# direction

btw what is the darknet format called?, since the original is screen-space. that would make googling a lot easier.

1 Answers1

2

This might be helpful. The YOLO format is:

<object-class> <x_center> <y_center> <width> <height>

where all the <x_center> , <y_center> , <width> , <height> are float values relative to width and height of image, it can be equal from 0.0 to 1.0.

  • width = width of object / width of image
  • height = height of object / height of image
  • x_center and y_center are the center coordinates of each object

For example, to calculate the center:

  • x_center = (x_min + (x_max - x_min)/2) / image_width
  • y_center = (y_min + (y_max - y_min)/2) / image_width

In your example:

width = 988.16 / 1024
height = 639.999756 / 768
x_center = (51.84 + 988.16) / (2 * 1024)
y_center = (175.359741 + 639.999756) / (2 * 768)

I am not sure how your text files look like. It would help if you could post a sample of your text files to read and convert. I also don't know what the Darknet format is called.

Hadi GhahremanNezhad
  • 2,377
  • 5
  • 29
  • 58