I've created a trained yolov4 model, and I tried to test it as well. My original image size was - width 1920 and height 1080.
For training I reduced it to 416*416. When I was tested I got a good result but I cannot understand the output values:
(left_x: 506 top_y: -376 width: 2076 height: 1179)
(how can a coordinate be negative or bigger than the image's size?)
I'm sure that there is a formula behind it but I wasn't be able to find it. I searched inside the code (darknet.py) and bbox2points(bbox) function returned a bad result.
What am I missing?
Can you help me to find the bounding box's coordinate in this example?
Code - darknet.py:
x, y, w, h = bbox
xmin = int(round(x - (w / 2)))
xmax = int(round(x + (w / 2)))
ymin = int(round(y - (h / 2)))
ymax = int(round(y + (h / 2)))
return xmin, xmax, ymin, ymax
those x, y, w, h are the same as it is outputted (left_x, top_y, width, height) Code: https://github.com/AlexeyAB/darknet/blob/master/darknet.py
This is how i transform the bounding boxes returned by the darknet_video.py to use it in opencv.
def __transform_boxes(boxes, image):
image_height, image_width, image_channels = image.shape
top_coordinates_x = int((boxes[0] - (boxes[2]) / 2) * (image_width / 416))
top_coordinates_y = int((boxes[1] - (boxes[3]) / 2) * (image_height / 416))
bottom_coordinates_x = int((boxes[0] + (boxes[2]) / 2) * (image_width / 416))
bottom_coordinates_y = int((boxes[1] + (boxes[3]) / 2) * (image_height / 416))
return bottom_coordinates_x, bottom_coordinates_y, top_coordinates_x, top_coordinates_y
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.