I've been trying to write the correct annotations for YOLOv4. I am told that the annotations need to be calculated relative to the canvas image. But there is an issue where the bounding box is misplaced.
This is my function that calculates the annotations for each logo on a canvas image:
def get_annotation_coordinates(canvas_shape, logo_shape):
x = (logo_width + canvas_width) / 2
y = (logo_height + canvas_height) / 2
width = logo_width / canvas_width
height = logo_height / canvas_height
return f"{x / canvas_width} {y / canvas_height} {width} {height}"
What exactly am I doing wrong? Because obviously my calculations are wrong.