Open fatbringer opened 1 year ago
The only thing that you need is the class ID and the boxes, so you could edit the annotations files and keep only the important information, and then manually draw the boxes per image with the opencv. You could try something like this,(adjust it to your problem). The key lines are the cv2.rectangle and cv2.putText.
for i in range(detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > 0.5:
class_id = int(detections[0, 0, i, 1])
class_name = classes[class_id]
box = detections[0, 0, i, 3:7] * np.array([image.shape[1], image.shape[0], image.shape[1], image.shape[0]])
(startX, startY, endX, endY) = box.astype('int')
cv2.rectangle(image, (startX, startY), (endX, endY), (0, 255, 0), 2)
label = '{}: {:.2f}%'.format(class_name, confidence * 100)
cv2.putText(image, label, (startX, startY - 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
cv2.imshow('Object Detection', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
@KyriakosChris hey! Thanks for the code. I forgot to close the issue as i solved it awhile back using cv2 methods too. Your implementation is neater :)
I notice that the annotation files looked like that
How should i understand the annotation? Is it something like that?
<Target ID>, <frame number>, <bbox_left>,<bbox_top>,<bbox_width>,<bbox_height>,<score>,<object_category>,<truncation>,<occlusion>
How may i display the bounding boxes such that it look like that? I do not need the class, but i just need the ID and the bounding box.![track_all_seg_1280_025conf](https://github.com/VisDrone/VisDrone-Dataset/assets/93758179/74e47511-43a5-4260-9086-918259b9ef8d)
Or something like that![image](https://github.com/VisDrone/VisDrone-Dataset/assets/93758179/0cf2a32e-9895-4431-ad53-3b189ff3839d)