Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
robotframework-ocrlibrary
Advanced tools
A robot framework library that utilizes OpenCV image processing and pytesseract OCR.
A robot framework library that is capable of processing images, validating text, and locating specified text by coordinates within images.
You can find the keyword documentation here.
pip install robotframework-ocrlibrary
OCRLibrary uses two dependencies downloadable through the pip package manager, opencv-python and pytesseract. As well as Tesseract OCR.
OCRLibrary requires Google's Tesseract OCR software.
To install tesseract on Linux, run sudo apt install tesseract-ocr
To install tesseract on MacOS, run brew install tesseract
To install tesseract on Windows, download one of the installers from UB-Mannhiem/tesseract Once installed add the path to the tesseract folder (ex: C:\User\Program/ Files\tesseract) to your environment variables.
Run the command tesseract -v
to confirm that tesseract was downloaded successfully.
For more detailed installation instructions of tesseract please see the following installation guide.
To install opencv-python, run pip install opencv-python
.
Please see opencv-python's installation and usage section for more information.
To install pytesseract, run pip install pytesseract
.
Please see pytesseracts installation section for more information.
Once OCRLibrary is installed, along with its dependencies, add Library OCRLibrary
to your robot file to use.
You can see which languages are available by running tesseract --list-langs
. You can do the following to install more languages. Here is a list of supported languages, language codes and tessdata files.
To install all languages on Linux, run sudo apt install tesseract-ocr-all
.
To install a specific language on Linux, run sudo apt install tesseract-ocr-<lang>
. Where <lang>
is the language code.
To install all language on MacOS, run brew install tesseract-lang
.
To download a language on Windows, you must install the trained model for your desired language. This repo has many language models to download. Here are more tessdata files. Once downloaded, place the trained model in the tessdata directory (i.e. where the tesseract.exe is located).
You can add any combination of the following to the pyt_conf
string argument.
Page segmentation modes provide different ways a page of text can be analyzed. Here is a list of supported page segmentation modes:
Mode | Description |
---|---|
0 | Origentation and script detection only. |
1 | Automatic page segmentation with OSD. |
2 | Automatic page segmentation, but no OSD, or OCR. |
3 | Fully automatic page segmentation, but no OSD. (Default) |
4 | Assume a single column of text of variable sizes. |
5 | Assume a single uniform block of vertically aligned text. |
6 | Assume a single uniform block of text. |
7 | Treat the image as a single text line. |
8 | Treat the image as a single word. |
9 | Treat the image as a single word in a circle. |
10 | Treat the image as a single character. |
11 | Sparse text. Find as muuch text as possible in no particular order. |
12 | Sparse text with OSD. |
13 | Raw line. Treat the image as a single text line, by passing hacks that are Tesseract-specific. |
To change your page segmentation mode, add --psm <mode>
to your custom configuration string.
Select the OCR engine modes to be used by pytesseract:
Mode | Description |
---|---|
0 | Legacy engine only. |
1 | Neural nets LSTM engine only. |
2 | Legacy + LSTM engines. |
3 | Default, based on what is available. |
To change your ocr engine mode, add --oem <mode>
to your custom configuration string.
This configuration specifies which characters to detect.
Add the characters you want to detect to the string: -c tessedit_char_whitelist=
.
An example to only detect lowercase letters: -c tessedit_char_whitelist=abcdefghijklmnopqrstuvwxyz
Opposite to whitelisting characters, this configurations lets you specify which characters to not detect.
Add the characters you want to not detect to the string: -c tessedit_char_blacklist=
An example to not detect special characters: -c tessedit_char_whitelist=!@#$%^&*()
Visit this site for a complete list of Tesseract configuration parameters.
In this example, the content will be returned from the processed image using page segmentation mode 6 and it will ignore all numbers.
${content}= Get Image Content ${processed_image} --psm 6 -c tessedit_char_blacklist=0123456789
Please see any of the following links for more information on image processing using OpenCV:
Thank you for thinking of contributing to the robotframework-ocrlibrary!
When contributing please adhere to the following.
If you find a bug, please submit an issue.
If you want to fix something or improve upon something, fork the repo, and create a new branch. Once you have made the changes and have written unit tests or updated the regression tests (please use pythons Unittest when testing), make a pull request.
Please put the files in the appropriate directories with the appropriate names. The image processing features fall under any of these categories, please name the file to resemble that category (see existing files for examples), or add to an existing file.
FAQs
A robot framework library that utilizes OpenCV image processing and pytesseract OCR.
We found that robotframework-ocrlibrary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.