visionkit-rs 0.2.1

Safe Rust bindings for VisionKit.framework — image analysis, Live Text, and availability-aware area coverage on macOS
Documentation
  • Coverage
  • 0.39%
    1 out of 256 items documented1 out of 147 items with examples
  • Size
  • Source code size: 583.03 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 7.93 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 11s Average build duration of successful builds.
  • all releases: 1m 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • doom-fish/visionkit-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 1313

visionkit-rs

Safe Rust bindings for Apple's VisionKit.framework on macOS.

Status: v0.2.1 covers the full public macOS ImageAnalysisOverlayView surface — including delegates, menu tags, selection metadata, tracking views, fonts, and subject analysis — alongside ImageAnalyzer, ImageAnalysis, and explicit availability metadata for the iOS-only document-camera / Data Scanner / recognized-item areas.

Quick start

use visionkit::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    if !ImageAnalyzer::is_supported() {
        println!("ImageAnalyzer is not supported on this Mac");
        return Ok(());
    }

    let analyzer = ImageAnalyzer::new()?;
    let configuration = ImageAnalyzerConfiguration::new(ImageAnalysisTypes::TEXT)
        .with_locales(["en-US"]);
    let analysis = analyzer.analyze_image_at_path(
        "examples/assets/live_text.png",
        ImageOrientation::Up,
        &configuration,
    )?;

    let interaction = LiveTextInteraction::new()?;
    interaction.track_image_at_path("examples/assets/live_text.png")?;
    interaction.set_analysis(&analysis)?;

    println!("transcript: {}", analysis.transcript()?);
    println!("live text overlay text: {}", interaction.text()?);
    Ok(())
}

Highlights

  • ImageAnalyzer::is_supported and supported_text_recognition_languages
  • ImageAnalyzerConfiguration, ImageAnalysisTypes, and ImageOrientation
  • File-path based analysis through every public macOS analyzer overload: URL, NSImage, CGImage, CIImage, and CVPixelBuffer
  • ImageAnalysis::transcript and has_results
  • full LiveTextInteraction coverage for macOS ImageAnalysisOverlayView, including delegates, menu tags, selection metadata, tracking/content views, fonts, and subject analysis
  • VNDocumentCameraViewController, DataScannerViewController, RecognizedText, Barcode, and RecognizedItem availability metadata on macOS

Availability

  • ImageAnalyzer, ImageAnalysis, and LiveTextInteraction are available on macOS 13+.
  • LiveTextInteraction::text, selected_text, selected_attributed_text, selected_ranges, and LiveTextMenuTag require macOS 14+ because Apple introduced those overlay accessors after macOS 13.
  • VNDocumentCameraViewController, DataScannerViewController, RecognizedText, Barcode, and RecognizedItem are iOS-only Apple APIs. On macOS, this crate exposes them as structured availability metadata instead of pretending they exist.

Examples

cargo run --example 01_vn_document_camera_view_controller
cargo run --example 02_framework_smoke
cargo run --example 03_data_scanner_view_controller
cargo run --example 04_image_analyzer
cargo run --example 05_live_text_interaction
cargo run --example 06_image_analysis
cargo run --example 07_recognized_text
cargo run --example 08_barcode
cargo run --example 09_recognized_item

See COVERAGE.md for the audited VisionKit API matrix.

License

Licensed under either of Apache-2.0 or MIT at your option.