Skip to main content

Crate visual_cortex

Crate visual_cortex 

Source
Expand description

Scry: watch screen regions and receive typed events when patterns match.

Modules§

patterns
Text parsers for OCR output. Used with WatcherBuilder::ocr.

Structs§

Brightness
Mean luma (0.0..=255.0) of the region, as DetectorOutput::Number. Pair with .on_threshold(...) for “screen went dark”-style watchers.
ColorDominance
Boolean detector/gate: at least min_fraction of pixels are dominated by one channel (e.g. “the HP bar area is mostly red”).
ColorMatch
Boolean detector/gate: at least min_fraction of the region’s pixels are within tolerance (per channel) of the target RGB color.
Event
An event emitted by a watcher.
EventStream
An async stream of events for one or more watchers. All session events flow through one broadcast channel; each EventStream filters to its subscribed watcher names, so merge is just a name union.
FakeSource
A scripted FrameSource for tests and demos: yields its frames in order, then repeats the final frame forever.
Frame
A single captured frame in BGRA8 layout, row-major, stride = width * 4.
FrameDiff
Boolean gate: did the region’s pixels change since the last evaluation? Hashes the region’s bytes; the first evaluation always reports changed.
FrameView
A borrowed rectangular view into a frame. Zero-copy; rows are slices of the frame.
OcrDetector
Adapts any OcrEngine into a Detector.
PxRect
A resolved, pixel-space rectangle, guaranteed in-bounds by Region::resolve.
Rate
How often a watcher evaluates, or a source captures. Stored as a period.
Session
A capture session: owns the frame source, the capture loop, and all watcher tasks. Dropping the last Session handle stops everything.
SessionBuilder
TemplateMatcher
Grayscale normalized cross-correlation template matcher.
TextSpan
One recognized text region. bbox is relative to the evaluated view.
WatcherBuilder
Configures one watcher. Created via Session::watch; consumed by subscribe.

Enums§

CaptureError
Channel
A primary color channel, for ColorDominance.
DetectorError
DetectorOutput
What a detector produced this tick.
Error
EventKind
Region
A watch region. Fractional (Percent) regions survive resolution changes; validation happens at resolve time against actual frame dimensions.
Target
What to capture: a display by index, or a window matched by exact title.
ThresholdDirection

Traits§

Detector
Evaluates one region of one frame. Built-in detectors, gates, and user-defined detectors all implement this same trait.
FrameSource
A source of frames. The session’s capture loop calls capture_frame at the session’s capture rate; implementations should return the freshest frame available. Real backends (scap) arrive in a later milestone.
OcrEngine
Pluggable OCR backend. The default ONNX/PaddleOCR implementation lives in the visual-cortex-ocr-onnx crate; any engine can slot in here. Returning an empty vec means “no text present” and is not an error.

Functions§

from_fn
Build a detector from a closure: from_fn(|view| Ok(DetectorOutput::Bool(true))).

Type Aliases§

Result