Transform boundingBox according to angle and rotation

553 Views Asked by At

I am trying to implement a plastic cards detector using Vision ML Model which was trained on a custom data set. I am drawing rectangles according to bounding boxes coordinates over the camera view and it works like a charm. BUT. It doesn't react to changes in the angle, or rotation. You can see this on the screens below.

2022-12-04-03-28-28.jpg 2022-12-04-03-28-33.jpg

The ideal solution already exists in the same Vision library, but for rectangles detection. It has topLeft, topRight, bottomLeft, bottomRight with which I can draw whatever quadrilateral, but object detection has only bounding box property which actually is CGRect (ML model really required here for future changes). I found a lot of similar answers, but they had different contexts or language or the task itself.

Maybe there is some way to do it with CGAffineTransform or configure model training better? Thanks!

1

There are 1 best solutions below

0
On

You can detect the object you need using object detector model and then use VNDetectRectanglesRequest. It may be a little bit slow, but this way you don't have to train anything :)