Created
September 11, 2020 04:20
-
-
Save pranjalAI/1361d46f16387207af52c62d060227fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert from opencv format to yolo format | |
# H,W is the image height and width | |
def cvFormattoYolo(corner, H, W): | |
bbox_W = corner[3] - corner[1] | |
bbox_H = corner[4] - corner[2] | |
center_bbox_x = (corner[1] + corner[3]) / 2 | |
center_bbox_y = (corner[2] + corner[4]) / 2 | |
return corner[0], round(center_bbox_x / W, 6), | |
round(center_bbox_y / H, 6), | |
round(bbox_W / W, 6), | |
round(bbox_H / H, 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment