TIEVisionOCR.getOrientation
Declaration
procedure getOrientation(out orientation: TIEVisionOCROrientation; out writingDirection: TIEVisionOCRWritingDirection; out textlineOrder: TIEVisionOCRTextlineOrder; out deskewAngle: single); safecall;
Description
Returns detail of the orientation, rotation and text direction of the document. This can be used for non-OCR applications, such as automatically correcting the rotation of scanned documents.
getOrientation should be called after
getTextAngle or
recognize.
Parameter | Description |
orientation | Character orientation, mainly used for document orientation, e.g. a page scanned upside-down would return ievOCROrientPAGE_DOWN |
writingDirection | Writing direction |
textlineOrder | Line direction, e.g. Right-to-left for Arabic or Hebrew, or Top-to-bottom for some Asian text |
deskewAngle | Deskew angle in radians in the range -Pi/4 and Pi/4. The level of rotation required to correct a document scanned at an angle |
Notes:
-
getOrientation works best with the
ievOCRAuto_OSD segmentation mode
-
getOrientation requires the support file
Osd.TrainedData for all languages
Example
// AUTOMATICALLY ROTATE CURRENT DOCUMENT IMAGE TO CORRECT ORIENTATION
// Create OCR Engine
m_OCR := IEVisionLib.createOCR( sOcrFilesPath, IEOCRLanguageList[ OCR_English_language ].Code, ievOCRDefault );
// Detect orientation
m_OCR.setSegmentationMode( ievOCRAuto_OSD );
angle := m_OCR.getTextAngle( ImageEnView1.IEBitmap.GetIEVisionImage() ) * 180 / PI;
// Retrieve orientation details
m_OCR.getOrientation( orientation, writingDirection, textlineOrder, deskewAngle );
deskewAngle := -deskewAngle * 180 / PI;
if orientation = ievOCROrientPAGE_RIGHT then
deskewAngle := deskewAngle - 90
else
if orientation = ievOCROrientPAGE_DOWN then
deskewAngle := deskewAngle - 180
else
if orientation = ievOCROrientPAGE_LEFT then
deskewAngle := deskewAngle - 270;
if deskewAngle <> 0 then
ImageEnView1.Proc.Rotate( -deskewAngle );