cardboardcode / virtual_camera

A ROS2 package that simulates a camera, providing ROS messages from playing a static video.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build codecov License Ubuntu

What Is This?

A ROS2 package that simulates a camera, providing ROS messages from playing a static video or image.

Dependencies

  1. OpenCV
  2. ROS2 Foxy Fitzroy

Setup

Run the command below.

cd $HOME
git clone https://github.com/cardboardcode/virtual_camera.git --branch foxy_devel --single-branch --depth 1
cd ~/virtual_camera
source /opt/ros/foxy/setup.bash
colcon build
cd ~/virtual_camera
source install/setup.bash
ros2 run virtual_camera virtual_camera

ros2 launch virtual_camera showimageraw.launch.py
# For running without image-viewer
./scripts/run.bash
# For running with image-viewer
./scripts/show_image.bash

Create A Static Video/Image

# Jump into a folder called data
cd data
# Move your intended video/image into this folder
# Create a symbolic link to video.
ln -sf <video_file_name> input_data
# Or create a symbolic link to image.
ln -sf <image_file_name> input_data

Control FPS

Run the following command to control the speed of the video

ros2 param set /virtual_camera FPS <an integer>
# Eg. ros2 pararm set /virtual_camera FPS 24

Docker Instructions

This section is for users who do not want to worry about installing all dependencies stated above.

Build the docker image.

docker build --tag vcam_image .

Run the docker image.

# For first run.
sudo docker run -ti \
--name vcam_test_container \
-v $(pwd):/home/user/virtual_camera \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-u 0  \
 vcam_image:latest /bin/bash

# For subsequent run.
docker start vcam_test_container && docker exec -it vcam_test_container bash

About

A ROS2 package that simulates a camera, providing ROS messages from playing a static video.

License:Apache License 2.0


Languages

Language:C++ 79.1%Language:CMake 8.1%Language:Python 5.3%Language:Shell 4.8%Language:Dockerfile 2.7%