Monday, May 27, 2013

Installing gscam in ROS: Obtaining images from a webcam





Requeriments

- Ubuntu PC and Internet connection.
     + Tested version: Ubuntu 12.04

- ROS (Robotic Operating System).
     + Tested version: ROS Electric and ROS Fuerte

- A webcam. Tested with:
    + Creative Labs Live! Notebook USB Webcam.
    + Philips SPC900



1a. Installation in ROS Fuerte

The installation procedure in ROS Fuerte is simple:

$ roslocate info brown_perception | rosws merge -
$ rosws update
$ source ~/fuerte_workspace/setup.bash

1b. Installation in ROS Electric

1. First, Brown Perception repository must to be downloaded:

$ svn checkout http://brown-ros-pkg.googlecode.com/svn/trunk/distribution/brown_perception/gscam

2. You have to edit the bashrc file so ROS can find the package:

$ gedit ~/.bashrc

Add next line (better like last line):

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ros_workspace/gscam

2. Building

1. Next, install the gscam dependencies and compile:

$ rosdep install gscam
$ rosmake gscam 
 

3. Running

1. You can connect now the webcam. Important thing is to know what is the route:

$ ls /dev/video*

Normally you will see "/dev/video0"

2. Now you can launch it. Open 3 terminals. First, you have to launch the core of ROS:

$ roscore

3. Next you put the camera settings and launch the gscam node:

$ roscd gscam
$ cd bin
$ export GSCAM_CONFIG="v4l2src device=/dev/video0 ! videoscale ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! video/x-raw-rgb"
$ rosrun gscam gscam

NOTE: If you have the "Failed to PAUSE" problem you are in front of a permission problem, and the solution is simple. To solve it, you have to change the permissions in the next way:

$ sudo chmod 777 /dev/video0

And re-launch gscam.

4. Finally, to see the image raw, you have to launch the image_view node, wich is an application to show streaming. First list the topics:

$ rostopic list

Now yo will see next list:

/gscam/camera_info
/gscam/image_raw
/gscam/image_raw/compressed
/gscam/image_raw/compressed/parameter_descriptions
/gscam/image_raw/compressed/parameter_updates
/gscam/image_raw/theora
/gscam/image_raw/theora/parameter_descriptions
/gscam/image_raw/theora/parameter_updates
/rosout
/rosout_agg

You are interested in /gscam/image_raw, so launch the image_view node with next parameters:

$ rosrun image_view image_view image:=//gscam/image_raw

And, you will see the images from your webcam.


No comments:

Post a Comment