how to detect orientation of a scanned document?
I'd to detect and, if necessary, correct the orientation of a scanned document image. I am already able to deskew documents, however it still might occur, that a document is upside down and it needs to be rotated by 180°. Using tesseract 's layout analysis feature it should be possible to determine a document's orientation using this code: tesseract::TessBaseAPI api; api.Init(argv[0], "eng"); api.SetImage(img); api.SetPageSegMode(tesseract::PSM_AUTO_OSD); tesseract::PageIterator* it = api.AnalyseLayout(); tesseract::Orientation orient; tesseract::WritingDirection dir; tesseract::TextlineOrder