deskew
Library used to deskew a scanned document
Skew detection in scanned images
Detect and fix skew in images containing text
Automatically extract and perspectively correct documents in images