Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to visualise VisDrone target ID and bounding box? #34

Open
fatbringer opened this issue Jun 6, 2023 · 2 comments
Open

How to visualise VisDrone target ID and bounding box? #34

fatbringer opened this issue Jun 6, 2023 · 2 comments

Comments

@fatbringer
Copy link

fatbringer commented Jun 6, 2023

I notice that the annotation files looked like that

1,0,19,783,60,91,1,1,0,0
2,0,16,782,60,91,1,1,0,0
3,0,13,781,60,91,1,1,0,0
4,0,11,780,60,91,1,1,0,0

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

Or something like that
image

@KyriakosChris
Copy link

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()

@fatbringer
Copy link
Author

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants