How to Build
From OpenCV on the Cell
This page show that how to install OpenCV library and CVCell module. If you succeed install, run demonstration.
| demonstration | ||
|---|---|---|
Steps of a procedure
- Step 2: Install OpenCV Library
- Step 3: Install CVCell module
- Step 4: Run demonstration
- Optional: Installing the Webcam
Detailed Processes
Install Build Environment for Cell/B.E.
The following explanation is based on FedoraCore6(FC6) environment and system software version 1.80. In order to build OpenCV library containing the Cell/B.E. specific code, the Cell/B.E. Software Development Kit 2.1 is required. If not yet ready, please download from Barcelona Supercomputing Center and install.
You need the following package at least to build the environment:
GNU Toolchain for PPU
- ppu-binutils-2.17.50-8.ppc.rpm
- ppu-gcc-4.1.1-10.ppc.rpm
- ppu-gcc-c4.1.1-10.ppc.rpm
GNU Toolchain for SPU
- spu-binutils-2.17.50-8.ppc.rpm
- spu-gcc-4.1.1-9.ppc.rpm
- spu-gcc-c4.1.1-9.ppc.rpm
- spu-newlib-1.15.0-7.ppc.rpm
SPE Runtime Lib v2.1 (libspe2)
- libspe2-2.1.0-0.ppc.rpm
- libspe-devel-1.2.2-0.ppc.rpm
simdmath library for PPU and SPU
- simdmath-2.1-1.ppc.rpm
- spu-simdmath-2.1-1.ppc.rpm
Install OpenCV Library
Get ready for installing the optimized OpenCV library
Get the original code for OpenCV (opencv-1.0.0) from SourceForge OpenCV project page. You will also need the patch file for OpenCV (opencv-1.0.0-cell-patch-20080108) and the CVCell module (cvcell-0.1.0-20080108) from SourceForge OpenCV on the Cell/B.E. project page.
Extract the original code for OpenCV and the patch file for OpenCV. Please execute as follows:
$ tar -zxf opencv-1.0.0.tar.gz $ tar -zxf opencv-1.0.0-cell-patch-20080108.tar.gz
Apply the patch for Cell/B.E:
Apply the patch for Cell/B.E:
$ patch -d opencv-1.0.0 -p1 < opencv-1.0.0-cell-patch-20080108/opencv-cell.patch
Configure the OpenCV library
Configure the OpenCV library. If you execute the following, OpenCV library will be installed to /usr/local:
$ ./configure
You need to specify prefix argument if you want to install to other directory. If you want to use gcc optimaized for ppu, specify CXX variable to 'ppu-g++ -m32' when you run ./configure:
$ ./configure --prefix=$(Directroy you want to install) $ ./configure CXX='ppu-g++ -m32' CC='ppu-gcc -m32'
From now on, the case you install OpenCV to /usr/local is supposed. You will change below commands on your environment.
Compile and Install the OpenCV programs
Compile the OpenCV programs.
$ make $ make install
If you are installing to a system-wide location, you need to install the OpenCV as "root":
$ su # make install
Install CVCell module
Get ready for installing the optimized CVCell module
Unpack the CVCell module as follows:
$ tar -zxf cvcell-0.1.0-20080108.tar.gz $ cd cvcell-0.1.0
Configure the CVCell module
Build the CVCell module. Please execute the following:
$ ./configure
The value of PKG_CONFIG_PATH is needed to set for compiling CVCell module programs. You shold add the directory containing 'opencv.pc' to the PKG_CONFIG_PATH environment variable. If you succeed install OpenCV, you can find 'opencv.pc' in /usr/local/lib/pkgconfig. Execute the following:
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Compile and Install the CVCell module
After adjusting the PKG_CONFIG_PATH environment variable, install the CVCell module:
$ make $ su # make install
Run demonstration
Compile the samples
Copy sample/c directory to your home directory and run build_all.sh:
$ cp -r /usr/local/share/opencv/samples/c ~/ $ cd ~/c $ sh build_all.sh
If you got error as follows, please set PKG_CONFIG_PATH environment variable to /usr/local/lib/pkgconfig.
Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing 'opencv.pc' to the PKG_CONFIG_PATH environment variable No package 'opencv' found
Facedetect Sample
This sample is the example which executed the sample program attached to OpenCV. The following figure is an example of the face detection program.
| Output of Facedetect | ||
|---|---|---|
You can set the number of SPE when you run programs if you specify the value of CVCELL_SPENUM environment variable. Please execute as follows:
$ CVCELL_SPENUM=0 ./facedetect --cascade=/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml detection time = 832.045ms
In this case, PPE only was running. The average of detection times is about 840ms.
Please execute the following:
$ CVCELL_SPENUM=6 ./facedetect ---cascade=/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml detection time = 102.563ms
In this case, PPE and SPE*6 were running. Compare with the previous detection time. The average of detection times is about 102ms.
The value of CVCELL_SPENUM must be reffered to when the optimized function runs. All applications are made as usual OpenCV applications. It is time when runs the optimized function in there is a modified OpenCV Library and CVCell module.
If you cannot find any changes between previous two results, execute the following. Please execute the second command ls /spu while the program that was executed by the first command is running:
$ ./facedetect ---cascade=/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml & $ ls /spu spethread-2349-268517544 spethread-2349-268520704 spethread-2349-268521440 spethread-2349-268520040 spethread-2349-268521368 spethread-2349-268521628
The output shows threads of SPE that is running. As you know, if the program ends, anything doesn't occur even if the second command is executed.
Installation is successful when you can see SPEs were running.
If you are enable to use webcam (See Installing the Webcam), facedetect runs on movie that is captured from webcam. If not, runs on lena.jpg.
Installing the Webcam
If you have a webcam, OpenCV can be utilized further. However, the base Linux kernel does not support a capture device as CONFIG_VIDEO_DEV is not set by default. Moreover, as Linux 2.6.23 does not support a USB Video Class driver, it is necessary to install that too. Next, we prepared a patch for FC6. Please refer to Installing the Webcam.


