Skip to content

Vision mode: add support for IP cameras / camera specification by path#190

Open
reisbauer03 wants to merge 2 commits intodnhkng:mainfrom
reisbauer03:pr-vision-spec
Open

Vision mode: add support for IP cameras / camera specification by path#190
reisbauer03 wants to merge 2 commits intodnhkng:mainfrom
reisbauer03:pr-vision-spec

Conversation

@reisbauer03
Copy link
Copy Markdown
Contributor

@reisbauer03 reisbauer03 commented Mar 30, 2026

Pull Request Summary – Flexible IP Camera Support

This PR makes the vision configuration more flexible by letting you specify a camera either by its numeric index or by a full path/URL. It doesn’t add new features—OpenCV already handles these kinds of inputs—but it updates the configuration schema to make those options available.

  • Configuration Changevision.camera_index is replaced with vision.camera_spec. The old key is kept for backward compatibility.

  • Supported Formatscamera_spec accepts either a non‑negative integer (camera index) or a string (file path, network stream URL, etc.).

  • Code Update – All internal references to vision.camera_index have been switched to vision.camera_spec.

  • Documentation – The example config file configs/glados_vision_config.yaml has been updated to illustrate the new camera_spec usage.

No new functionality is introduced; this change simply expands how the existing camera support can be configured.

Summary by CodeRabbit

  • New Features

    • Support for IP/network camera sources (RTSP/URI) in addition to local camera indices.
  • Improvements

    • Camera setting now accepts either an index or a URI for greater flexibility.
    • Backward compatibility preserved—existing index-based configs continue to work.
    • Camera source info in logs is now redacted to avoid exposing embedded credentials.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c75cf137-65ed-4f5b-8c06-ffb79e5bb286

📥 Commits

Reviewing files that changed from the base of the PR and between 7d057ad and 8cfa21d.

📒 Files selected for processing (2)
  • src/glados/vision/vision_config.py
  • src/glados/vision/vision_processor.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/glados/vision/vision_config.py

📝 Walkthrough

Walkthrough

camera_index was replaced by camera_spec to accept either a non-negative integer (local camera index) or a string (URI/filename, e.g., rtsp://...). Backward-compatible aliasing allows old camera_index keys, union parsing is explicit, and vision code/logs now use the new spec and redaction helper for logs.

Changes

Cohort / File(s) Summary
Configuration
configs/glados_vision_config.yaml
Replaced camera_index with camera_spec; added commented example for IP/RTSP URL.
Vision config model
src/glados/vision/vision_config.py
Field changed to camera_spec: Union[NonNegativeInt, StrictStr] with validation_alias=AliasChoices("camera_spec", "camera_index"), union_mode='left_to_right'; added redacted_camera_spec_for_log() to safely redact credentials in string specs.
Vision runtime
src/glados/vision/vision_processor.py
VideoCapture now constructed with self.config.camera_spec; log messages and capture-failure warnings updated to reference/redact the camera spec via the new helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop, a lens, a stream to see,
Index or URL — both now agree.
I guard the secrets in each spec line,
Redacted tokens? All safe and fine.
Cheers to vision, near and far! 📸

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: replacing camera_index with camera_spec to support IP cameras and path-based camera specification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
configs/glados_vision_config.yaml (1)

31-31: Quote the RTSP example for copy/paste safety.

On Line 31, consider quoting the URL example to avoid YAML edge-case parsing surprises when users add credentials or query params.

Suggested tweak
-    # camera_spec: rtsp://192.168.0.1:5555/ # Use IP camera
+    # camera_spec: "rtsp://192.168.0.1:5555/" # Use IP camera
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@configs/glados_vision_config.yaml` at line 31, The commented RTSP example for
camera_spec may be parsed incorrectly in YAML when users add credentials or
query params; update the camera_spec example to use a quoted string (surround
the URL with either single or double quotes) so the commented example remains
safe for copy/paste and avoids YAML parsing edge cases—locate the commented line
containing camera_spec and replace the unquoted URL with a quoted URL string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/glados/vision/vision_config.py`:
- Line 19: The AliasChoices instantiation currently lists the deprecated key
first so Pydantic v2 will prefer "camera_index" over "camera_spec"; update the
call to AliasChoices so the new key is first (i.e., use
AliasChoices("camera_spec", "camera_index")) to ensure "camera_spec" takes
precedence when both are present.

In `@src/glados/vision/vision_processor.py`:
- Around line 135-137: The logs in VisionProcessor currently emit
repr(self.config.camera_spec), risking credential exposure for RTSP/http URLs;
change the logging to use a redacted camera spec instead by adding a small
helper (e.g., redact_camera_spec(camera_spec)) that parses the URL (using
urllib.parse.urlparse) and removes or masks username/password (or replaces them
with "<redacted>") while preserving host/path, then replace all uses of
repr(self.config.camera_spec) in VisionProcessor (where the error/ retry/ info
logs appear) with the redacted string; ensure the helper is reused for every log
site to avoid leaking credentials.

---

Nitpick comments:
In `@configs/glados_vision_config.yaml`:
- Line 31: The commented RTSP example for camera_spec may be parsed incorrectly
in YAML when users add credentials or query params; update the camera_spec
example to use a quoted string (surround the URL with either single or double
quotes) so the commented example remains safe for copy/paste and avoids YAML
parsing edge cases—locate the commented line containing camera_spec and replace
the unquoted URL with a quoted URL string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7cc448a4-13ae-4521-a7d8-591a35309ba5

📥 Commits

Reviewing files that changed from the base of the PR and between 6cbcbbc and 7d057ad.

📒 Files selected for processing (3)
  • configs/glados_vision_config.yaml
  • src/glados/vision/vision_config.py
  • src/glados/vision/vision_processor.py

Comment thread src/glados/vision/vision_config.py Outdated
Comment thread src/glados/vision/vision_processor.py
…RL credentials in logging (CodeRabbit suggestions)
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.

1 participant