Files
dora-webcam/dora-node.yml
T
cristhian dc3960809a
validate / validate (push) Successful in 59m16s
build with uv, and preview locally instead of a second dataflow
The build command was `pip install .`, which is what upstream and the dora docs
use because `--uv` rewrites it. Spelling it `uv pip install .` means the
dataflow never installs through pip at all, whether or not `--uv` was passed.
The cost is that the node then needs a virtualenv to install into, so it must
be run with `--uv`; the README says so.

The second dataflow is gone. It existed to wire this node into dora-image-view
just to see the frames, which pulled another repository over the network and
needed a tag there. PREVIEW=true now opens a local window of the frames as they
are published, so checking a camera, an encoding or a flip needs this
repository alone. It shows the frame after the flip and the resize, so what is
on screen is what is sent, and it never opens under CI, where there is no
display.

That a source node can display its own output overlaps with what a viewer node
does. The overlap is the point: the alternative was a second repository in the
loop before you can tell whether a camera works.
2026-09-15 06:09:12 -03:00

91 lines
3.1 KiB
YAML

# Node manifest: the typed contract a consumer wires against.
#
# No source package is shared between node repositories, so this file and its
# type URNs are the only contract a consumer has. `dora validate` checks a
# dataflow against it without running the node, so CI needs neither a camera nor
# OpenCV.
apiVersion: 1
name: dora-webcam
namespace: liria
description: Captures frames from a webcam and publishes them as std/media/v1/Image
categories: [sensor]
keywords: [opencv, camera, webcam, video, capture, image, v4l2]
runtime: python
entrypoint: dora-webcam
# Run the dataflow with --uv, which gives the node its own managed venv under
# `.dora/python-envs/`, so what it imports at runtime is what was installed
# here. Without --uv this needs a virtualenv to install into.
build: uv pip install .
dora: ">=1.0"
inputs:
tick:
required: true
description: >-
Reads and publishes one frame. Wire to dora/timer/millis/N. The node stops
when this input closes.
outputs:
image:
type: std/media/v1/Image
description: >-
Captured frame as an Arrow struct {width, height, encoding, data}. For a
compressed encoding, width and height are the image's dimensions rather
than the length of data, so a receiver can size a buffer without decoding
first.
env:
CAMERA_ID:
description: >-
Substring of an entry in /dev/v4l/by-id/. Stable across reboots and across
which USB port the camera is in, unlike an index, so it takes precedence
over CAPTURE_PATH. Linux only.
CAPTURE_PATH:
default: "0"
description: Device path such as /dev/video1, or an index. A numeric string is read as an index.
IMAGE_WIDTH:
type: int
description: Requested capture width; frames are also resized to it. Defaults to the camera's native width.
IMAGE_HEIGHT:
type: int
description: Requested capture height; frames are also resized to it. Defaults to the camera's native height.
ENCODING:
default: bgr8
description: One of bgr8, rgb8, yuv420, jpeg/jpg/jpe, png, bmp, webp.
JPEG_QUALITY:
type: int
default: 95
description: Quality 0-100, used only by the JPEG encodings.
FLIP:
description: Flip the frame. One of VERTICAL, HORIZONTAL or BOTH. Unset means no flip.
PREVIEW:
type: bool
description: >-
Open a local window showing the frames as they are published, so a camera
can be checked without wiring a viewer. Press q to stop the node. Ignored
under CI, where there is no display.
CAPTURE_FRAMES:
type: int
default: 0
description: >-
Stop after this many frames. 0, the default, runs until the tick input
closes. A positive count is what lets a test run the dataflow to
completion rather than killing it on a timeout.
CI:
type: bool
description: >-
When true, a failed read publishes a labelled black frame instead of
raising, which is what lets the dataflow run on a machine with no camera.
example: |
- id: camera
git: ssh://git@gitea.liria.cl:5001/liria/dora-webcam.git
tag: v0.1.0
build: uv pip install .
path: dora-webcam
inputs:
tick: dora/timer/millis/33
outputs:
- image