hukaixuan19970627 / yolov5_obb

yolov5 + csl_label.(Oriented Object Detection)(Rotation Detection)(Rotated BBox)基于yolov5的旋转目标检测
GNU General Public License v3.0
1.83k stars 427 forks source link

Get Pixel Coordinates of the bounding box vertices. Get angle of rotation too. #526

Open akamal816 opened 1 year ago

akamal816 commented 1 year ago

Hello All

After running detect.py is there anyway to output the pixel coordinates of the bounding box vertices and the rotation angle of the bounding box as well?

Thank you!

quangdungluong commented 1 year ago

To output the pixel coordinates of the bounding box vertices, add --save-txt when running detect.py. After that, you can calculate the rotation angle of the bounding box.

ibtehajali67 commented 1 year ago

angle you can find out angle by this adding this line after --save-txt you file a text file cross every lable so 1 to 9 are four points of detected object

NGUYENQUANGLY commented 1 year ago

Hello guys, I loaded model from local directory. I want to get angle from result model trained. My code: "

LOAD MODEL

import torch import numpy as np import cv2

model = torch.hub.load('PJ1/yolov5_obb', 'custom',source='local',path='PJ1/result_2--0.3c/best.pt', force_reload=True) image = cv2.imread("/home/lenovo/Documents/TRAIN/PJ1/images/HH_Rotate_0_0_1.jpg")

results = model(image) detections = results.poly[0] print(detections)" error: YOLOv5 🚀 b00c3f2 torch 1.10.1+cu113 CUDA:0 (NVIDIA Quadro M1000M, 2002MiB)

Fusing layers... Model Summary: 290 layers, 21584355 parameters, 0 gradients, 50.2 GFLOPs Adding AutoShape... Traceback (most recent call last): File "/home/lenovo/Documents/TRAIN/PJ1/ex_2.py", line 11, in detections = results.poly[0] AttributeError: 'Detections' object has no attribute 'poly' " Hope to any help from everyone!