Search code examples
tensorflowopencvartificial-intelligenceobject-detectionimage-recognition

Rotate image to reduce training image count


I am training an object detection model used for tensorflow. The objects being detected are a bunch of different cards, each cards with different drawing on top of it.

As they are all plain cards, so user may lay it on the table in any orientation(360 degree), which means I need to label the images in every angle that user may put it on desk and train.

This looks like a overwhelm job. I am wondering if there is any tool that can do it for me? Eg) I provide a labeled image in one angle, and it rotates and labels automatically for all the other angles?

In the other hand, is there any opencv method to preprocess it to correct the orientation of the cards in the picture? So that I only need to train the images in one specific orientation.


Solution

  • I'm assuming you are using Tensorflow Object detection API, and they offer this data augmentation option in their configuration file during training.

    data_augmentation_options {
     random_rotation90 {
          probability: 0.5
        }
      }
    

    Rotation is bound to 90 degrees, but there are scale and flip options as well (and much more). You can see a list of options here

    If you are looking for an offline option, to process the images before training, I recommend the aleju/imgaug package. It processes your images along with the new bounding box coordinates.