All examples
Video and vision

Prepare video for numerical models

Resize and normalize RGB frames into detached CPU Float32 NCHW tensors with reusable native input storage.

vision_preprocess.aner
// Native RGB -> Float32 NCHW; immutable plan, reusable input storage.
import aner.video
import aner.vision
import aner.tensor
import aner.nn
import aner.ml

let source = video.synthetic(width: 160, height: 90, frames: 3)
let frame = video.frame_slot()
let plan = vision.preprocess(width: 32, height: 32, resize: "letterbox")
let input = vision.input_slot(plan)
while source.read_into(frame) == "ready" {
    plan.prepare_into(frame, input)
    print(tensor.rank(input.tensor()))
    print(tensor.dim(input.tensor(), 2))
    print(tensor.dim(input.tensor(), 3))
    print(tensor.cols(input.features()))
    print(input.sequence())
}
source.close()

// Synthetic one-row KNN round trip: explicit Float64 feature copy.
// Fitting and querying the same fixture demonstrates interoperability only;
// this is not held-out evaluation or evidence of recognition quality.
let features = input.features().astype("Float64")
let labels: Tensor = [[0.0]]
let neighbors = ml.fit_knn(features, labels, k: 1)
let predicted = neighbors.predict(features)
print(tensor.item(predicted))

Make it your experiment.

Use Aner 0.1.0 or newer. Save this program as examples/vision_preprocess.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/vision_preprocess.aner
aner run examples/vision_preprocess.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires Aner 0.1.0 or newer. Synthetic capture and CPU vision examples need no external source; cameras, remote media and encoded recording require optional FFmpeg support and explicit inputs. Checking opens no camera, network connection or recording.

Credential setup
aner check examples/vision_preprocess.aner
aner run examples/vision_preprocess.aner

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner