openfoodfacts / robotoff

🤖 Real-time and batch prediction service for Open Food Facts
https://openfoodfacts.github.io/robotoff/
GNU Affero General Public License v3.0
80 stars 56 forks source link

Auto-rotate images if necessary #971

Open raphael0202 opened 2 years ago

raphael0202 commented 2 years ago

Some images that contributors send us are not correctly oriented (they may be rotated to the left, to the right or top-down). Using Google Cloud Vision, we store the orientation of each detected word (up, right, down, left) as a prediction, in the prediction DB table, with the image_orientation type. prediction.data has the following structure:

{"count":{"up":4,"left":1,"right":18},"rotation":270,"orientation":"right"}

The count field gives you how many words were correctly oriented ("up"), left-oriented ("left"), right-oriented ("right"), or flipped ("down"). The orientation with the highest count determines the values for the remaining fields:

We would like to automatically rotate incorrectly-rotated images if we're confident enough that the rotation is incorrect:

Steps

teolemon commented 2 years ago