Search code examples
image-processingcomputer-visionobject-detection

Detect rotated vehicle images


I want to rotated my vehicle images (90, 180, or 270 degree) to the right position.
I have used a hypothesis that is: rotate the image with 4 angle (0, 90, 180, 270) and give each one to an object detetion Neural Net, the angle that gives greatest car object confidence score will be the angle I have to use to rotate my image.
The problem is: Some images with 180 rotate give better score than the original, because the NN mistakenly detect the road with 2 wheels is the car. For example:
The original image
The rotated image but get better score

How can I can prevent that from happening?
My model: ssd_resnet_50_fpn_coco from model zoo
Here is some other fail cases:
1 2 enter image description here


Solution

  • I found the solution that is a bit tricky.
    Firstly, I created a model (SSD for example) that will detect 4 classes which are the rotation angle of the image, i.e: class1 - 0 degree, class2 - 90 degree, etc.
    The model, then, will find 2 label correctly out of 4: 0 and 180. If the label ran into 90 or 270 (which are sometimes recognized as one another), I will rotate them again with 90 degree and let the model predict what their label are between 0 and 180. After that, I will subtract the degree with 90 degree to get the right label.