HUB
Sign inSign up
camera logo

husarion/camera

By husarion

•Updated 2 days ago

ROS 2 UVC camera node for Husarion robots: H.264, MJPEG or raw frames plus Opus audio.

Image
0

10K+

husarion/camera repository overview

⁠husarion/camera

A ROS 2 UVC camera node for Husarion⁠ robots. It opens a USB camera through V4L2 and publishes H.264, MJPEG or raw frames on ROS 2 topics, plus optional Opus listen-in audio. H.264 and MJPEG that the camera encodes itself pass straight through. A raw capture is re-encoded on the host to H.264 and MJPEG; H.264 needs a hardware encoder (VAAPI, NVENC or v4l2m2m), and without one you get MJPEG or raw (see the hardware acceleration guide below). The node can also take an upstream ROS image or H.264 topic (an OAK, for example) and re-wrap or re-encode it.

Multi-arch: linux/amd64 + linux/arm64.

⁠Tags

  • husarion/camera:X.Y.Z: pinned production tag (recommended)
  • husarion/camera:latest: tracks the most recent release

Each X.Y.Z is one snapshot validated on Husarion hardware. The Tags tab above lists every version.

⁠Quick start

services:
  camera:
    image: husarion/camera:X.Y.Z   # a version from the Tags tab
    network_mode: host
    ipc: host
    env_file:
      - /home/husarion/config/common/.env   # ROS_DOMAIN_ID, RMW, namespace
    environment:
      - CAMERA_DEVICE=/dev/video0
      - CAMERA_FORMAT=h264
      - CAMERA_WIDTH=1920
      - CAMERA_HEIGHT=1080
      - CAMERA_FPS=30
    devices:
      - /dev/snd:/dev/snd
      # /dev/dri only on hosts that have a Mesa userspace render node
      # (Intel / AMD desktops, NVIDIA via the container toolkit). Pi
      # 4 has no /dev/dri — listing it makes Docker reject the
      # service on start. See "Hardware video acceleration" below.
      - /dev/dri:/dev/dri
    volumes:
      - /dev:/dev
    device_cgroup_rules:
      - "c 81:* rmw"   # V4L2
      - "c 116:* rmw"  # ALSA
    group_add: ["video", "audio"]
    restart: unless-stopped

⁠Topics and services

Frames:

  • ~/image_raw/h264: foxglove_msgs/CompressedVideo (H.264, from native h264 capture and from the raw-mode re-encode alike)
  • ~/image_raw/compressed: sensor_msgs/CompressedImage (MJPEG)
  • ~/image_raw: sensor_msgs/Image (raw passthrough, published only while something subscribes)
  • ~/image_raw/h264/parameter_sets: the SPS+PPS sidecar (native h264 mode only; raw mode puts them in-band)

Audio (optional): ~/audio (Opus) and the latched ~/audio_info.

Latched state: ~/capabilities, ~/active_mode, ~/connected, ~/camera_info.

Services: ~/set_format, ~/set_mmap_buffers, ~/pan/set, ~/tilt/set, ~/zoom/set, ~/ptz/home.

~ is the ROS namespace the container runs in, set with the ROS_NAMESPACE env var.

⁠Configuration

The env vars you will reach for most:

VarDefaultNotes
CAMERA_DEVICE(empty)V4L2 device path. Empty means the first capture device found, including one plugged in later.
CAMERA_FORMATh264h264 / mjpeg / raw (initial mode only; change it at runtime with ~/set_format)
CAMERA_WIDTH × CAMERA_HEIGHT × CAMERA_FPS1920×1080@30Initial mode only
CAMERA_AUDIO_DEVICEunsetSet to e.g. plughw:CARD=GUV3100,DEV=0 to turn on audio listen-in. Empty means no audio.
CAMERA_ENCODERautoThe in-process re-encoder for raw mode. auto walks H.264 h264_vaapi → h264_nvenc → h264_v4l2m2m (hardware only, no software H.264) and MJPEG mjpeg_vaapi → mjpeg_qsv → mjpeg_v4l2m2m → mjpeg. Pin a concrete name (h264_vaapi, h264_v4l2m2m, …) to override.
CAMERA_ENCODER_VAAPI_DEVICE(libav default)Path to the VAAPI render node (e.g. /dev/dri/renderD128).
ROS_NAMESPACE/Standard ROS 2; the node publishes everything under it.

⁠Hardware video acceleration

A camera that encodes H.264 itself (the GUV3100 and similar) sends frames the node passes through bit for bit: no encoder runs and no host GPU is needed. Hardware acceleration matters only in raw mode, where the camera sends uncompressed YUYV or NV12 and the node re-encodes to H.264 or MJPEG inline, or when you switch a native H.264 camera to a resolution it cannot capture natively.

CAMERA_ENCODER=auto probes the hardware paths in priority order when the first browser subscribes and logs the choice (encoder selected: h264_v4l2m2m (h264) …). If auto reports no HARDWARE H.264 encoder available although the hardware is there, the host setup below is incomplete.

⁠Intel / AMD x86 hosts: VAAPI
volumes:
  - /dev:/dev
devices:
  - /dev/dri:/dev/dri
group_add: ["video"]

With that, auto picks h264_vaapi on /dev/dri/renderD128. If you have several render nodes, set the path with CAMERA_ENCODER_VAAPI_DEVICE.

⁠Raspberry Pi 4: V4L2 M2M (bcm2835-codec)

The Pi 4's stateful M2M H.264 encoder is at /dev/video11. It appears only when the firmware loads the full VideoCore image; by default Raspberry Pi OS loads the cut-down image, which has the codecs stripped.

# On the host:
sudo sed -i 's/^gpu_mem=16$/gpu_mem=128/' /boot/firmware/config.txt
sudo reboot
# After reboot:
ls /dev/video11                          # must exist
v4l2-ctl --list-devices | grep codec     # bcm2835-codec-encode at /dev/video11

In your compose service, leave out /dev/dri: the Pi 4 has no Mesa userspace render node, and listing it makes Docker reject the container with "no such file or directory". The wide /dev:/dev bind mount and the c 81:* rmw cgroup rule are enough to expose /dev/video11 to the encoder, and auto picks h264_v4l2m2m.

If the log still says no hardware H.264 encoder is available while /dev/video11 exists, bcm2835-codec has refused the output format for that width, height and FourCC. Pin CAMERA_ENCODER=h264_v4l2m2m and try CAMERA_RAW_FOURCC=YUYV.

⁠NVIDIA x86 (desktop / workstation): NVENC

Install nvidia-container-toolkit⁠ on the host, then in compose:

deploy:
  resources:
    reservations:
      devices:
        - driver: nvidia
          capabilities: [video, compute]

auto picks h264_nvenc. You can keep /dev/dri:/dev/dri here too, which leaves VAAPI on the integrated GPU available as a fallback.

⁠NVIDIA Jetson: V4L2 M2M

Jetson devices expose the hardware encoder through V4L2 M2M (/dev/nvhost-msenc and the nvv4l2encoder GStreamer element). The FFmpeg bundled in the camera image can use it through h264_v4l2m2m when the device nodes are passed through:

volumes:
  - /dev:/dev
runtime: nvidia    # if the host has nvidia-container-runtime configured
group_add: ["video"]

Pin CAMERA_ENCODER=h264_v4l2m2m if auto does not pick it. The priority list tries h264_nvenc first, which on a Jetson needs a CUDA runtime that is not always available inside the container.

Jetson support is best effort. If your model finds no hardware encoder, file an issue with the encoder probe log and we will look into it.

⁠No hardware encoder means no H.264

The image has no software H.264 encoder. A camera that only delivers raw frames, on a host without a usable hardware encoder (a Pi 4 without gpu_mem=128, a Raspberry Pi 5), serves MJPEG or raw. For an H.264 stream on such a host, use a camera that captures H.264 itself (CAMERA_FORMAT=h264).

⁠About

Built and maintained by Husarion⁠, robotics research and commercial UGV platforms. Husarion robots get this image through their OS images, which pin it by digest.

License: proprietary. © Husarion S.A., all rights reserved.

Tag summary

Content type

Image

Digest

sha256:0103918f7…

Size

387.5 MB

Last updated

2 days ago

docker pull husarion/camera