views:

860

answers:

2

I would like to rotate photos automatically, even when EXIF metadata about the image orientation is not available.

Are there any good algorithms for detecting the orientation of a photo? The images are photographs from a digital camera. The algorithm doesn't have to work perfectly, but any reduction in the amount of human interaction required to properly rotate photos would be a benefit.

I have found these two papers on the topic:

Pointers to other research and especially implementations are appreciated.

+3  A: 

Many photographs from consumer digital cameras are of people, which could be used for orientation. Face detection is a well-studied research area. Basic face detection would give you a rectangle whose longer side should be the vertical dimension. Further, if you can detect the eyes/mouth, you should be able to pick the correct orientation of the rectangle.

Many other photographs are tourist snaps, where the sky is up and blue, and the ground is down and green.

smackfu
Many face detection algorithms will not find faces that are upside down so you have to look for faces in all four possible directions.
Janusz
This is something that I've been considering since examining the papers I linked to above, because at least one of them uses face recognition as part of the algorithm. Since the vast majority of my photo corpus will include faces I think it may work well (assuming I can find a face recognition program that can recognize orientation, per Janusz).
Luke Francl
A: 

If the images are not square, you may be able to make the assumption that the default images are wider than they are tall. If that's the case determaning whether you need to rotate is just a matter of comparing the aspect ratio and rotating to reorient to default. Though you may end up with upside down images.

bdbaddog
This is only true for default images. Often people taking pictures of faces or people will turn the camera...
Janusz
True, but when people turn the camera to take such pictures, unless the faces are sideways or upside down, you may be able to use the aspect ratio for at least a hint.
bdbaddog