Skip to content

Debugging the Camera

There are two scripts in the icarus/scripts directory to help you debug cameras.

camera.py

Usage
uv run scripts/camera.py -d <dev_name>

Parameters

  • -d, -device: Camera device path (e.g., /dev/video0)

Description
Retrieves and displays comprehensive information about V4L2 camera devices connected to the Icarus system. It should be mainly used as a tool for troubleshooting camera compatibility issues, configuring camera settings, and verifying that a camera meets the requirements for use with Icarus.

When executed, the script uses the V4L2 control utilities to query the specified camera device and reports three key categories of information:

  • Device Capabilities: Shows general camera information including driver details, camera model, bus information, and supported features
  • Supported Formats: Lists all video formats, resolutions, and frame rates the camera can provide
  • Available Controls: Displays all adjustable camera parameters such as exposure, brightness, and contrast

This information is particularly useful when:

  • Setting up a new camera with Icarus: Ensure that dev_name reflects the right device path.
  • Debugging camera-related recording issues
  • Determining optimal camera settings for motion detection:
  • Verifying that a camera supports required formats:
    In icarus/app/internal/video/segments_producer.py, parameters in the cmd list in the start_segment_ffmpeg() function can be changed using this scripts provided info.
    • MJPEG input format
    • Resolution
    • Framerate
    • Pixel format

Example
uv run scripts/camera.py -d /dev/video0

Camera information for /dev/video0

DEVICE CAPABILITIES

Driver Info:
    Driver name      : uvcvideo
    Card type        : HD Pro Webcam C920
    Bus info         : usb-0000:00:14.0-1
    Driver version   : 5.15.0
    Capabilities     : 0x84a00001
        Video Capture
        Metadata Capture
        Extended Pix Format
        Device Capabilities
    Device Caps      : 0x04200001
        Video Capture
        Extended Pix Format


SUPPORTED FORMATS

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)


AVAILABLE CONTROLS

    exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=1
    exposure_absolute 0x009a0902 (int)    : min=3 max=2047 step=1 default=250 value=333
    brightness 0x00980900 (int)    : min=0 max=255 step=1 default=128 value=128

record.py

Usage
uv run scripts/record.py -d <dev_name> -t <time> -seg <segment_duration> -th <threshold> -med <min_event_duration> [-s]

Parameters

  • -d, -device: Camera device path (e.g., /dev/video0)
  • -t, -time: Total recording duration in seconds
  • -seg, -seg_duration: Duration of each segment in seconds
  • -th, -threshold: Motion detection threshold (0-255)
  • -med, -min_event_duration: Minimum event duration in seconds
  • -s, -send: Optional flag to send detected events to server

Description
This script provides a standalone testing environment for the Icarus video recording and event detection pipeline. It's designed for debugging, development, and testing changes without affecting the main application.

The script implements the full video processing pipeline:

  1. Video Recording: Uses FFmpeg to record video from the specified camera in fixed-duration segments
  2. Motion Detection: Analyzes segments for motion using OpenCV
  3. Event Detection: Creates clip files when motion is detected
  4. Server Integration: Optionally sends events to a server endpoint

This utility is particularly useful for:

  • Testing new camera hardware compatibility
  • Tuning motion detection parameters
  • Debugging issues with the event detection algorithm
  • Testing changes to the recording pipeline
  • Simulating the full recording process in isolation

Example
uv run scripts/record.py -d /dev/video0 -t 60 -seg 10 -th 25 -med 2 -s

This will:

  1. Use the camera device at path /dev/video0
  2. Record 60 seconds of video in 10-second segments
  3. Detect events with a threshold of 25
  4. Create events lasting at least 2 seconds
  5. Send created events to the server
  6. Print logs to stdout for the user to see what is happening