Pega integration with an opensource ==> Tesseract OCR API
Tesseract OCR is an optical character reading engine developed by HP laboratories in 1985 and open sourced in 2005. Since 2006 it is developed by Google. Tesseract has Unicode (UTF-8) support and can recognize more than 100 languages “out of the box” and thus can be used for building different language scanning software also. Latest Tesseract version is Tesseract 4. It adds a new neural net (LSTM) based OCR engine which is focused on line recognition but also still supports the legacy Tesseract OCR engine which works by recognizing character patterns.
Generally OCR works as follows:
-Pre-process image data, for example: convert to gray scale, smooth, de-skew, filter.
-Detect lines, words and characters.
-Produce ranked list of candidate characters based on trained data set. (here the setDataPath() method is used for setting path of trainer data)
-Post process recognized characters, choose best characters based on confidence from previous step and language data. Language data includes dictionary, grammar rules, etc.
Here is the working functionality of OCR:
Advantages of OCR:
- it increases the efficiency and effectiveness of office work
- The ability to instantly search through content is immensely useful, especially in an office setting that has to deal with high volume scanning or high document inflow.
- OCR is quick ensuring the document’s content remains intact while saving time as well.
- Workflow is increased since employees no longer have to waste time on manual labor and can work quicker and more efficiently.
Disadvantages:
- The OCR is limited to language recognition.
- There is lot of effort that is required to make trainer data of different languages and implement that.
- One also need to do extra work on image processing as it is the most essential part that really matters when it comes to the performance of OCR.
- After doing such a great amount of work, no OCR can offer an accuracy of 100% and even after OCR we have to determine the unrecognized character by neighboring methods of machine learning or manually correct it.
For more details about this API documentation and all, pls google it.
How to use and integrate Tesseract OCR from Pega PE running on Windows 10:
(1) Install all the jars(15) from "tess4j-3.3.1.zip" into Pega using Pega Import wizard (https://sourceforge.net/ projects/tess4j/files/tess4j/ 3.3.1/)
(2) Install the VC++ 2015 standard libraties(vc_redist.x64.exe, vc_ redist.x86.exe) before we run this OCR implementation and here is the link:https://www.microsoft.com/en- us/download/details.aspx?id= 53587. After installation, we need to restart the machine to use these files from Windows OS.
(3) Get the 3 DLL's (libtesseract305.dll, gsdll64.dll, liblept174.dll) after extraction of the above zip file in the local path (C:/Users/urspv/Documents/Eclipse/Tess4J-3.3.1/dlls/). These files are packaged in 2 jars: tess4j-3.3.1.jar and lept4j-1.3.1.jar
(4) Keep all the trained data mentioned in a folder called "tessdata" after extraction of the above zip and place it in the tomcat path: C:\Users\urspv\Documents\Pega\ V74\PRPCPersonalEdition\ tomcat\lib\tessdata
(5) It is better to keep all images needed for our exercise in the tomcat path like this C:\Users\urspv\Documents\Pega\ V74\PRPCPersonalEdition\ tomcat\lib\images
(6) Restart the Pega PE server
(7) Build a sample Pega function in a library with all the necessary packages imported and build the Pega compatible java code mentioned in the API documentation.This Pega function needs 2 parameters. One param is to get the image file taken from the tomcat path mentioned above and other parameter is to get the tessdata path mentioned above. Based on these 2 parameters, the predefined method: doOCR() from the tess4j API will read the text from the image file.
Important point is to call/load the above DLL's from this function only once and for this we need to use System.load() method from java before doOCR() call.
Note: This API integration from Pega is tricky and I took more time in reading & understanding the process to use the DLL's from Pega on-fly.
Here is the sample screenshot taken from Pega PE.
References:
1) https://google.com

