Scanner Pro SDK ActiveX

Scanner Pro SDK ActiveX

Platform : Windows 10, Windows 8, Vista, Windows 7, XP

For Windows Developers who need to capture image from scanner, digital camera that has a TWAIN device driver and save to Docx, TIFF , PDF/A with C#, C ,VB.NET , VB, Delphi, VFP, MS Access.

Popular Solution Go   Back

VB6 - How to improve the OCR quality

Step 1: To install the Scanner Pro SDK, begin by launching the setup file (scannerprodemosetup.exe). Select the desired installation folder for the Scanner Pro SDK ActiveX and continue with the installation on your development computer.

Step 2:  Launch Visual Basic 6.0. Select  New Project, Select  Standard EXE.
Step 3:  Select Project - References... , Select Scanner Pro ActiveX Control
Step 4:  Now you will see the Scanner Pro SDK ActiveX display  on toolbar.



Step 5:  Drag Scanner Pro SDK ActiveX  on form and add one button, one label and one textbox on form, the UI like the following screen


Step 6:  For demonstration purposes, we download this image clearbackgroundsample.jpg.



Step 7:  In Start OCR button click event, add the following code
Private Sub Command1_Click()
Dim iresult As Integer

'Change this to the path of 
clearbackgroundsample.jpg
'Scanner1.LoadImage ("c:yourfolderclearbackgroundsample.jpg")
Scanner1.OCRRecognizeMode = 1
Scanner1.OCRSetRect 0, 0, 0, 0
 
iresult = Me.Scanner1.OCRStartScan(0, "dictfiles")
 
End Sub

Step 8: add the following code in OCRRecognized event

Private Sub Scanner1_OCRRecognized(ByVal bSuccess As Boolean)
 Text1.Text = Scanner1.OCRGetRecognizedCharCount
 MsgBox Scanner1.OCRGetRecognizedText
End Sub

Step 9: Now run the project and click OCR Start button, it will display the recognized text in message box. It cannot recognized text if set the  OCRRecognizeMode = 1.
Step 10: In Start OCR button click event, we change the OCRRecognizeMode = 3, it will use Clear Text Background Mode, it will improve the OCR quality if the scanned image have some background (e.g. Grid).

Scanner1.OCRRecognizeMode = 3

Step 11: Now run the project and click OCR Start button, it will display the recognized text in message box. Now the result is very good.

Step 12:   For demonstration purposes, we download this image noisesample.png



Step 13: In Start OCR button click event, we change the LoadImage method to load noisesample.png and set OCRRecognizeMode = 2

'Change this to the path of noisesample.png
'Scanner1.LoadImage ("c:yourfoldernoisesample.png ")
Scanner1.OCRRecognizeMode = 2

Step 14: Now run the project and click OCR Start button, it will display the recognized text in message box. Now the result is bad.



Step 15: In Start OCR button click event, we change the OCRRecognizeMode = 5, it will use Clear Noise Mode, it will improve the OCR quality if the scanned image have some noise.

Step 16: Now run the project and click OCR Start button, it will display the recognized text in message box. Now the result is very good.