Connecting the camera

Firstly, connect your camera to Raspberry. To determine whether it’s working or not, just type:

$ sudo vcgencmd get_camera

If you got supported=1 detected=1, then it’s ok and you can follow the next step. Otherwise, you should enable your camera with raspi-config. Furthermore, you can test video streaming with this tutorial.

Installing ROS on your server

I used ROS kinetic, but you may use anything you want. Check out the official guide to get it working. Installation of ROS is quite straightforward and usually doesn’t produce errors. If you stumbled and got any, you can always ask for help on the forum.

Installing all packages and libraries

In this section we are going to build our environment with every library we need. Here are the list of what we should install:

OpenCV

libviso2

gscam

image_common

image_pipeline

vision_opencv

OpenCV

The needed packages should be installed using a terminal and the following commands:

$ sudo apt-get install build-essential

$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev $ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Get the latest stable OpenCV version:

$ git clone https://github.com/Itseez/opencv.git

Build:

$ cd /opencv $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. $ make -j5 # runs 5 jobs in parallel

All the following packages should be cloned into ~/odometry/src, so

$ cd ~/odometry/src

viso2

$ git clone https://github.com/srv/viso2

gscam

$ git clone https://github.com/ros-drivers/gscam

image_common

$ git clone https://github.com/ros-perception/image_common.gi...

image_pipeline

$ git clone https://github.com/ros-perception/image_common.gi...

vision_opencv

$ git clone https://github.com/ros-perception/image_common.gi...

Building everything:

$ cd ~/odometry

$ catkin_make

After successful building all packages let’s get our system up and working. Firstly, ssh into Raspberry and start broadcasting video to our server:

$ raspivid -n -w 640 -h 480 -b 1000000 -fps 40 -t 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host= port=9000

Where is IP address of your server. If you don’t know it, type:

$ ifconfig

and find your network and your IP.

After that change directory to ~/odometry/gscam/examples and create a new launch file called ‘raspicam.launch’:

$ cd /odometry/gscam/examples

$ vi raspicam.launch

Paste the following and save it:

<launch> <arg name="cam_name" value="raspicam"/> <env name="GSCAM_CONFIG" value="udpsrc port=9000 ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoconvert"> <node pkg="gscam" type="gscam" name="$(arg cam_name)"> <param name="camera_name" value="$(arg cam_name)"/> <remap from="camera/image_raw" to="$(arg cam_name)/image_raw"/> </node> </launch>

Then launch gscam and see if you can get an image:

$ roslaunch gscam raspicam.launch

$ rosrun image_view image_view image:=/raspicam/image_raw