cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
11.9k stars 2.9k forks source link

Rotated bounding boxes #1128

Closed MadsDyrmann closed 2 years ago

MadsDyrmann commented 4 years ago

Thank you for the great effort, you are putting into this project :) There is, however, a feature I miss; rotated bounding boxes. Especially when objects are thin and diagonal, an ordinary bounding box fits poorly. Examples of such cases are shown here: rotated bounding boxes

A way annotation could be carried out is by using the recently implemented "extreme clicking" combined with the minimum bounding-box algorithem

cbasavaraj commented 4 years ago

I second this demand :) For info, opencv has its well-known minAreaRect function, which could be as well:

https://docs.opencv.org/3.4/dd/d49/tutorial_py_contour_features.html https://docs.opencv.org/3.4/d3/dc0/group__imgproc__shape.html#ga3d476a3417130ae5154aea421ca7ead9

So it's a simple extension from the polygon mode we already have. And it would definitely be useful to have Interpolation mode available for these Rotated Boxes.

Thanks!

dketterer commented 3 years ago

I saw a rotated bounding box format in a customized COCO json the other day. Just wanted to leave that here.

Like this:

"bbox" : [x, y, w, h, theta]    # all floats, where theta is measured in radians anti-clockwise from the x-axis.
"segmentation" : [[x1, y1], [x2, y2], [x3, y3], [x4, y4]]    # Required for validation scores.

I also think an addtional method to directly annotate rotated bounding boxes would be useful instead of using the segmentation to crete them from the segmentaion.

nmanovic commented 3 years ago

@MadsDyrmann , why don't use a polygon with 4 points? Do you need them only in annotation files?

MaxPRon commented 2 years ago

Hi guys,

thanks for the great effort!

I was trying to the rotated bounding box pull request but I can't seem to find the feature.

Could anybody give me a hint how to use it ? I'm new to the tool so maybe I'm just overlooking it.

Best regards and thanks a lot,

Max

farid67 commented 2 years ago

Hi guys,

thanks for the great effort!

I was trying to the rotated bounding box pull request but I can't seem to find the feature.

Could anybody give me a hint how to use it ? I'm new to the tool so maybe I'm just overlooking it.

Best regards and thanks a lot,

Max

Same here

cbasavaraj commented 2 years ago

Hello, this issue has been closed by the maintainers. I tried using rotated bounding boxes for training a model on detectron2 last year. But the results were not great, as the predicted angle changed from frame to frame. So in my opinion, it's not worth the trouble.

A better approach is to use a segmentation model like mask-rcnn. So you have the exact mask, and the bounding box and its angle are less important. Of course from the mask you cannot tell which side is up or the orientation in general. But I think that's not so important usually.

nmanovic commented 2 years ago

@cbasavaraj , @farid67 , @MaxPRon , you can find it in develop branch at the moment: https://openvinotoolkit.github.io/cvat/docs/manual/advanced/annotation-with-rectangles/#rotation-rectangle

MaxPRon commented 2 years ago

Thank you @nmanovic

I tried to use the feature with the latest develop branch, however the rotation point is not there:

image

Am I missing anything ?

quents commented 2 years ago

I also cannot use rotation point at the latest develop branch.

kimlia545 commented 2 years ago

@nmanovic There is a problem with labeling the rotating box. When I download the label(COCO 1.0) with "Export task dataset" and do "Upload annotations" again, all rotation disappear.

{
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "segmentation": [],
            "area": 334.9267999999998,
            "bbox": [
                261.75,
                190.06,
                44.42,
                7.54
            ],
            "iscrowd": 0,
            "attributes": {
                "occluded": false,
                "rotation": 324.4
            }
        }

#Upload Coco's dataset, the rotation disappears
{
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "segmentation": [],
            "area": 334.9267999999998,
            "bbox": [
                261.75,
                190.06,
                44.42,
                7.54
            ],
            "iscrowd": 0,
            "attributes": {
                "occluded": false,
                "rotation": 0.0
            }
        }
nmanovic commented 2 years ago

@kimlia545 , I believe COCO format doesn't support rotated bounding boxes. But let my engineering team to comment. @yasakova-anastasia , @zhiltsov-max , could you please comment? In any case it is a good idea to have a table to the format list and features which they support.

kimlia545 commented 2 years ago

@nmanovic Thank you for answer. rotation remains in the CVAT 1.1. I hope it will be supported by coco as well.

zhiltsov-max commented 2 years ago

@kimlia545, hi. Our COCO implementation refers to the original format, which doesn't have rotation info, but we've added a rotation attribute as an extension, and it can be seen in the example above. Thank you for reporting the import problem, need to double check this.