# Captcha Engine
A high-performance, ONNX-based captcha recognition engine for Rust.
## Features
- **High Accuracy**: Uses a custom-trained CNN-RNN-CTC model (95%+ accuracy)
- **Fast Inference**: Powered by [ort](https://github.com/pykeio/ort) (ONNX Runtime)
- **Flexible Deployment**:
- `download` (default): Tiny binary, downloads model on first run
- `embed-model`: Zero-dependency, single binary distribution (bundles model)
- **Standard Interface**: Simple `predict(image)` API
## Usage
Add to `Cargo.toml`:
```toml
[dependencies]
captcha-engine = { path = "crates/captcha-engine" }
# For embedded model:
# captcha-engine = { path = "crates/captcha-engine", features = ["embed-model"], default-features = false }
```
### Example
```rust
use captcha_engine::CaptchaModel;
fn main() -> anyhow::Result<()> {
// 1. Initialize Model
// With `embed-model` feature (recommended for plugins):
let mut model = CaptchaModel::load_embedded()?;
// OR with `download` feature (default):
// let model_path = captcha_engine::ensure_model_downloaded("models")?;
// let mut model = CaptchaModel::load(&model_path)?;
// 2. Predict
let image = image::open("captcha.png")?;
let text = model.predict(&image)?;
println!("Captcha: {}", text);
Ok(())
}
```
## Architecture
- **Input**: 215x80 RGB images
- **Model**: Custom ResNet + BiLSTM + CTC (ONNX format)
- **Output**: 6-character alphanumeric string (case-insensitive)