Expand description
Optional vision layer: raster plus ONNX runner (#636). Off by default. Optional vision layer: page raster plus ONNX runner (#636).
Behind the vision cargo feature (off by default). No trained model ships;
a separate team plugs models in later. This module is infrastructure only:
rasterize_page_with_dpirenders a page through the engine’s existing renderer (crate::PdfDocument::render_page) and converts the RGBA output to grayscale or RGB bytes. No new renderer.VisionRunnerloads an ONNX model from bytes or a path withtract-onnx(MIT OR Apache-2.0) and runs it on aVisionRasteror on a crop named by a bbox in page points, returning the output tensor asVisionOutput.
Input tensors are NCHW f32 in 0.0..=1.0 (bytes divided by 255). Output is
the model’s first output, which must be f32.
Structs§
- Vision
Output - The output tensor of one model run: shape plus row-major
f32data. - Vision
Raster - A page (or crop) rasterized for vision input, row-major.
- Vision
Runner - An ONNX model loaded from bytes or a path, runnable on a
VisionRaster.
Enums§
- Vision
Error - Errors from the vision layer.
- Vision
Pixel Format - Pixel layout of a
VisionRaster.
Constants§
- DEFAULT_
VISION_ DPI - Default rasterization resolution for vision input, in dots per inch.
Functions§
- rasterize_
page - Rasterize a page to a grayscale or RGB buffer at
DEFAULT_VISION_DPI. - rasterize_
page_ with_ dpi - Rasterize a page to a grayscale or RGB buffer at the given dpi.
Type Aliases§
- Vision
Result - Convenience alias for vision operations.