Locate and MICR line anywhere on an image. Extract identified type of the document image: personal or business check, IRD. Rotate and deskew if needed.
Visual Basic |
---|
Public Function ExtractCheck() As ICiImage |
Private Sub ExtractToFile (file As String, page As Integer, fileOut As String) Dim reader As New CcMicrReader Dim checkImage As CiImage reader.Image.Open file, 1 Set checkImage = reader.ExtractCheck If (Not checkImage Is Nothing) Then checkImage.SaveAs fileOut ' To obtain check image geometrical information ' Position: reader.MicrLine(1).Document.Left, reader.MicrLine(1).Document.Top, reader.MicrLine(1).Document.Right, reader.MicrLine(1).Document.Bottom ' Skew: reader.MicrLine(1).Document.Skew ' Rotation: Choose(reader.MicrLine(1).Document.Conf, "None", "Upside Down", "Left", "Right", "Unknown") End If End Sub
static System.Threading.Mutex mut = new System.Threading.Mutex(); // Prevents reentrancy String[] rotText = {"", "None", "Upside Down", "Left", "Right", "Unknown"}; public static void ExtractToFile (string file, int page, string fileOut) { try { mut.WaitOne(); ClearMicr.CcMicrReader reader = new ClearMicr.CcMicrReader(); reader.Image.Open(file, page); ClearImage.CiImage checkImage = reader.ExtractCheck(); if (checkImage != null) { checkImage.SaveAs (fileOut, ClearImage.EFileFormat.ciTIFF); // To obtain check image geometrical information ClearMicr.CcMicrInfo Info = reader.get_MicrLine(i).Document; String s = String.Format("Document at {0}:{1}-{2}:{3} Skew: {4:F}deg Rotation: {5}", Info.Left, Info.Top, Info.Right, Info.Bottom, Info.Skew, rotText[(int)Info.Conf]); } return; } catch (Exception ex) { return ("ERROR: " + ex.ToString()); } finally { mut.ReleaseMutex(); System.GC.Collect(); } }