A Node.js wrapper for EasyOCR
npm install easyocr-jsbash
npm install easyocr-js
`
$3
- Python 3.6+ must be installed on your system.
- Pip package manager is required.
- The necessary Python dependencies will be installed automatically during the npm installation process.
Usage
easyocr-js supports CommonJS module systems. Below is an example:
$3
`javascript
const EasyOCRWrapper = require("easyocr-js");
(async () => {
const ocr = new EasyOCRWrapper();
console.log(await ocr.init("en"));
console.log(await ocr.readText("path/to/yourimage.jpg")); // Replace with actual image path
console.log(await ocr.close());
})();
`
API
$3
Initializes the OCR reader with the specified languages.
- languages: Comma-separated language codes (e.g., 'en,fr').
- Returns a Promise resolving to a status object.
$3
Performs OCR on the specified image.
- imagePath: Path to the image file.
- Returns a Promise resolving to an array of detected text objects:
`json
{
"status": "success",
"data": [
{
"bbox": [[x1, y1], [x2, y2]],
"text": "Detected text",
"confidence": 0.98
}
]
}
``