Camera Transmission Methods
NavTalk provides two methods for transmitting camera data to the AI, each optimized for different use cases:Both methods can be used simultaneously. The WebRTC stream provides real-time video for immediate AI processing, while periodic snapshots offer AI-friendly image data for vision model analysis.
Method 1: WebRTC Video Stream (Real-time)
This method transmits the camera video stream directly through WebRTC, providing ultra-low latency for real-time visual analysis.1
Request Camera Access
First, request camera permissions and create the video stream:
Camera permissions are required from the user. Make sure to request permissions appropriately and handle cases where the user denies access.
2
Add Video Track to WebRTC Connection
After establishing the WebRTC connection (after handling the offer), add the camera video track to the peer connection:
Method 2: Periodic Snapshots (Image Frames)
This method captures video frames at regular intervals (every 2 seconds by default), converts them to JPEG images, and sends them via WebSocket. This approach is bandwidth-efficient and suitable for periodic scene analysis.1
Start Periodic Frame Capture
After the WebSocket connection is established and session is ready, start capturing frames periodically:
2
Capture Frame and Send to AI
Capture video frames, convert them to base64-encoded images, and send them to the AI via WebSocket:
Best Practices:
- Use JPEG quality of 0.7 (70%) to reduce payload size while maintaining reasonable image quality
- Resolution of 640x360 is sufficient for most use cases and reduces bandwidth requirements
- Capture interval of 2-3 seconds balances real-time responsiveness and bandwidth usage
- Set
reply: 0to avoid triggering immediate AI response for each frame
3
Stop Camera
Release camera resources when done:
Choosing the Right Method
Use WebRTC Video Stream When:
- You need continuous real-time video analysis (e.g., gesture recognition, live monitoring)
- Low latency is critical (50-100ms)
- The AI model supports direct video stream processing
- Network bandwidth is sufficient
Use Periodic Snapshots When:
- You need periodic scene recognition (e.g., “What do you see?”)
- Bandwidth is limited
- You want to reduce server processing load
- The use case doesn’t require frame-by-frame analysis
Use Both Methods When:
- You want the best of both worlds: real-time responsiveness with AI vision capabilities
- The AI provider supports both video stream and image input
- Your application needs both continuous monitoring and detailed image analysis
Complete Integration Example
Here’s how to integrate both camera transmission methods in a complete implementation:Integration Timing:
- WebRTC video stream is added when handling the WebRTC offer (during connection setup)
- Periodic snapshots start when receiving
realtime.session.updatedevent (when session is ready) - Both methods can run simultaneously without conflicts