How+to+get+the+VeryFast-framework+(object+detection)+to+run+(Ubuntu+12.04)

=How to get the VeryFast-framework (object detection) to run (Ubuntu 12.04)= In the last years VISICS published multiple papers concerning object detection (including "Fast stixel estimation for fast pedestrian detection", "seeking the strongest rigid detector", "handling occlusions using franken-classifiers"). All of these are based on a framework which is made available by Rodrigo Benenson on his bitbucket (https://bitbucket.org/rodrigob/doppia). Although an explanation is given on how to compile this code, it needed multiple attemts to get it working. The code for "Seeking the strongest rigid detector" would also be made available,but at the time of this writing this is not yet the case.

Get the code
The first step is to download the code and extract it:
 * Just click the download-link (a zip-file). By doing this from the site, you are certain you download the most recent version.
 * unzip the file, which will generate a directory (in my case rodrigob-doppia-8b784ff23eea).

Things to make sure
By using a trial-and-error approach a figured out some precautions need to be taken (these are not in the documentation delivered with the framework, but could maybe be extracted from the issue-page):
 * **Use compiler g++-4.6**, I tried compiling with g++-4.4 and this resulted in an error about ambigious routines, which is no problem for g++-4.6. If you have both installed, a simple symbolic link from /usr/bin/g++ to /usr/bin/g++-4.6 (and the same for gcc, although this is maybe not necessary) will do the trick
 * Use a recent OpenCV with support for GPU. I used **OpenCV 2.4.6.1.** And it must also be **compiled with CUDA support** (and hopefully with a lot of other settings that can only benefit the execution speed)
 * A recent cuda version (>4.0). The system depends on this, I compiled it with **CUDA 5.0** . On the documentation page are some mentions of issues with CUDA 4.0 which would be solved in CUDA 5.0, so why not avoid these possible issues.
 * Use a GPU with **compute capability >= 2.0.** For most recent GPU's this is the case.I tried it on a card with compute capability 1.3 and the number of detections where huge (all but the correct ones). The system I got it working on a Tesla C2075 (a little overkill) and a NVIDIA quadro 2000 card.

Make a configuration specific for your system
The file common_settings.cmake is included by all the cmake-config files in the application directories and it holds all kind of configuration options to be used on your system. For this you have to add an option in the machine selection by adding a new option with your hostname.

elseif(${HOSTNAME} STREQUAL "super")

The options that made it work for me where: message(STATUS "Using EAVISE optimisation options") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(PKG_CONFIG_PATH ${PKG_CONFIG_PATH}) option(USE_GPU "Should the GPU be used ?" ON) set(CUDA_BUILD_EMULATION OFF CACHE BOOL "enable emulation mode") set(CUDA_BUILD_CUBIN OFF) set(local_CUDA_CUT_INCLUDE_DIRS "/home/fds/NVIDIA_GPU_Computing_SDK/C/common/inc") set(local_CUDA_CUT_LIBRARY_DIRS "/home/fds/NVIDIA_GPU_Computing_SDK/C/common/lib") set(local_CUDA_LIB_DIR "/usr/local/cuda-5.0/lib64") set(local_CUDA_LIB "/usr/lib/libcuda.so") set(cuda_LIBS "cuda") set(cutil_LIB "cutil") set(CUDA_NVCC_EXECUTABLE /usr/local/cuda-5.0/bin/nvcc) set(CUDA_SDK_ROOT_DIR /home/fds/NVIDIA_GPU_Computing_SDK/C) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=sm_20) set(google_perftools_LIBS tcmalloc_and_profiler) set(liblinear_INCLUDE_DIRS "/home/fds/RodrigoCode/rodrigob-doppia-8b784ff23eea/libs/liblinear-1.8") set(liblinear_LIBRARY_DIRS "/home/fds/RodrigoCode/rodrigob-doppia-8b784ff23eea/libs/liblinear-1.8")

of course these options (in particular the paths) must be made specific for your system

Installing google_perftools and tmalloc
If you are using the option set(google_perftools_LIBS tcmalloc_and_profiler) you also have to install this. This package can be downloaded from http://google-perftools.googlecode.com. This package is dependend on libunwind, which can be installed with sudo apt-get install libunwind7-dev after this you can extract, configure, compile and install the package

tar -xvf gperftools* cd gperftools* ./configure make sudo make install

Installing needed libraries from repository
If not already available on your system,some extra libraries need te be installed: sudo apt-get install libprotobuf-dev libsdl1.2-dev libboost1.48-all-dev libxrandr-dev

Compiling the applications
Now it should be possible to compile the applications in the framework. The first one we try is ground-estimation, since this is purely CPU based and can already point out some problems with the cmake-configuration used. To compile you go to the application source directory(src/applications/ground_estimation). You generate the Makefile and let the CPU's generate some heat

cd src/applications/ground_estimation cmake. make -j8

Possibly there are some errors. The error I received was the due to the lack of libraries used in the linking command of OpenCV (undefined reference to function ...). This issue can be solved by adding a lot of opencv-libraries in the CMakeLists.txt file. I added opencv_core opencv_highgui opencv_imgproc opencv_video opencv_contrib opencv_objdetect opencv_legacy opencv_gpu opencv_calib3d on line 129

After this, a simple regeneration of the Makefile and linking will do the job cmake. make

When compilation (and linking) is successful you can run the examples as mentioned on the documentation page ./ground_estimation -c test.config.ini

The application can be the stixel_world application, but since this also CPU based it may be interesting to go to the real challenge, namely the object_detection application Go into the directory and create the Makefile cd src/applications/objects_detection cmake.

Look to the output and hope everything looks fine. If this is the case, start compiling (//use the deprecated option if you do not want tons of warnings//) make -j8 [-Wdeprecated-declarations]

errors and issues I found are mentioned in the issue-section below.

When the object_detection application is compiled you can run it. The default configuration files lead on all tested system to an error concerning resizing the gui. To test the detector, I give all options on the commandline. An example command is given here:

./objects_detection --process_folder /home/fds/PETS --objects_detector.method gpu_channels --objects_detector.model ../../../data/trained_models/2012_04_04_1417_trained_model_multiscales_synthetic_softcascade.proto.bin --save_detections true --gui.disabled true --objects_detector.score_threshold -0.2 --objects_detector.non_maximal_suppression_method greedy --objects_detector.resize_detections true --preprocess.residual true --additional_border 80

Using this above configuration (and sometimes a solution of the possible issue section) the following applications build without problems:
 * object_detection OK
 * object_detection_lib still error
 * ground_estimation OK
 * boosted_learning OK
 * bootstrapping_lib OK
 * stixel_world OK
 * stixel_world_lib still errors
 * video_input OK

__Possible issues__
Cmake is not that verbose on default which can make it difficult to find the problem. Use the VERBOSE=1 option when compiling transfers the eye-friendly output of the compilation in the list of compilation commands executed (and therefor also the error-messages they generate).

undefined reference to opencv-libraries
Just add the needed libraries in the CMakeLists.txt file

cuda code stops compiling with an error
This has happened to me when compiling the code with multiple threads (-j8 option). Just let the compiling process get as far as possible and try remaking (just do the make command again). If this is not doing the trick, use the verbose mode.

can not find cutils
This is a library is part of the NVIDIA_GPU_SDK and is possibly not present in the default library directories. A simple symbolic link can also here be a way out. sudo ln -s ~/NVIDIA_GPU.../C/lib/libcutils_x86_64.a /usr/lib/libcutil.a
 * **Remark 1:** it seems that libcutil.a and cutil.h were removed from the CUDA SDK starting with CUDA5.0 and thus also in CUDA5.5
 * This can be solved by following four steps
 * Download CUDA4.2 GPU SDK (last version that still has seperate SDK and supports the use of libcutil)
 * Install the package by executing the run file and only install the SDK.
 * Go to the directory structure (~/NVIDIA_GPU_Computing_SDK/) and perform a make -j 8.
 * Add the symbolic link as mentioned above

**AtomicAdd could not be found (happens in several projects)**
This means that something went wrong. However, just rebuilding a second time using **cmake. && make -j 8** solved the problem. It is mentioned that Rodrigo had same problem and a double run fixed it!