wiki:BIAS

Video processing toolkit from the  working group of Multimedia Information Processing of CAU Kiel.

Installation

1. BIAS download and configuration

  • Go to your shared directory (e.g. ~/shared or ~/workspace or whatever)
  • Download source from cvs by calling these three commands: cvs -d :pserver:anonymous@www.mip.informatik.uni-kiel.de:65010/home/cvs/bias login cvs -d :pserver:anonymous@www.mip.informatik.uni-kiel.de:65010/home/cvs/bias get BIAS cvs -d :pserver:anonymous@www.mip.informatik.uni-kiel.de:65010/home/cvs/bias get CMakeModules
  • change to BIAS directory (make sure, cmake ? is installed!), don't forget the '.' ! cd BIAS ccmake .
  • (first time you call ccmake, simply press 'c' to check if it is properly installed and to advance to BIAS config page)
  • Configure the installation (e.g. switch off USE options likle IMAGEMAGIXLIB, if they are not installed)

See example Configuration below. Note that USE_DC1394 is mandatory for our camera. For building a simple GUI, activate USE_GTK2 and additionally USE_PTHREADS and USE_XML2. The install prefix should be /usr/local in order to have a common install path to be able to use make files across different computers.

Example Configuration

     Page 1 of 1
 BIAS_DEBUG                       ON                                           
 BUILD_EXAMPLES                   ON                                           
 BUILD_IMAGE_DOUBLE               OFF                                          
 BUILD_IMAGE_SHORT                OFF                                          
 BUILD_IMAGE_UINT                 OFF                                          
 BUILD_IMAGE_USHORT               OFF                                          
 BUILD_SHARED_LIBS                ON                                           
 BUILD_TESTING                    ON                                           
 BUILD_TESTS                      ON                                           
 BUILD_TESTS_GRAPHICAL            ON                                           
 CMAKE_BACKWARDS_COMPATIBILITY    2.4                                          
 CMAKE_BUILD_TYPE                 Debug                                        
 CMAKE_INSTALL_PREFIX             /usr/local                                   
 EXECUTABLE_OUTPUT_PATH           /home/haf/shared/BIAS/bin                    
 FIND_BIAS_FILE                   /home/haf/shared/BIAS/../CMakeModules/FindBIAS.cmake
 GTK_cairo_INCLUDE_PATH           /usr/include                                 
 GTK_gobject_LIBRARY              /opt/gnome/lib/libgobject-2.0.so             
 LIBRARY_OUTPUT_PATH              /home/haf/shared/BIAS/lib                    
 TARGET_DOC                       ON                                           
 TARGET_PACKAGE                   ON                                           
 USE_DAIMLERCHRYSLER              OFF                                          
 USE_DC1394                       ON                                           
 USE_DEVIL                        OFF                                          
 USE_DV                           OFF                                          
 USE_FFTW3                        OFF                                          
 USE_GLEW                         OFF                                          
 USE_GLUT                         OFF                                          
 USE_GSL                          OFF                                          
 USE_GTK                          OFF                                          
 USE_GTK2                         ON                                           
 USE_IMAGEMAGICKLIB               OFF                                          
 USE_IMLIB                        OFF                                          
 USE_LIBJPEG                      OFF                                          
 USE_OPENCV                       OFF                                          
 USE_OPENEXR                      OFF                                          
 USE_OPENGL                       OFF                                          
 USE_PTHREADS                     ON                                           
 USE_TIFF                         OFF                                          
 USE_UEYE                         OFF                                          
 USE_V4L                          OFF                                          
 USE_WXWIDGETS                    OFF                                          
 USE_XML2                         ON                                           
 wxWidgets_CONFIG_EXECUTABLE      wxWidgets_CONFIG_EXECUTABLE-NOTFOUND         
 -------------------------------------------------------------------------------
 BIAS_DEBUG: define BIAS_DEBUG?                                                                        
 Press [enter] to edit option                                               CMake Version 2.4 - patch 3
 Press [c] to configure     Press [g] to generate and exit
 Press [h] for help         Press [q] to quit without generating
 Press [t] to toggle advanced mode (Currently Off)
  • Press 'c', ccmake will check if your computer fulfills all dependencies
  • If error messages come up, either
    • install the missing package for your linux distribution (e.g. GTK2) (see some example dependencies below)
    • deactivate the corresponding USE-option in the ccmake menu
  • If the "configure" step successfully finished without error, the option 'g' - "generate" becomes available
  • Press 'g' to generate Makefiles
  • Start the make process make
  • If error messages come up during make, this is supposingly a bug, because ccmake forgot to check some dependencies. So please
    • Guess what package is missing on your system (from the error message) and install it
    • AND write a bug report to the BIAS people
    • try to rerun make
  • Install programs (binaries), include files (c++ headers) and libraries into your linux distribution (as root!) make install

Some basic dependencies

Most Linux distributions provide the corresponding packages under some different names. Suse 9.2 had some missing, so some details for those are explained at the links below.

  • cmake ?
  • f2c ? (fortran-to-c)
  • libuuid (belongs to SUSE package E2fsprogs)
  • g2c (Fortran 77 compiler, Suse package g77)
  • lapack/blas (can be installed from SUSE yast)
  • make (GNU-make prefered, other untested)
  • a compiler (gcc/g++ 4.1 prefered)

DEBIAN 3.1 Testing: All dependent packages are provided with debian, install the following packages:

  • cmake
  • f2c
  • g2c
  • lapack3-devel
  • gcc
  • e2fslibs-dev
  • uuid-dev
  • libxml2-dev
  • libgtk2-dev

Run BIAS

Activating some features in ccmake together with the "BuildExamples" option will build some example binaries. E.g. USE_WXWIDGETS will build the ShowCamWX program to display the camera image.

Example Program

The following simple example will connect to the camera, grab images, draw something at the images and display the images in a GTK window.

/**
 * Simple test program for use of BIAS, set up for the rtsys baton interpreter unit.
 *
 * @author Hauke Fuhrmann (haf)
 *
 **/

#include "Image/Camera.hh"
#include "VideoSource/VideoSource_DCAM.hh"
#include "Base/Image/ImageDraw.hh"
#include "Gui/GuiGTK.hh"

// all BIAS related stuff is in BIAS namespace, so use it here
using namespace BIAS;

int main()
{
    VideoSource_DCAM myCam;
    Camera<unsigned char> cameraImage; //image coming from camera (original)
    Camera<unsigned char> myImage;     //copy of image to be manipulated

    // send settings to request a specific picture format
    // from camera
    myCam.SetSize(640,480);
    myCam.SetColorModel(ImageBase::CM_RGB);
    myCam.OpenDevice();
    myCam.InitImage(cameraImage);
    myCam.PreGrab();

    // Create some simple Gui Window (using GTK)
    GuiGTK gui = GuiGTK("baton", true);

    for (;;) // main loop for image processing
    {
        // get image from camera
        myCam.GrabSingle(cameraImage);
        //copy image (don't manipulate the original camera image!)
        myImage = *cameraImage.Clone();

        // get image data
        unsigned char *data = myImage.GetImageData();
        /* analyze data here */

        // manipulate image to display some debug information
        // eg, where some features where detected in the image

        // draw an arrow
        unsigned start[] = {200,200};
        unsigned end[]   = {250,250};
        unsigned length  = 10;
        unsigned width   = 5;
        unsigned char color[] = {255,55,55}; // some red
        ImageDraw<unsigned char>::Arrow(myImage, start, end, length, width, color);

        //draw a circle
        ImageDraw<unsigned char>::CircleCenter(myImage, 300, 300, 65);

        //display image in gui window
        gui.ShowImage(myImage,255.0,255.0);
    }
    myCam.PostGrab();
    myCam.CloseDevice();
    return 0;
}// main function

Notice this example uses the GuiGTK Class which is an example of the BIAS Package. This GUI is very simple and especially does not give any feedback to the application (e.g. whenever the "Exit" cross was klicked). So the application needs to be terminated manually from the shell. For own applications you should build a simple GUI by yourself. Find explanations for that (and tutorials including a small hello-world GUI) at  http://www.gtk.org/. Note that GTK does not really use object orientation. It is ok for small applications, but Qt or WXWidgets might be a better choice for larger applications.

Possible Errors

(dc1394_control.c) Couldn't get raw1394 handle! dc1394 - couldn't get handle: No such device or address

  • Most propably, the camera cannot be accessed. Install IEEE1394 support at your distribution! Load the driver modules (e.g. with modprobe)
    • raw1394
    • video1394
  • BIAS expects the camera to be device /dev/video1394-0
  • In some linux distributions the device is called /dev/video1394 or even /dev/video1394/0
  • So add a link to the actual device, e.g. ln -s /dev/video1394/0 /dev/video1394-0

Building the Example

Call the g++ compiler with all the needed options:

 g++ -o ExampleSimple.o ExampleSimple.cpp \
     -g -I/usr/local/include/BIAS -L/usr/local/lib/shared \
     -Xlinker -rpath -Xlinker /usr/local/lib/shared \
     -lBIASCommon -lBIASDebug -lBIASFeatureDetector \
     -lBIASFilter -lBIASGeometry -lBIASGeometryBase -lBIASGui \
     -lBIASImage -lBIASImageBase -lBIASMatcher2D -lBIASMathAlgo \
     -lBIASMathBase -lBIASNetworkComm -lBIASStateEstimator -lBIASUtils \
     -lBIASVideoSource \
     `pkg-config --libs --cflags gtk+-2.0`

Explanations

  • -o is the output filename followed by the input cpp-Program to be compiled
  • -g enables to debug the program with the gdb debugger
  • -I is an additional path for include files (above is the standard path to the BIAS installation)
  • -L is an additional path for library files (above is the standard path to the BIAS installation)
  • -Xlinker: the whole line sets the library path during runtime for the linker (note: the -L option is only set for compile time, so the -rpath option must be passed to the linker to add the library path for runtime)
  • -l<lib> links the corresponding library to the file. Above are all BIAS libraries added. The library path, where the corresponding libBiasCommon.so, etc. is located must be visible to g++ by adding the path as shown above.
  • To use the GTK gui toolikt, the compiler needs a whole bunch of additional parameters. In order to avoid hardcoding them, you can use the program pkg-config to find the parameters for your system. The pkg-config call can be embedded into your g++ call just as shown above (use the correct ` character!)

Makefile

For larger projects, a makefile is mandatory, that stores all these options for you and can compile multiple source files successively and automatically link them together to one binary. So you really should write a Makefile for your BIAS application using the parameters as shown above. See  http://www.gnu.org/software/make/ for instructions.

Specific Camera Settings

The Camera is a  Unibrain Fire-i Digital Firewire Camera. It sends uncompressed images over the bus (in contrast to DV, which compresses the images in the camera before sending). Supported Color Modes and frame rates are

 Frame rates (fps)             30      15     7.5    3.75
 Video Modes 	 
 640x480 RGB-24 (24 bits)       —       X       X       X
 640x480 YUV 4:2:2 (16 bits)    —       X       X       X
 640x480 YUV 4:1:1 (12 bits)    X       X       X       X
 640x480 Y-Mono8 (8 bits)       X       X       X       X
 320x240 YUV 4:2:2 (16bits)     X       X       X       X
 160x120 YUV 4:4:4 (24 bits)    X       X       X       —

BIAS Color Models

Note that BIAS supports more color models than the camera. If you capture the images in on specific color model (e.g. YUV411), BIAS can convert them to any of these following color models:  BIAS Color Models

Use the  ImageConvert Functions to convert between color models!

Install BIAS on mini-ITX computer Baton

  • Install BIAS at the big read-write harddrive system as explained above
  • The small read-only system is mounted at /mnt/system2
  • After installation (make install) to the default big system, call ccmake again and change the install prefix to the small system: cd <BIAS directory> ccmake . CMAKE_INSTALL_PREFIX /mnt/system2/usr/local
  • configure ("c") and generate Makefiles ("g") and install make install
  • To get the changes to the flash-disk, too,
    • either copy the whole system2 image to the flash disk as explained here [[Baton - Chang
    • or change the prefix to /mnt/flash/usr/local and install again