telegenic
Pure-Rust GenICam camera library.
Transports are pluggable backends behind the feature layer. The only backend
today is GigE Vision (telegenic::gige): GVCP (control) and GVSP (stream)
spoken directly over UDP — no vendor SDK, no GenTL producer. USB3 Vision can
slot in later without touching the feature API.
use ;
let mut cam = new; // no I/O, infallible
cam.connect?; // dial, take control, load the feature model
cam.set_float?;
cam.set_enum?;
// One frame on demand — zero stream bandwidth between captures:
let frame = cam.snap?;
println!;
// Or continuous acquisition. The guard subscribes before the camera
// starts (so even the first frame is delivered) and stops it on drop:
let acq = cam.start_acquisition?;
while let Some = acq.wait_for
acq.stop?; // or just drop it
cam.disconnect; // or just drop it
# Ok::
Cameras are plain owned values with an explicit lifecycle: construction is
free, connect(&mut self) is where I/O happens (and doubles as the
reconnect path after a dropped link), disconnect/drop releases device
control, and per-connection state — identity, capabilities, the GenICam
model, stats — lives exactly as long as the connection. Worker-facing
methods return Disconnected while no link is up.
Layers
GenICamera: the GenICam feature layer and the type most users hold. String-keyed typed feature access over the node graph from the device's XML (zipped or plain), Converter/SwissKnife formula evaluation, register caching with pInvalidator handling, and acquisition tied together for you:start_acquisitionreturns an RAII guard for continuous streaming,snap/snapshot_sessioncapture single frames on demand with the camera idle between shots. Both guards borrow the camera mutably, so stopping is automatic and disconnecting mid-acquisition cannot compile.gige: the GigE Vision backend.gige::discovery: broadcast device discovery per network adapter, plus Force IP for repointing a camera whose address doesn't match the local subnet (examples/discover.rs,examples/force_ip.rs).gige::GigECamera: the GVCP transport: register/memory IO as [ResponseHandle]s (syncwait_timeoutorawait), automatic heartbeat, pending-ack handling, retries, message-channel events, andopen_streamfor raw GVSP channels.gige::stream: per-channel GVSP receiver on its own thread: preallocated buffer pool (zero allocation per packet/frame at steady state), out-of-order reassembly, packet-resend requests, automatic packet size negotiation, frames fanned out asArc<Frame>over bounded channels with drop-on-full.
Python
The same library ships as a Python package (PyO3/maturin, py feature;
pip install telegenicam once published, or maturin develop from a
checkout. The import name stays telegenic). The GenICam surface maps one-to-one, every blocking call
releases the GIL, and frames expose their pixels as bytes for
numpy.frombuffer:
=
# camera idle between snaps
=
# stops the camera again on exit
=
telegenic.discover() finds cameras on the local subnets. Type stubs and
docstrings ship in the package (telegenic/__init__.pyi).
Examples
Testing
cargo test runs everything against an in-process fake camera over loopback
UDP (tests/fake_camera/): GVCP semantics (retries, pending-ack, control
loss), discovery/force-IP, GVSP reassembly under loss/reordering/duplication
with resend replay, GenICam evaluation against the real Hikrobot and Imperx
vendor XMLs in tests/data/, and the full GenICamera path including
message-channel events and single-frame snapshots.