DeveloperReference
Code samples
What ships in the package, what each one actually does, and which ones need something that has not shipped yet.
In the package
viewer module
A runnable window with keys for exposure, gain and the illuminator, plus frame saving. All three reach the image on this camera (measured with the earlier Python implementation; with the Rust implementation exposure and gain were written and read back, and of the three, only the illuminator's effect was measured again, once — one unit, 2026-12-03). Turning the illuminator on from 0 in an open camera was not shown: 96 written over 0 read back 96 and the image did not change in that open (a later open was lit). Verified against the synthetic source. Its s key (a left/right PNG pair): verified ①; the rest of the live-camera path has not been signed off yet. --read-only (0.0.11): writes no camera control; always on on Linux; run without a camera only.
examples/ — 21 Python scripts, 17 Rust examples
In the repository rather than the package: run them from a checkout after installing the package. Each example is one file. Ten: quickstart, live preview, stereo pairs to PNG, video recording, listing controls, setting exposure and gain once, the illuminator level, measuring the frame rate, saving frames to .npz, and a PyTorch DataLoader over that file (needs torch). All but quickstart.py run with no camera: most take --synthetic, and torch_dataloader.py and play_recording.py need no camera at all. For what has been run with the camera, see the table below.
Six examples added in 0.0.4
list_devices.py (the video devices Windows reports, and how many are a Weevia S1), threaded_capture.py (reads on one thread, processes the latest frame on another), brightness_stats.py (per-eye mean, min, max and share of saturated pixels into a CSV), handle_stall.py (on DeviceError: close, ask for the USB cable to be re-inserted, reopen), calibration_info.py (prints the installed calibration) and play_recording.py (reads a video written by record_video.py back through Device). For what has been run with the camera, see the table below.
Two examples added in 0.0.5
presets.py (saves every control to a preset and loads it back; loading writes in one set_many() call) and calibration_check.py (checks in numbers whether a calibration file fits the camera). Both have been run without a camera only.
Added in 0.0.6
open_by_usb_location (Python and Rust): opens the camera at a USB location and reads one frame; run with the camera once, one camera connected, not run with two. Rust record_video and play_recording: run with the camera once. (One PC, one camera, 2026-11-25.) Rust calibration_info: run without a camera only.
Added in 0.0.7
export_recording (Python and Rust): writes a recording as left/right image pairs (Python PNG, Rust PGM), pairs.csv and capture_info.json. From an MJPG recording the images hold what it decodes to, not the camera's pixel values. Run with generated recordings; the Python example also with a camera recording once on Linux, from source before release. From Windows camera recordings (Python: MJPG and FFV1; Rust: MJPG): verified ① (Rust: the crates.io 0.0.7 source). On Linux: verified on one setup only (one Weevia S1 unit, Ubuntu 26.04.1, x86_64, USB connected directly, the published 0.0.10 wheel and crate, two USB re-insert cycles, 2026-12-02; which lens was covered is the operator's statement). Not verified: a second unit, a direct USB connection on Windows.
Added in 0.0.8
Rust: quickstart (no window: prints the mode, reads 100 frames and prints the rate, saves the last pair as PGM), brightness_stats (the CSV columns of brightness_stats.py), capture_dataset (no .npz: PGM pairs, pairs.csv and capture_info.json) and presets (saves a preset, plans what loading it would change, lists them; applying one to the camera is not there yet). New option: list_devices --synthetic --backend v4l2 (Python and Rust); run without a camera only (made-up devices). quickstart, brightness_stats, capture_dataset and presets (saving, and --plan): run with the camera once on Windows (one PC, one camera, 2026-11-26, from the 0.0.8 source); a preset load that changes values: not run.
Added in 0.0.9
Rust measure_fps -- --csv FILE (off by default): one row per frame read() returned — index, host_ns, whether each eye is byte-identical to the frame before, and its largest pixel value. Run with the camera in two USB re-insert cycles (one PC, one camera, 2026-11-26), from this release's source before release.
Changed in 0.0.10
record_video (Python and Rust) prints estimated missed N; dropped by the write queue M — two separate counts; read them separately. Rust record_video and play_recording: on Windows verified in two USB re-insert cycles (one Weevia S1 unit, Windows 11, one PC, two-level USB hub, from the 0.0.10 source before release, 2026-11-26 and 2026-11-29); the write queue dropped 14 and 31 frames (cause not established). Measured with the single encoding thread before 0.0.11 added several; not re-measured with the camera yet. Not verified: pausing, a direct USB connection on Windows, a second unit. On Linux: verified on one setup only (one Weevia S1 unit, Ubuntu 26.04.1, x86_64, USB connected directly, the published 0.0.10 wheel and crate, two USB re-insert cycles, 2026-12-02).
Added in 0.0.11
lerobot_record.py: both eyes into a LeRobot dataset (format v3.0; checked with lerobot 0.7.0), one episode, through the official lerobot package (needs lerobot). Not run with the camera yet: checked only by converting generated recordings. Whether it keeps up with the camera's 90 fps has not been checked; to keep every frame, record with record_video.py first and convert the recording with --recording. Rust: presets -- --load FILE applies a preset (Controls::load_preset); run without a camera only.
synthetic source
Drives the viewer with generated frames, so the capture path runs with no camera attached. This is the part to use while you wait for hardware — the Quickstart steps still need a real camera.
Run record by example (Python)
| Example | Windows, camera | Linux, one camera | Without a camera |
|---|---|---|---|
| quickstart.py | — | Not run | Needs a camera |
| live_preview.py | — | Not run | Runs |
| save_stereo_pairs.py | 2D export verified ① | Verified on one setup (2026-12-02) | Runs |
| record_video.py | MJPG and FFV1: verified with the 0.0.11 wheel on one setup (2026-12-04) | Verified on one setup (2026-12-02) | Runs |
| list_controls.py | Verified with the 0.0.11 wheel on one setup (2026-12-04) | Once (2026-11-25) | Runs |
| set_controls_once.py | Earlier Python implementation: measured. Rust implementation: exposure and gain written and read back (one unit, 2026-12-03; not with this example) | Not run | Runs |
| led_level.py | Earlier Python implementation: measured. Rust implementation: 24, 16 and 0 read back, 24 lit (one unit, one open, 2026-12-03; not with this example). Turning the illuminator on from 0 in an open camera was not shown: 96 written over 0 read back 96 and the image did not change in that open (a later open was lit). | Not run | Runs |
| measure_fps.py | --backend msmf: printing driver times verified on one setup with the 0.0.11 wheel (2026-12-04); through this path they do not show when a frame arrived | Once (2026-11-25) | Runs |
| capture_dataset_npz.py | 2D export verified ① | Verified on one setup (2026-12-02) | Runs |
| torch_dataloader.py | — | Not run | No camera needed |
| list_devices.py | DirectShow list: once (one PC, one camera, 2026-11-25, the 0.0.6 code); --backend msmf and --verbose: two USB re-insert cycles (one Weevia S1 unit, one PC, 2026-11-25, the published 0.0.7 wheel) | Not run | Runs |
| threaded_capture.py | Not run | Not run | Runs |
| brightness_stats.py | Not run | Not run | Runs |
| handle_stall.py | Not run | Not run | Runs |
| calibration_info.py | Not run | Not run | Runs |
| play_recording.py | Reading back, seeking, looping verified ① and with the 0.0.11 wheel; real time and --speed 2 ran without an error (the pace was not timed) on one setup (2026-12-04) | Reading back: verified on one setup (2026-12-02) | No camera needed |
| presets.py | Not run | Not run | Runs |
| calibration_check.py | Not run | Not run | Runs |
| open_by_usb_location.py | — | Once (2026-11-25) | Runs |
| export_recording.py | From camera recordings (MJPG, FFV1) verified ① | Verified on one setup (2026-12-02) | Run with generated recordings |
| lerobot_record.py | Not run | Not run | Run with generated recordings |
- —: not listed in this table (see each page).
- For recording and reading back, verified in this table (①, the 0.0.11 wheel, Linux) means the files were written and read back with the same frame count — not that both eyes showed the scene in every recording.
- 2D export not verified: a second unit, a direct USB connection on Windows, the viewer's s key on Linux. On Linux, save_stereo_pairs.py and capture_dataset_npz.py: verified on one setup only (one Weevia S1 unit, Ubuntu 26.04.1, x86_64, USB connected directly, the published 0.0.10 wheel and crate, two USB re-insert cycles, 2026-12-02).
① Verification conditions: the published 0.0.7 wheel, one Weevia S1 unit, Windows 11, one PC, two-level USB hub, two USB re-insertions, read-only.
# no camera on your desk yet — run the whole path on generated frames
python -m opticmix_vision.viewer --synthetic
# with the camera plugged in and the wheel installed, in the python/ folder of a checkout of the repository:
# finds the Weevia S1 by name, reads 100 frames and prints the frame rate
python examples/quickstart.py --no-windowTutorials
Eight short tutorials, in order, built on the examples above, and a page on the viewer and the explorer. New to the camera? Do 1 → 2 → 3. Every page ends with a Rust section (the cargo run command for each step that has a Rust example). The output they show is from --synthetic (generated frames): it shows that the code runs and says nothing about the camera. They are in the SDK repository, pinned to the v0.0.11 tag; check out the tag of the version you installed before running the commands.
- 01 · Hello Weevia
- 02 · Live view and frame rate
- 03 · Saving frames
- 04 · Recording and playback
- 05 · Camera controls
- 06 · IR illuminator
- 07 · Robust capture
- 08 · Calibration file
- Viewer and explorer
A note on what is missing
There are no rectification or depth samples here. Those parts are not in the published package; samples will be added once they are verified end to end on real hardware. The two calibration examples — calibration_info.py (prints an installed calibration file) and calibration_check.py (shows in numbers how well a calibration file fits the camera, added in 0.0.5) — have been run without a camera only.
