A lightweight Node.js OCR service utilizing chrome-lens-ocr, Express, and Multer, providing a free alternative to Google Cloud Lens API..
This service provides Optical Character Recognition (OCR) capabilities through two endpoints:
POST /upload: Accepts image file uploads and returns the extracted text.GET /scan: Fetches an image from a provided URL and returns the extracted text.
To set up the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/dgbkn/lens_api_chromium_docker.git
-
Navigate to the project directory:
cd lens_api_chromium_docker -
Install dependencies:
npm install
-
Start the server:
npm start
The server will run on
http://localhost:3000.
Endpoint to perform OCR using Google Lens internal API (requires Protobuf definitions).
- URL:
http://localhost:3000/api/ocr/glens - Method:
POST - Headers:
Content-Type: multipart/form-data - Body: Form-data with a key
imagecontaining the image file.
Example using cURL:
curl -X POST -F "image=@path_to_your_image.png" http://localhost:3000/api/ocr/glenswebEndpoint to perform OCR by simulating requests to the Google Lens website.
- URL:
http://localhost:3000/api/ocr/glensweb - Method:
POST - Headers:
Content-Type: multipart/form-data - Body: Form-data with a key
imagecontaining the image file.
Example using cURL:
curl -X POST -F "image=@path_to_your_image.png" http://localhost:3000/api/ocr/glenswebTo deploy the service using Docker:
-
Build the Docker image:
docker build -t ocr-service . -
Run the Docker container:
docker run -p 3000:3000 ocr-service
Alternatively, use Docker Compose:
-
Start the service:
docker-compose up --build
The service will be accessible at http://localhost:3000.
Contributions are welcome! Please follow these steps:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes.
-
Commit your changes:
git commit -m "Add your commit message" -
Push to the branch:
git push origin feature/your-feature-name
-
Open a pull request.
Distributed under the MIT License. See LICENSE for more information.
Dev Goyal
📧 anandrambkn@gmail.com