Skip to content

[Tiny] Add Webcam demo#977

Merged
spomichter merged 6 commits intodevfrom
jeff_add_webcam_demo
Jan 13, 2026
Merged

[Tiny] Add Webcam demo#977
spomichter merged 6 commits intodevfrom
jeff_add_webcam_demo

Conversation

@jeff-hykin
Copy link
Member

  • dimos run demo-camera

@jeff-hykin jeff-hykin requested a review from a team January 12, 2026 03:17
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Greptile Overview

Greptile Summary

This PR adds a webcam demo feature accessible via dimos run demo-camera along with several code quality improvements.

Key Changes

Core Feature:

  • Adds demo_camera blueprint in camera/module.py using autoconnect() to create a standalone webcam demo
  • Registers the blueprint in all_blueprints.py to enable the demo-camera command

Bug Fixes:

  • MuJoCo Image Format Fix: Corrects a color channel bug in mujoco_connection.py by explicitly specifying ImageFormat.RGB when creating images from MuJoCo renderer output. Previously, Image.from_numpy() defaulted to BGR format, but MuJoCo returns RGB frames, causing incorrect color rendering.
  • Import Improvement: Fixes potential timeout issue by calling mjx_env.ensure_menagerie_exists() explicitly instead of relying on implicit import side effects
  • Typo Fix: Corrects "menajerie" → "menagerie" in comment

Code Cleanup:

  • Removes unused imports across three files (SystemMessage, threading, Any)
  • Updates uv.lock dependency lockfile

Integration

The demo follows the established pattern used by other demo blueprints like demo_osm and demo_skill. When executed, it:

  1. Initializes the CameraModule with default Webcam hardware
  2. Opens the system's default camera (/dev/video0)
  3. Streams RGB images through the module's output ports
  4. Can be extended by connecting to other modules via autoconnect()

Confidence Score: 4/5

  • This PR is safe to merge with one minor style improvement recommended
  • The changes are well-implemented and follow existing patterns in the codebase. The MuJoCo image format fix is an important bug correction. The only issue is a minor style inconsistency where demo_camera should be added to the __all__ export list in camera/module.py for consistency with module conventions (though it will work without this change).
  • dimos/hardware/sensors/camera/module.py - minor style improvement suggested for all export list

Important Files Changed

File Analysis

Filename Score Overview
dimos/hardware/sensors/camera/module.py 4/5 Added demo_camera blueprint using autoconnect; minor issue with all export list not including demo_camera
dimos/robot/unitree_webrtc/mujoco_connection.py 5/5 Fixed typo, improved import handling for menagerie, and correctly specified ImageFormat.RGB for MuJoCo frames
dimos/robot/all_blueprints.py 5/5 Added demo-camera blueprint registration to enable 'dimos run demo-camera' command
uv.lock 5/5 Added new lockfile with 10,066 lines of dependency specifications

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as dimos CLI
    participant Blueprint as ModuleBlueprintSet
    participant CameraModule
    participant Webcam as Webcam Hardware
    participant ImageStream as Observable[Image]

    User->>CLI: dimos run demo-camera
    CLI->>Blueprint: Load demo_camera blueprint
    Note over Blueprint: autoconnect(camera_module())
    Blueprint->>CameraModule: Deploy & start module
    CameraModule->>Webcam: Initialize webcam hardware
    Webcam->>Webcam: Open cv2.VideoCapture
    Webcam->>ImageStream: Create image stream
    
    loop Capture Loop
        Webcam->>Webcam: Read frame from camera
        Webcam->>Webcam: Convert BGR to RGB
        Webcam->>ImageStream: Emit Image(format=RGB)
        ImageStream->>CameraModule: Publish to color_image output
    end
    
    Note over CameraModule: Module runs until stopped
    User->>CLI: Stop (Ctrl+C)
    CLI->>CameraModule: Stop module
    CameraModule->>Webcam: Release camera
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

)


__all__ = ["CameraModule", "camera_module"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo_camera should be added to the __all__ export list for consistency with the module's export conventions. While the blueprint will work without this (since all_blueprints.py uses direct import paths), it's best practice to include all public module-level variables in __all__.

Suggested change
__all__ = ["CameraModule", "camera_module"]
__all__ = ["CameraModule", "camera_module", "demo_camera"]

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@jeff-hykin jeff-hykin changed the base branch from main to dev January 12, 2026 03:43
@jeff-hykin jeff-hykin changed the title TIny: Add Webcam demo [Tiny] Add Webcam demo Jan 12, 2026
Copy link
Contributor

@spomichter spomichter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving bc i assume this is tested - but idk why we need auto connect on blueprints w one
module


camera_module = CameraModule.blueprint

demo_camera = autoconnect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paul-nechifor do we need to run autocorrect on a blueprint with one module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a good point, probably not. I'll test that tomorrow and simplify if it works without autoconnect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It can just be demo_camera = CameraModule.blueprint()

@leshy
Copy link
Contributor

leshy commented Jan 12, 2026

you can also instantiate the class and just use it (no multiprocess or anything) or you can dimos.deploy it and then use it, idk if we want to use blueprints on a single module but your call, just making sure we are all aware

https://github.com/dimensionalOS/dimos/blob/dev/docs/concepts/modules.md

@spomichter spomichter merged commit 92d5232 into dev Jan 13, 2026
13 checks passed
@spomichter spomichter deleted the jeff_add_webcam_demo branch January 13, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants