Compile and run the opencv implementation of hog

background

The previous installations of LitmusRT, pgmRT, etc. are prepared for the experiment here, so the precondition is that litmusRT and pgmRT have been compiled and installed, and the current system kernel is litmusRT

download

Clone the source code to a directory

root@ubuntu:/home/szc/cpu-gpu/openvx# git clone https://github.com/Yougmark/opencv.git hog

Configuration

Enter the directory and modify CMakeLists.txt

root@ubuntu:/home/szc/cpu-gpu/openvx# cd hog
root@ubuntu:/home/szc/cpu-gpu/openvx/hog# vim CMakeLists.txt

The modification content is as follows, change the directory of liblitmus and pgm to your own

set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} pgm boost_graph boost_filesystem boost_system)# litmus)

ocv_include_directories("/home/szc/litmus/liblitmus/include")  
ocv_include_directories("/home/szc/litmus/liblitmus/arch/x86/include")
ocv_include_directories("/home/szc/litmus/liblitmus/arch/x86/include/uapi")
ocv_include_directories("/home/szc/litmus/liblitmus/arch/x86/include/generated/uapi")

link_directories("/home/szc/cpu-gpu/openvx/pgm/")
link_directories("/home/szc/litmus/liblitmus/")

If you need to debug with gdb, you also need to add C_FLAGS and CXX_FLAGS above this file (look at the first line)

set(CMAKE_C_FLAGS "-g ")
set(CMAKE_CXX_FLAGS "-g ")

Compile

Create and enter the build directory, generate Makefile

root@ubuntu:/home/szc/cpu-gpu/openvx/hog# mkdir build && cd build
root@ubuntu:/home/szc/cpu-gpu/openvx/hog/build/bin# cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D BUILD_EXAMPLES=Yes -D ENABLE_CXX11=Yes -D BUILD_opencv_cudacodec=OFF ..

Compile hog

root@ubuntu:/home/szc/cpu-gpu/openvx/hog/build# make -j6

test

test

Download the test video https://github.com/opencv/opencv_extra/blob/master/testdata/gpu/video/768x576.avi , put it in the data directory under the build directory, and then run bin/example_tapi_hog

root@ubuntu:/home/szc/cpu-gpu/openvx/hog/build/bin# ./example_tapi_hog

This is an example of pedestrian detection, the running screenshot is as follows

Conclusion

Even if the experiment runs through here, we can debug the code inside, mainly samples/gpu/hog.cpp, which is the corresponding part of the experimental paper. If you have a student mailbox, you can use Clion.

When debugging and analyzing the hog code, I found that it uses a lot of cuda APIs (closed source, source tracking can end here), because this experiment is based on OpenVX's CPU-GPU heterogeneous scheduling experiment, then you need to be familiar with it. CUDA's official documents are mainly programming guides and best practices.

Guess you like

Origin blog.csdn.net/qq_37475168/article/details/109686640