Lightweight OCR for developer screenshots — extract text from code images, terminals, and IDE windows
Project description
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-ai • x.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocy-1.0.0.tar.gz.
File metadata
- Download URL: ocy-1.0.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d20e78a78ed7d04c5b062694a1419e9ebfae802232d850400e2151be95290fa
|
|
| MD5 |
a8eff50c23cd2d76d624657b93f4f7a1
|
|
| BLAKE2b-256 |
3de4f489094a08679b53a60017fd3abcd080411ef21a4a1ed68449d9079c1c80
|
File details
Details for the file ocy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ocy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa86c4bebb0d9b5cf9775976e57f83a6020b69a248e310b2371cee79131b9591
|
|
| MD5 |
ac882f97001878d23d6da387fbf97c44
|
|
| BLAKE2b-256 |
81a6e89294aafbc6ec577efff1bce64d3364c294596864af8c3a235ea7328e68
|