ROS node for streaming an image topic to a video capture device. Mostly based on this:
Setup a workspace:
cd ~/catkin_ws/src # or wherever catkin_ws is
git clone https://github.com/lucasw/ros-virtual-cam
cd ..
catkin build virtual_cam
Stream node needs to write to a video capture device, which varies depending on your system.
Uses v4l2-loopback:
$ sudo apt-get install v4l2loopback-*
$ sudo modprobe v4l2loopback video_nr=1
$ v4l2-ctl -D -d /dev/video1
Driver Info (not using libv4l2):
Driver name : v4l2 loopback
Card type : Dummy video device (0x0000)
Bus info : v4l2loopback:0
Driver version: 0.8.0
Capabilities : 0x05000003
Video Capture
Video Output
Read/Write
Streaming
Typically just:
$ rosrun virtual_cam stream _device:=/dev/video1 _width:=640 _height:=480 _fourcc:=YV12 image:=/my_camera/image
where:
/dev/video1
target device640x480
target sizeYV12
target pixel format/my_camera/image
the sourcesensor_msgs/Image
topic re-mapped toimage
For more:
$ rosrun virtual_cam stream --help
$ v4l2-ctl -D -d /dev/video1
Driver Info (not using libv4l2):
Driver name : v4l2 loopback
Card type : Dummy video device (0x0000)
Bus info : v4l2loopback:0
Driver version: 0.8.0
Capabilities : 0x05000003
Video Capture
Video Output
Read/Write
Streaming
$ ROS_VIRTUAL_CAM_STREAM_TEST_DEVICE=/dev/video1 catkin_make run_tests
If you want coverage:
$ catkin_make -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON
$ ROS_VIRTUAL_CAM_STREAM_TEST_DEVICE=/dev/video1 catkin_make run_tests
$ lcov --path . --directory . --capture --output-file coverage.info
$ lcov --remove coverage.info 'tests/*' '/usr/*' '/opt/*' --output-file coverage.info
$ lcov --list coverage.info
TODO(lucasw) update above for catkin build