Skip to main content

Lightweight OCR for developer screenshots — extract text from code images, terminals, and IDE windows

Project description

OCY

OCY - Python OCR SDK

Lightweight OCR for developer screenshots — extract text from code images, terminals, and IDE windows with one line of code.

Made by Samin Yeasar • github.com/solez-aix.com/Solez_None

Installation

pip install ocy

Quick Start

1. Set your API URL

First, set the API URL. You can use a self-hosted instance or a public one:

import ocy

# Set your API URL (required)
ocy.set_api_url("https://your-api.vercel.app")

2. Extract text from a URL

result = ocy.extract_text("https://example.com/screenshot.png")
print(result["text"])
print(f"Confidence: {result['confidence']:.1%}")

3. Extract text from a local file

result = ocy.extract_text("./myScreenshot.png")
print(result["text"])

4. Async usage

import asyncio
import ocy

async def main():
    result = await ocy.extract_text_async("https://example.com/code.png")
    print(result["text"])

asyncio.run(main())

5. Use an API key

import ocy

# Option 1: Per-request key
result = ocy.extract_text("https://example.com/screenshot.png", api_key="your-key")

# Option 2: Set global key
ocy.set_api_key("your-key")
result = ocy.extract_text("https://example.com/screenshot.png")

Response Format

{
    "text": "extracted text from image...",
    "confidence": 0.95,        # 0.0 to 1.0
    "latency_ms": 150,         # processing time in milliseconds
    "model": "ocy-v1-int8",    # model identifier
    "chars_detected": 42       # number of characters detected
}

API Reference

Function Description
extract_text(img, api_key=None) Extract text synchronously
extract_text_async(img, api_key=None) Extract text asynchronously
set_api_url(url) Set custom API endpoint
set_api_key(key) Set global API key

License

MIT License - See LICENSE for details.

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

ocy-1.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

ocy-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file ocy-1.0.1.tar.gz.

File metadata

  • Download URL: ocy-1.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for ocy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3c376ea08b4287fd5569b4244dfc693aff0b4f40c16fd965d60d60ee73009bc0
MD5 5f93184648f54770fb13223650741697
BLAKE2b-256 d5d1e71e5fba01eaea8c96b1592aa75f254ec8d245357822733244018e4432f5

See more details on using hashes here.

File details

Details for the file ocy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ocy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for ocy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd99eb4bac427ea831a0ce88163d2113241af5c4bdb4bf9cf1126bdbc3b2f0bc
MD5 c0039a3c8d7108b34e49c17be5ed35de
BLAKE2b-256 05de35e0b0cb5a631838af6df104305c21bfc5968cc9c783c529c322b3c3fa2f

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