This directory contains examples demonstrating how to integrate camera feeds with PraisonAI multimodal agents for real-time visual analysis.
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.
pip install praisonaiagents opencv-pythonexport OPENAI_API_KEY=your_openai_api_key- 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- 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- 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- 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- ✅ 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"]
camera_id = 0 # Default camera (change to 1, 2, etc. for other cameras)analysis_interval = 10 # Seconds between analyses for continuous monitoringrecording_duration = 15 # Seconds for video recording# 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()# Process multiple camera angles simultaneously
task = Task(
description="Analyze multiple camera feeds",
agent=vision_agent,
images=["cam1.jpg", "cam2.jpg", "cam3.jpg"]
)# 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
)- 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
# 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()- On Linux: Add user to
videogroup - On macOS: Grant camera permissions in System Preferences
- On Windows: Check camera privacy settings
- Reduce frame size for faster processing
- Adjust analysis intervals based on requirements
- Use parallel processing for multiple agents
Feel free to contribute additional camera integration examples or improvements to existing ones!