Upright Adjustment
Automatically levels an image (Lightroom 2013)
Upright tool analyzes an image to automatically level horizons and straighten objects like buildings to correct a keystone effect, by rotating the image in 3D. It actually does camera calibration: extracting 3D camera orientation from the image content. It is based on this research paper.
Watch the popular youtube tutorial here.