• Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    C++
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A package to open video streams and publish them in ROS using the opencv videocapture mechanism

video_stream_opencv

A package to view video streams based on the OpenCV VideoCapture module, easy way to publish on a ROS Image topic (including camera info) usb cams, ethernet cameras, video streams or video files. It also supports flipping of images and fps throttling.

Screenshot of the plugin working with a webcam, video stream and video file

Example usages in launch folder (only the argument video_stream_provider is mandatory):

<launch>
   <!-- launch video stream -->
   <include file="$(find video_stream_opencv)/launch/camera.launch" >
        <!-- node name and ros graph name -->
        <arg name="camera_name" value="webcam" />
        <!-- means video device 0, /dev/video0 -->
        <arg name="video_stream_provider" value="0" />
        <!-- set camera fps to (if the device allows) -->
        <arg name="set_camera_fps" value="30"/>
        <!-- set buffer queue size of frame capturing to -->
        <arg name="buffer_queue_size" value="100" />
        <!-- throttling the publishing of frames to -->
        <arg name="fps" value="30" />
        <!-- setting frame_id -->
        <arg name="frame_id" value="webcam" />
        <!-- camera info loading, take care as it needs the "file:///" at the start , e.g.:
        "file:///$(find your_camera_package)/config/your_camera.yaml" -->
        <arg name="camera_info_url" value="" />
        <!-- flip the image horizontally (mirror it) -->
        <arg name="flip_horizontal" value="false" />
        <!-- flip the image vertically -->
        <arg name="flip_vertical" value="false" />
        <!-- force a width and height, 0 means no forcing -->
        <arg name="width" value="640"/>
        <arg name="height" value="480"/>
        <!-- visualize on an image_view window the stream generated -->
        <arg name="visualize" value="true" />
   </include>
</launch>

Based on the ROS tutorial to convert opencv images to ROS messages.

Usability

You can use any input that OpenCV on your system accepts, e.g.:

  • Video devices that appear in linux as /dev/videoX, e.g.: USB webcams appearing as /dev/video0

  • Video streamings, e.g.: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

  • Video files, anything you can play, e.g.: myvideo.avi

  • Etc.

Parameters

Note these important ones on the behaviour of the node:

  • set_camera_fps: Will set the OpenCV parameter CV_CAP_PROP_FPS to that amount of fps, if the camera allows it. Does nothing on video streams or video files.

  • buffer_queue_size: Will set the size of the buffer of images read from the capturing device. We read as fast as possible (in another thread) from the device and store in the buffer the images. The main thread consumes from the buffer. If you want the shortest delay/lag set it to 1. If you don't want to lose images set it higher.

  • fps: The effective rate at which you want the image topic to publish, if lower than the effective fps of the camera it will throttle the publication dropping frames when needed.

So if you want the very latest image published from a camera, set buffer_queue_size to 1, set_camera_fps to the max the camera allows and fps to that same max.

If you want to publish all images (don't drop any and you don't mind some possible delay from real time), set buffer_queue_size big enough for your case (1000?), set_camera_fps and fps to whatever FPS it has.

The rest of the parameters explained, even though they are pretty self explanatory:

  • camera_name: node name and ros graph name. All topics will hang from this e.g.: /camera_name/.
  • video_stream_provider: A number for the /dev/videoX device, e.g.: 0 for /dev/video0. A string for a path for a video file, e.g.: /home/user/Videos/myvideo.avi or a url of a video stream e.g.: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov and http://10.68.0.6/mjpg/video.mjpg.
  • frame_id: frame_id to be published in the Header of the messages.
  • camera_info_url: camera info loading, take care as it needs the "file:///" at the start , e.g.: "file:///$(find your_camera_package)/config/your_camera.yaml".
  • flip_horizontal: flip horizontally the image (mirror it).
  • flip_vertical: flip vertically the image (upside down).
  • loop_videofile: if the provider is a video file, enable loop playback.
  • width and height: force a width and height to the capturing device (if it allows), 0 means no forcing.
  • start_frame: if the provider is a video file, set the start frame of video.
  • stop_frame: if the provider is a video file, set the stop frame of video. -1 means the end of the video. Also setting stop_frame = start_frame + 1 can publish a single frame with a certain rate.

Extras

In the scripts folder you'll find test_video_resource.py which you can use to test if your system installation can use this node to open your video stream (not using any ROS, just copy the file to your computer and try). Just do any of those:

./test_video_resource.py 0
./test_video_resource.py rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
./test_video_resource.py /home/youruser/myvideo.mkv

And you'll see an output like:

Trying to open resource: /dev/video0
Correctly opened resource, starting to show feed.

With an OpenCV image show window showing the stream (which should close when pressing ESC, or Control+C the shell).

More Repositories

1

velodyne

ROS support for Velodyne 3D LIDARs
C++
583
star
2

usb_cam

A ROS Driver for V4L2 USB Cameras
C++
542
star
3

rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
C++
473
star
4

nmea_navsat_driver

ROS package containing drivers for NMEA devices that can output satellite navigation data (e.g. GPS or GLONASS).
Python
211
star
5

joystick_drivers

ROS drivers for joysticks
Python
173
star
6

flir_camera_driver

C++
160
star
7

ros2_ouster_drivers

ROS2 Drivers for the Ouster OS-0, OS-1, and OS-2 Lidars
C++
139
star
8

pointgrey_camera_driver

ROS driver for Pt. Grey cameras, based on the official FlyCapture2 SDK.
C++
127
star
9

gscam

ROS Camera driver for GStreamer-based video streams.
C++
120
star
10

transport_drivers

A set of ROS2 drivers for transport-layer protocols.
C++
92
star
11

odva_ethernetip

Library implementing ODVA EtherNet/IP (Industrial Protocol).
C++
91
star
12

urg_node

ROS wrapper for the Hokuyo urg_c library.
C++
87
star
13

mocap_optitrack

ROS nodes for working with the NaturalPoint Optitrack motion capture setup
C++
83
star
14

libuvc_ros

C++
81
star
15

audio_common

Common code for working with audio in ROS
Python
77
star
16

vrpn_client_ros

VRPN ROS Client
C++
55
star
17

axis_camera

Contains basic Python drivers for accessing an Axis camera's MJPG stream. Also provides control for PTZ cameras.
Python
52
star
18

openni2_camera

ROS wrapper for openni 2.0
C++
49
star
19

openni_camera

A ROS driver for OpenNI depth (+ RGB) cameras.
C++
48
star
20

zbar_ros

Lightweight ROS wrapper for zbar barcode/qrcode reader library (http://zbar.sourceforge.net/)
C++
46
star
21

novatel_span_driver

Work in progress driver for NovAtel SPAN devices. See: http://wiki.ros.org/novatel_span_driver
Python
39
star
22

camera_umd

C
38
star
23

ackermann_msgs

ROS messages for Ackermann steering
CMake
36
star
24

phidgets_drivers

ROS drivers for various Phidgets devices
C++
35
star
25

nmea_msgs

nmea_msgs is a ROS package containing messages related to the NMEA standard
CMake
29
star
26

microstrain_mips

C
26
star
27

gps_umd

C
25
star
28

hokuyo_node

A ROS node to provide access to SCIP 2.0-compliant Hokuyo laser range finders (including 04LX).
C++
24
star
29

openni_tracker

C++
24
star
30

linux_peripheral_interfaces

linux hardware utilities.
C++
21
star
31

advanced_navigation_driver

ROS driver for Advanced Navigation devices
C
19
star
32

omron

ROS driver for OMRON OS32C laser scanner.
C++
18
star
33

camera1394

ROS driver for devices supporting the IEEE 1394 Digital Camera (IIDC) protocol.
C++
17
star
34

rgbd_launch

Launchfiles for use with depth cameras.
Python
16
star
35

microstrain_3dmgx2_imu

A driver for IMUs compatible the microstrain 3DM-GX2 and 3DM-GX3 protoco
C++
15
star
36

um7

ROS driver for UM7 inertial measurement device.
C++
14
star
37

wifi_ddwrt

Python
14
star
38

flir_ptu

ROS driver for FLIR pan-tilt units
C++
14
star
39

sicktoolbox

This package contains the SICK LIDAR Matlab/C++ Toolbox, available from http://sicktoolbox.sourceforge.net/
C++
13
star
40

wge100_driver

Contains the ROS driver and firmware for the WGE100 camera used on the PR2 robot.
Forth
13
star
41

urg_c

This project introduces sample programs of the URG library. Applications using URG and URG library are also introduced here. URG is Scanning Laser Range Finder of Hokuyo Automatic Co., for robots, autonomous systems and security systems.
C
11
star
42

openni2_tracker

C++
8
star
43

korg_nanokontrol

ROS driver for the Korg NanoKontrol MIDI input device.
Python
8
star
44

openni2_launch

Launch files to open an OpenNI2 device and load all nodelets to convert raw depth/RGB/IR streams to depth images, disparity images, and (registered) point clouds.
CMake
8
star
45

four_wheel_steering_msgs

ROS messages for steering vehicles using front and rear wheels
CMake
7
star
46

rosserial-experimental

C++
6
star
47

nmea_comms

Generalized ROS interface to NMEA-speaking devices.
C++
6
star
48

joystick_drivers_tutorials

Tutorials for the joystick_drivers stack
Python
6
star
49

prosilica_driver

Contains the ROS driver and the SDK for AVT/Prosilica cameras.
C++
6
star
50

openni_launch

This repo is DEPRECATED but will be kept for backward compatibility. To stay up-to-date please visit openni_camera repo:
CMake
5
star
51

sicktoolbox_wrapper

sicktoolbox_wrapper is a ROS wrapper for the outstanding sicktoolbox library for interfacing with the SICK LMS2xx lasers.
C++
5
star
52

driver_common

Deprecated common resources for drivers in ROS.
C++
5
star
53

um6

ROS driver for UM6 inertial measurement device.
C++
4
star
54

smart_battery_msgs

CMake
3
star
55

prosilica_gige_sdk

C
2
star
56

nmea_gps_driver

Python
2
star
57

video_stream_opencv-release

2
star
58

kvh_drivers

ROS drivers for KVH sensing devices.
C++
2
star
59

ati_netft_ros_driver

C++
1
star