All examples
Video and vision

Capture a local camera

Discover backend devices, select a camera locator and distinguish read timeouts from terminal input states.

video_camera.aner
// Checking opens no camera. Running requires FFmpeg and OS camera permission.
// Replace "default" with an explicit backend locator after discovery.
import aner.video

print(video.available())
print(video.camera_backend())
print(video.devices())
let source = video.camera(device: "default", width: 640, height: 480, fps: 30.0)
let frame = video.frame_slot()
var count = 0
var waits = 0
var active = true
while count < 30 && waits < 10 && active {
    let status = source.read_into(frame, timeout_ms: 1000)
    if status == "ready" {
        print(frame.width())
        print(frame.height())
        print(frame.sequence())
        count += 1
    } else if status == "timeout" {
        waits += 1
    } else {
        print(status)
        print(source.error())
        active = false
    }
}
print(source.dropped())
source.close()

Make it your experiment.

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

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