Skip to main content

OCRmyPDF plugin using Google Lens API for OCR

Project description

OCRmyPDF-ChromeLens-Ocr

A plugin for OCRmyPDF that uses the Google Lens API to perform Optical Character Recognition (OCR).

Features

  • High Accuracy: Leverages Google's advanced Lens models.
  • Structure Preservation: Correctly handles multi-column layouts and vertical text flows via strict API parsing and rotation-aware sorting.
  • Smart De-hyphenation: Merges words broken across lines while respecting punctuation dashes.

Installation

Prerequisites

You must have ocrmypdf installed.

Install from Git

pip install git+https://github.com/atlantos/OCRmyPDF-ChromeLens-Ocr.git

Usage

To use this engine, pass the plugin name to OCRmyPDF. You generally do not need to specify a language, as Google Lens auto-detects it.

ocrmypdf --plugin ocrmypdf_chromelens_ocr input.pdf output.pdf

Configuration Options

You can configure the behavior of the plugin using the following command-line arguments:

Argument Description Default
--chromelens-no-dehyphenation Disables the logic that merges hyphenated words across lines. Useful if you prefer raw output. Disabled
--chromelens-max-dehyphen-len The maximum length of word parts allowed for de-hyphenation. If both the prefix (before hyphen) and suffix (after hyphen) are longer than this value, the plugin assumes it is a compound word or dash separator and will not merge them. 10

Example: Disable de-hyphenation

ocrmypdf --plugin ocrmypdf_chromelens_ocr --chromelens-no-dehyphenation input.pdf output.pdf

Example: Stricter de-hyphenation (only merge very short breaks)

ocrmypdf --plugin ocrmypdf_chromelens_ocr --chromelens-max-dehyphen-len 4 input.pdf output.pdf

Credits & Acknowledgements

This project is a Python port and adaptation based on ideas and logic from:

  1. chrome-lens-ocr:

    • Provided the critical reverse-engineering of the Google Lens Protobuf API (v1/crupload).
    • Logic for strict layout parsing and request structure.
  2. OCRmyPDF-AppleOCR:

    • Provided the architectural inspiration for creating an OCRmyPDF plugin that offloads recognition to an external engine.

Disclaimer

This software is for educational purposes. It uses an undocumented private API from Google.

  • Privacy: Your images are uploaded to Google servers. Do not process sensitive/confidential data.
  • Stability: The API may change or break at any time without notice.
  • Rate Limits: Excessive use may result in your IP being temporarily blocked by Google.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocrmypdf_chromelens_ocr-1.0.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocrmypdf_chromelens_ocr-1.0.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file ocrmypdf_chromelens_ocr-1.0.0.tar.gz.

File metadata

  • Download URL: ocrmypdf_chromelens_ocr-1.0.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ocrmypdf_chromelens_ocr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ec191e03f2be55f57ee1aeab3c2e7a4fa072c386ca260c020cd983cb8a5bf623
MD5 f31f7f775e865be9a8701f4829e43a29
BLAKE2b-256 3c40e835668b0273ea5287b08f155a6de318578123ea356c3645f41e1bcf952d

See more details on using hashes here.

File details

Details for the file ocrmypdf_chromelens_ocr-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ocrmypdf_chromelens_ocr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c8ae7ad67b2b23d87f2e6135e4a919d03f7b7dc6668e89074ad09a7ebfab4dd
MD5 9e44fcbedd9994aee7b856853e3c1d35
BLAKE2b-256 ed5c8f8c392b5b02c83ba9cba567e63f41cf7ba5cee9e3b62941503974b4269b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page