A ROS2 package that simulates a camera, providing ROS messages from playing a static video or image.
- OpenCV
- ROS2 Rolling Ridley
Run the command below.
cd $HOME
git clone https://github.com/cardboardcode/virtual_camera.git --branch rolling_devel --single-branch --depth 1
cd ~/virtual_camera
source /opt/ros/rolling/setup.bash
colcon build
Run the commands below to run virtual_camera ROS 2 node:
cd ~/virtual_camera
source install/local_setup.bash# For running without image-viewer
./scripts/run.bash
# For running with image-viewer
./scripts/show_image.bash# 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# You can choose not to do it manually by running the following script:
# Input the number of the input image shown in the script -
./scripts/set_input_data.bashRun 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
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:rolling .Run the docker image.
# Enable display to be forwarded from container to host.
xhost +local:docker
# For first run.
docker run -it \
--ipc host \
--net host \
--name vcam_rolling_test_container \
-v $(pwd):/home/user/virtual_camera \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-u 1000 \
vcam_image:rolling /bin/bash
# For subsequent run.
docker start vcam_rolling_test_container && docker exec -it vcam_rolling_test_container bash