-1

I have a target object and a lot of other objects in an image. Target object is pre-defined with a known shape in advance as shown in figure.

Target image

My task is to detect all the target object present in the image and find the angle at which the detected object is oriented with respect to target object. For the object detection purpose I am using YOLO-V5-OBB model which gives me detection confidence and the rotated bounding box coordinates.See the result below

detected result

I would like to know how rotation angle is predicted by yolo-obb model in order to make rotated bounding boxes around the detected objects?

rohit thakur
  • 27
  • 1
  • 7

2 Answers2

1

For finding the object:

Before using heavy machine learning models, try using classic computer vision algorithms.

For finding the object: If the object above is the only object you will be searching for: Use cv2.HoughCircles().

https://docs.opencv.org/3.4/d4/d70/tutorial_hough_circle.html

If you want to be able to search arbitrary objects: Try using template matching.

https://pyimagesearch.com/2021/03/22/opencv-template-matching-cv2-matchtemplate/

After detecting the objects:

Apply Hough transform to extract the top line and detect the angle by using a line fitting algorithm.

OpenCV line-fitting (Might be deprecated)

desertnaut
  • 57,590
  • 26
  • 140
  • 166
YScharf
  • 1,638
  • 15
  • 20
0

I think you may try to use YOLOv5-OBB to train and get the coordinates of bounding box, and then it is easy to find the angle of orientation. Look at the detect.py.

  1. https://www.youtube.com/watch?v=iRkCNo9-slY
  2. https://github.com/hukaixuan19970627/yolov5_obb
# Write results
for *poly, conf, cls in reversed(det):
                    if save_txt:  # Write to file
                        # xywh = 
(xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist()  
# normalized xywh
desertnaut
  • 57,590
  • 26
  • 140
  • 166
andy wong
  • 61
  • 5
  • as per your advice I trained the yolo_obb model and getting the rotated bounding box but angle information from the detected result is somewhat confusing. can you explain more on how to calculate the angle? – rohit thakur Aug 22 '22 at 06:19