A Membrane.Source that reads from a BB camera.
Membrane's demand maps one-to-one onto BB.Camera.request/1, so a pipeline
exerts real backpressure on the camera and nothing accumulates outside it.
The element asks the hub for a frame for each buffer the pipeline demands,
and the hub holds one frame regardless, so a pipeline that falls behind sees
current frames rather than a growing backlog.
import Membrane.ChildrenSpec
child(:camera, %BB.Camera.Membrane.Source{robot: MyRobot, camera: :eye})
|> child(:sink, %Membrane.Testing.Sink{})Format
The output pad carries Membrane.RawVideo, the standard format struct, so
downstream Membrane elements - a scaler, a pixel format converter, an
encoder - interoperate without a shim. The element re-emits it whenever the
camera renegotiates its geometry - the camera tells consumers before the
first frame produced the new way, so the format a downstream element holds
always matches the buffer it is about to receive.
Each buffer is one whole frame, so the format is aligned: true.
framerate is nil: a camera's rate is nominal at best, and every buffer
carries a pts, which is what Membrane.RawVideo asks for instead.
Timestamps
pts is nanoseconds since the first frame of this element's session, not
raw monotonic time - System.monotonic_time/1 is routinely a large negative
number, and a pipeline that starts its timeline there is one subtraction away
from nonsense. The untouched capture timestamps are preserved in
metadata.bb_camera for anything that needs to correlate a buffer with the
rest of the robot's telemetry.
Element options
Passed via struct BB.Camera.Membrane.Source.t/0
robotmodule()Required
The robot module the camera is declared oncameraatom()Required
The camera's sensor nameend_of_stream_on_capture_end?boolean()Default value:
true
Whether a cleanly ended capture ends the stream. Withfalse, the element stays in place and resumes if capture restarts.
Pads
:output
Accepted formats:
%RawVideo{aligned: true}| Direction: | :output |
| Availability: | :always |
| Flow control: | :manual |
| Demand unit: | nil |
Summary
Types
Struct containing options for BB.Camera.Membrane.Source
Types
@type t() :: %BB.Camera.Membrane.Source{ camera: atom(), end_of_stream_on_capture_end?: boolean(), robot: module() }
Struct containing options for BB.Camera.Membrane.Source
Functions
@spec options() :: keyword()
Returns description of options available for this module