All examples
Video and vision

Connect video to a native CNN

Run an explicitly random small CNN on prepared synthetic frames to demonstrate shape and dtype compatibility.

vision_cnn.aner
// Random CNN weights demonstrate integration, not recognition accuracy.
import aner.video
import aner.vision
import aner.nn
import aner.tensor

let source = video.synthetic(width: 32, height: 24, frames: 3)
let frame = video.frame_slot()
let plan = vision.preprocess(width: 16, height: 16)
let input = vision.input_slot(plan)
let model = nn.cnn(channels: 3, height: 16, width: 16, seed: 42)
    .conv2d(outputs: 4, padding: 1).relu()
    .head(classes: 2).on(device: "cpu", precision: "Float32").prepare()
while source.read_into(frame) == "ready" {
    plan.prepare_into(frame, input)
    let scores = model.logits(input.tensor())
    print(tensor.rows(scores))
    print(tensor.cols(scores))
    print(input.sequence())
}
source.close()

Make it your experiment.

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

Terminal
aner check examples/vision_cnn.aner
aner run examples/vision_cnn.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_cnn.aner
aner run examples/vision_cnn.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