Getting 640x480 images

From Wiki for iCub and Friends
Jump to: navigation, search

The following instructions describe how to configure the robot to use RGB image at the resolution of 640x480@30fps.


The dragonfly cameras mounted on the iCub provide images at various resolutions and framerates; the firewire bandwidth limits at 15fps the rate at which images can be obtained at the resolution of 640x480. Images can however be acquired with Bayer encoding at 30fps (saving 1/3 of the bandwidth).

To reduce the bandwidth used on the network when images are distributed to all the modules in the cluster (via YARP ports) it is also possible to postpone color reconstruction and transmit images with Bayer encoding. Color reconstruction can then be delegated to YARP ports (using a special protocol called bayer); at the same time color is reconstructed YARP can also reduce the size of the image (i.e. halving the original size). Color reconstruction and re-sizing is done by YARP within the receiving port and as such is completely transparent to clients.

Another advantage is that for each connection/client you can specify a different color reconstruction algorithm, or directly get Bayer images and perform the reconstruction yourself.

The drawback is that some extra CPU is used to reconstruct color on the clients, however this should be acceptable in modern machines.

Prepare YARP

Make sure you are using at least YARP 2.3.19. You need to re-compile YARP with the Bayer carrier.

Run cmake and enable the following flags:


Recompile YARP (it is advised to also recompile iCub since re-linking may be needed).

Configure the framegrabber

You need to configure the dragonfly cameras so that they stream images with Bayer encoding at the correct resolution. Use the following parameters (leave the others unchanged):

icubmoddev ... --width 640 --height 480 --video_type 3 --framerate 30 ...

You can now connect any port that expect an RGB image by simply changing how you connect them. For example you can connect a viewer and display 640x480 image:

 yarpview --name /view
 yarp connect /icub/image/left /view udp+recv.bayer+method.nearest

This tells YARP to receive images using udp, expect an image in Bayer format and reconstruct the color using nearest neighbor method (leaving the size unchanged). Check the size of the image in the yarpview by ticking Image->Original Size.

What is nice is that you can still receive images at 320x240 resolution. Configure YARP to halve the size of the image while reconstructing it:

 yarpview --name /view-half
 yarp connect /icub/image/left /view udp+recv.bayer+method.nearest+size.half

This tells YARP to receive images using udp, expect an image in Bayer format, reconstruct the color using nearest neighbor method, and halve the size of the image.

The bayer carrier has options for changing the Bayer format or reconstruction mechanism:

iCub configuration scripts

We provide two template scripts to configure the robot to stream images at 640x480.


This script runs the framegrabbers in Bayer mode but connects the camCalib modules so that they still receive and re-broadcast 320x240 images. This will not change anything on the images sent by camCalib on the ports /icub/camcalib/right/out and /icub/camcalib/left/out so nothing will change in existing modules that use calibrated images. However it will allow new modules to connect directly to the framegrabbers and get higher resolution images (as in the examples above).

The second script:


on the other hand connects camCalib modules so they receive (and re-broadcast) 640x480 images. In this case all modules will receive higher resolution images.

Note: the dragonfly driver does not allow saturation control when it provides Bayer images (for clear reasons). For this reason we have added a parameter that allows controlling the saturation in the camCalib module (check documentation).