Measure image rotation
Visual Basic |
---|
Public Function MeasureRotation() As EPageRotation |
If the image contains enough capital letters of the Latin alphabet, this method returns ciRotNone, ciRotUpsideDown, ciRotLeft, or ciRotRight.
If the image does not contain a sufficient number of good quality letters, then graphical features like lines are used.
If the most lines are horizontal, this method returns ciRotPortrait. If the most lines are vertical, this method returns ciRotLeftOrRight.
If neither sufficient letters or lines are present, this method returns ciRotUnknow.
rConfidence property contains confidence level in percents.
Sub MeasureSkewRotation(imageFile As String) ' Open image file Dim Ci As New CiServer Dim Tools As CiTools: Set Tools = Ci.CreateTools Tools.Image.Open imageFile ' Do processing Dim skew As Double, rot As EPageRotation skew = Tools.MeasureSkew Debug.Print "Skew=" & skew & " Confidence=" & Tools.rConfidence & "%" & vbCrLf rot = Tools.MeasureRotation Debug.Print "Rotation=" & _ Switch(rot = ciRotUnknown, "Unknown", _ rot = ciRotNone, "None", _ rot = ciRotLeft, "TurnedLeft", _ rot = ciRotRight, "TurnedRight", _ rot = ciRotUpsideDown, "UpsideDown", _ rot = ciRotLeftOrRight, "TurnedLeftOrRight", _ rot = ciRotPortrait, "Portrait") & _ " Confidence=" & Tools.rConfidence & "%" End Sub