Files
PraisonAI/examples/python/camera
cfd7d7c8a9 fix(examples): merge validation fixes phases 2-4 into main (stacked on #1855) (#1893)
* fix(examples): resolve syntax errors and align with consolidated-params API

* fix: correct TypeError in 3 example files by using proper parameter names

- Fix MemoryConfig(memory=...) → user_id=... in agent_centric_api.py
- Fix Session(memory=...) → user_id=... in session-example.py
- Fix build_context_for_task(memory=...) → user_id=... in memory-quality-example.py

Co-authored-by: Mervin Praison <[email protected]>

* fix(examples): align AgentTeam memory and knowledge configs with v4.6.52 API

* fix(examples): phase-3 API alignment for consolidated params on v4.6.52

* fix(examples): phase-4 API alignment for 40 validation failures on v4.6.52

* fix: resolve critical RouterAgent **kwargs bug and add missing if __name__ guards

- Fixed TypeError in RouterAgent._build_system_prompt() by removing **kwargs from super() call
- Added if __name__ == '__main__' guards to 6 example files to prevent auto-execution on import
- Addresses Gemini Code Assist review feedback

Co-authored-by: Mervin Praison <[email protected]>

* fix: resolve missing AgentTeam import and RouterAgent kwargs forwarding

- Fix missing AgentTeam import in self-reflection-optimization-patterns.py
- Forward kwargs properly in RouterAgent._build_system_prompt to super()
- Addresses critical issues identified by Gemini code reviewer

Co-authored-by: Mervin Praison <[email protected]>

* fix(examples): remove merge-conflict residue for PR #1893

---------

Co-authored-by: Dhivya-Bharathy <[email protected]>
Co-authored-by: praisonai-triage-agent[bot] <272766704+praisonai-triage-agent[bot]@users.noreply.github.com>
Co-authored-by: Mervin Praison <[email protected]>
Co-authored-by: Mervin Praison <[email protected]>
2026-06-23 00:03:04 +01:00
..
2026-01-31 08:34:24 +00:00

Camera Integration Examples

This directory contains examples demonstrating how to integrate camera feeds with PraisonAI multimodal agents for real-time visual analysis.

📋 Overview

PraisonAI supports visual input through the images parameter in Tasks. While there's no built-in camera capture, you can integrate camera feeds by capturing frames/videos and passing them to vision agents.

🛠️ Setup

Requirements

pip install praisonaiagents opencv-python

Environment Variables

export OPENAI_API_KEY=your_openai_api_key

📁 Examples

1. camera-basic.py - Basic Camera Capture

  • Purpose: Capture a single frame and analyze it
  • Use Case: Quick analysis, testing camera setup
  • Features:
    • Single frame capture
    • Basic object and scene analysis
    • Automatic cleanup

Usage:

python camera-basic.py

2. camera-continuous.py - Continuous Monitoring

  • Purpose: Continuous camera monitoring with periodic analysis
  • Use Case: Security monitoring, surveillance systems
  • Features:
    • Configurable analysis intervals
    • Real-time monitoring
    • Security-focused analysis
    • Graceful shutdown with Ctrl+C

Usage:

python camera-continuous.py

3. camera-multi-agent.py - Multi-Agent Analysis

  • Purpose: Multiple specialized agents analyzing the same camera feed
  • Use Case: Comprehensive analysis from different perspectives
  • Features:
    • Security analysis agent
    • Object detection agent
    • Scene analysis agent
    • Parallel processing

Usage:

python camera-multi-agent.py

4. camera-video-analysis.py - Video Recording & Analysis

  • Purpose: Record video segments and analyze temporal events
  • Use Case: Activity analysis, event detection
  • Features:
    • Video recording with configurable duration
    • Temporal event analysis
    • Timeline extraction
    • Automatic cleanup

Usage:

python camera-video-analysis.py

🎯 Supported Input Types

  • ✅ Local Images: "camera_shot.jpg", "webcam_capture.png"
  • ✅ Local Videos: "security_feed.mp4", "recording.avi"
  • ✅ Image URLs: "https://example.com/live_feed.jpg"
  • ✅ Multiple Sources: ["cam1.jpg", "cam2.jpg", "video.mp4"]

🔧 Configuration Options

Camera Settings

camera_id = 0  # Default camera (change to 1, 2, etc. for other cameras)

Analysis Intervals

analysis_interval = 10  # Seconds between analyses for continuous monitoring

Recording Duration

recording_duration = 15  # Seconds for video recording

💡 Integration Patterns

1. Real-time Processing

# Capture frames periodically and process them as separate tasks
def capture_and_analyze():
    cap = cv2.VideoCapture(0)
    ret, frame = cap.read()
    if ret:
        cv2.imwrite("temp_capture.jpg", frame)
        # Process with PraisonAI agent
    cap.release()

2. Batch Analysis

# Process multiple camera angles simultaneously
task = Task(
    description="Analyze multiple camera feeds",
    agent=vision_agent,
    images=["cam1.jpg", "cam2.jpg", "cam3.jpg"]
)

3. Video Analysis

# Save video segments and analyze them
task = Task(
    description="Analyze this video for activities",
    agent=vision_agent,
    images=["security_footage.mp4"]  # Video files work too
)

🔒 Security Considerations

  • Camera Permissions: Ensure your application has camera access
  • Privacy: Be mindful of privacy when recording/analyzing
  • Storage: Clean up temporary files to avoid storage issues
  • Access Control: Implement proper access controls for camera systems

🐛 Troubleshooting

Camera Not Found

# Check available cameras
for i in range(4):  # Check first 4 camera indices
    cap = cv2.VideoCapture(i)
    if cap.isOpened():
        print(f"Camera {i} is available")
        cap.release()

Permission Issues

  • On Linux: Add user to video group
  • On macOS: Grant camera permissions in System Preferences
  • On Windows: Check camera privacy settings

Performance Optimization

  • Reduce frame size for faster processing
  • Adjust analysis intervals based on requirements
  • Use parallel processing for multiple agents

🤝 Contributing

Feel free to contribute additional camera integration examples or improvements to existing ones!