Introduction: To participate in the Intel Cup and the big Chuang need to Openpose's demo to make some customization and then incoming neural network, yesterday just completed the development environment configuration, because the first time saw Openpose, Caffe such a large project, coupled with the unfamiliar with Linux, Groping for a long time to find custom Openpose demo method. Because a similar tutorial on the internet did not, so decided to write down, although for familiar with Linux friends to compare the basis (the problem solving method is not even very normative), but I believe that this tutorial can still help me as a small white
0. Development environment Preparation
Before that, you need to configure a openpose, Caffe, clion development environment. For Openpose and Caffe configurations, refer to my previous article Ubuntu16.04 configure Cuda8.0+cudnn5.1+caffe+openpose Clion installation please Click here to visit JetBrains's official website to download (if it is college students can receive free JetBrains family bucket, the specific method no longer repeat)
1. Create a project in Clion and import code
Click New Project to create the item, and the project name takes a random
Click Create should come out such an interface
Then view the files in the Openpose/examples/tutorial_wrapper directory
Open a. cpp file at random (depending on your requirements) and copy the code to the Clipboard
Then open Clion, create a new Openpose.cpp file under the project root, and paste the code you just copied in
Right-click the original main.cpp to remove it
2. Configure the project's CMakeLists.txt file and run the programWe openCMakeLists.txt files under the Openpose/examples/tutorial_wrapper directory, look at its code, find this section in the following figure, and copy it to the Clipboard
Paste it into the CMakeLists.txt file in the Openposedemo project (that is, the project created in Clion), replacing the add_executable (Openposedemo openpose.cpp). The results are shown in the following figure
Replace variables such as ${identifiers} as follows (the principle of this step is well understood, and friends who are familiar with this aspect can do it in a better way) ${exe_name} Replace with Openposedemo.bin ${example_file} Replaced by Openpose.cpp
The most important thing is: Configure the dynamic-link library (I don't know if this is the way to say it), because I have only one PM base in this area, so I can only check the libraries that need to be linked by repeatedly debug, and then manually search the directory on the computer to configure it, I'm sure there will be a better way I would also like to see the predecessors of this blog if there is a suitable solution to contact me to make corrections, the future if I find a more simple and universal method will also take the initiative to correctThe CMakeLists.txt configuration for the first. cpp file under the Openpose/examples/tutorial_wrapper folder is as follows
Cmake_minimum_required (VERSION 3.9)
project (Openposedemo)
set (Cmake_cxx_standard)
link_ Directories (/usr/lib)
add_executable (openposedemo.bin openpose.cpp)
target_link_libraries ( Openposedemo.bin openpose libglog.so libgflags.so libpthread.so/usr/lib/x86_64-linux-gnu/libopencv_ Objdetect.so.2.4/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4/usr/lib/x86_64-linux-gnu/libopencv_ imgproc.so.2.4/usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4 ${caffe_libs} ${mkl_libs} ${GLUT_LIBRARY} ${ Spinnaker_lib})
Next, add the training model to the project file, as follows: Open the Openpose folder and copy the models folder under it
Paste it into the directory where the Openposedemo.bin file belongs
In fact, it's already possible to build the project and run it at this point, and if you want to make some (symbolic) changes to the project, go ahead.
3. Change the source code to generate a custom programCopy the examples folder under the Openpose folder to the directory that the Openposedemo.bin file belongs to, as shown in the following figure
Then make the following changes to the source code
Compile and run the program