Skip to main content

Integrate RGB Cameras with Foxglove

With Foxglove, you can stream data from any RGB camera (USB webcams, built-in laptop cameras, or IP cameras) for real-time visualization. The Foxglove SDK contains example code that shows how to stream data that you can modify to fit your application.

note

If you are using ROS, you can launch your camera node, and follow ROS 2 Documentation to start Foxglove Bridge.

Prerequisites

OpenCV Installation

sudo apt update
sudo apt install libopencv-dev

Installation and Setup

Python Installation

  1. Navigate to the Python example directory:

    cd foxglove-sdk/python/foxglove-sdk-examples/rgb-camera-visualization
  2. Install dependencies using Poetry:

    poetry install

    Or using pip:

    pip install foxglove-sdk>=0.9.0 opencv-python>=4.5.0 numpy>=1.20.0

Usage

Running the Python Application

cd foxglove-sdk/python/foxglove-sdk-examples/rgb-camera-visualization

# Use default camera (usually camera 0)
poetry run python main.py

# Specify a different camera ID
poetry run python main.py --camera-id 1

# Use a video file path
poetry run python main.py --camera-id /path/to/video.mp4

Command Line Options

OptionDescriptionDefault
--camera-id, -cCamera ID (integer) or video file path0
--help, -hShow help message-

Visualize RGB Camera Data in Foxglove

To visualize the RGB camera data, open Foxglove and connect to the websocket server.

Make sure you are on the same network as your robot. In Foxglove, select Open connection from the dashboard or left-hand menu.

Select open connection

Select Foxglove WebSocket in the Open a new connection dialog, then enter the URL of the server:

Foxglove WebSocket dialog

Click "Open" to connect.

note

Local development: Use ws://localhost:8765 when running the server on the same machine as Foxglove.

Robot connection: Use ws://ROBOT_IP:8765 when connecting to a server running on your robot, where ROBOT_IP is your robot's IP address on the network.

Visualize Camera Feed

Add an Image panel to your layout by clicking the Add panel button in the top left corner and selecting the Image panel.

Add image panel

Configure the panel by selecting the appropriate image topic from the Topic dropdown in the panel settings.

To visualize the RGB camera feed, select the /camera/image topic.

Select Image panel

Learn More