Skip to main content
The Real-time Digital Human API supports real-time camera recognition, allowing the AI to analyze visual input from the user’s camera and respond accordingly. This enables use cases such as object recognition, scene analysis, gesture detection, and visual Q&A.
Provider Compatibility: Camera recognition is only supported with the OpenAIRealtime provider. This feature is not available when using other AI providers (e.g., ElevenLabs).

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:
Real-time Transmission: The WebRTC video stream provides ultra-low latency (typically 50-100ms) and is ideal for scenarios requiring continuous visual analysis, such as gesture control or real-time object tracking.

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: 0 to avoid triggering immediate AI response for each frame
3

Stop Camera

Release camera resources when done:
Always call stopCamera() to release camera resources when the session ends or the component is unmounted. Failing to do so may prevent other applications from accessing the camera.

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
Recommendation: Start with periodic snapshots (Method 2) for most use cases. Add WebRTC video stream (Method 1) only when you specifically need ultra-low latency or continuous video analysis. The NavTalk console implementation uses both methods simultaneously for optimal performance.

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.updated event (when session is ready)
  • Both methods can run simultaneously without conflicts