Search code examples
pythoncomputer-visionyolo

How to convert YOLO format annotations to x1, y1, x2, y2 coordinates in Python?


I would like to know how to convert annotations in YOLO format (e.g., center_X, center_y, width, height = 0.069824, 0.123535, 0.104492, 0.120117) to x1, y1, x2, y2 coordinates?


Solution

  • If I recall correctly:

    x1 = (center_X-width/2)*image_width
    x2 = (center_X+width/2)*image_width
    y1 = (center_y-height/2)*image_height
    y2 = (center_y+height/2)*image_height