Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
ocr-preprocessor
Advanced tools
Readme
This is an asynchronous OCR preprocessor module for NodeJS.
Use npm to install it by running :
npm install --save ocr-preprocessor
Note : This module is only compatible with Linux and OpenCV 2.X
var preprocessor = require("ocr-preprocessor");
let options =
{
blur: 3 ,
threshold: 255 ,
matrix: 7 ,
constant: 5
};
preprocessor("./test.jpg" , "./result.jpg" , options , function(err , path) {
if (err) {
console.log("Error !");
}
else {
console.log("Preprocessed Image saved at : " + path);
}
});
This module export itself as a single function
This function accept 4 arguments :
Argument | Description | Type |
---|---|---|
Input Path | Path to the source image | String |
Output Path | Path to the destination image | String |
Options | Options passed to preprocessing engine | Object |
Callback | Callback executed on return | Function |
Option | Description | Type | Default |
---|---|---|---|
blur | Blur value | Number | 0 |
threshold | Threshold value | Number | 255 |
matrix | Threshold matrix size | Number | 3 |
constant | Threshold constant | Number | 5 |
revert | Revert the image | Boolean | false |
isolate | Find and isolate biggest area | Boolean | false |
deskew | Run deskew algorithm | Boolean | false |
matchCount | Deskew sensibility | Number | 100 |
ratio | Line width threshold for deskew | Number | 2 |
lineStep | Minimum line spacing for deskew | Number | 20 |
Note : ratio is used this way inside of the module :
image.width() / ratio;
Therefore , to select lined that are half the width of the image , ratio should be set to 2.
This module is asynchronous. All the work is done outside of the node main loop. It allows you to preprocess a big amount of images at the same time.
FAQs
asynchronous image preprocessor based on OpenCV for OCR engine
The npm package ocr-preprocessor receives a total of 7 weekly downloads. As such, ocr-preprocessor popularity was classified as not popular.
We found that ocr-preprocessor demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.