您的位置:首页 > 理论基础

【视频开发】【计算机视觉】doppia编译之四:安装其他库、编译和运行doppia

2017-06-28 01:17 302 查看
(与本节内容无关///////////////////////////保存图片参数为—-gui.save_all_screenshots true////////////////////) 

在我们安装好CUDA、boost、OpenCV之后,接下来的一些库(libSDL、protobuf等)的安装,我们都可以用系统内部的程序进行安装。比如

安装libSDL,我们终端输入
apt-cache search libsdl
1
1

系统会给出一系列程序,我们选择其中的libsdl1.2-dev进行安装。
sudo apt-get install libsdl1.2-dev
1
1

(这里注意不要安装libsdl2-dev,因为安装之后生成的文件夹是SDL2,之后doppia调用时会出现找不到“SDL files”的错误)

安装protobuf库,则是我经过多番测试,得到的能够通过v1,v2测试的安装方法。(之前尝试安装protobuf2.5.0和protobuf2.4.1,doppia都找不到路径,而想把它们删除又删除不了,很麻烦),之后我测试了几个自带的protobuf库,发现安装以下四个库能够通过v1,v2的测试,安装命令为:
sudo apt-get install libprotobuf-dev libprotoc-dev python-protobuf protobuf-compiler
1
1

切换到doppia目录下,运行
sudo sh ./generate_protocol_buffer_files.sh
1
1

protobuf通过doppia-v1检测的返回信息为
Generating objects detection files...
(Ground plane and video input files not yet handled by this script)
End of game. Have a nice day!
1
2
3
1
2
3

protobuf通过doppia-v2检测的返回信息为
+ cd src/objects_detection/
+ protoc --cpp_out=./ detector_model.proto detections.proto
+ protoc --python_out=../../tools/objects_detection/ detector_model.proto detections.proto
+ cd ../..
+ cd src/stereo_matching/ground_plane/
+ protoc --cpp_out=./ plane3d.proto
+ protoc --python_out=../../../tools/stixels_evaluation plane3d.proto
+ cd ../../..
+ cd src/stereo_matching/stixels/
+ protoc --cpp_out=./ -I. -I../ground_plane --include_imports stixels.proto ground_top_and_bottom.proto
--include_imports only makes sense when combined with --descriptor_set_out.
+ protoc --python_out=../../../tools/stixels_evaluation -I. -I../ground_plane --include_imports stixels.proto ground_top_and_bottom.proto
--include_imports only makes sense when combined with --descriptor_set_out.
+ cd ../../..
+ cd src/video_input/calibration
+ protoc --cpp_out=./ calibration.proto
+ cd ../../..
+ cd src/helpers/data
+ protoc --cpp_out=./ DataSequenceHeader.proto
+ protoc --python_out=../../../tools/data_sequence DataSequenceHeader.proto
+ cd ../../..
+ cd src/helpers
+ cd ../..
+ cd src/tests/data_sequence/
+ protoc --cpp_out=./ TestData.proto
+ cd ../../..
+ echo End of game. Have a nice day!
End of game. Have a nice day!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

到这里,我们该安装的库大部分已经安装成功,接下来就可以开始编译doppia啦!(至于可能还缺少的库,可以根据doppia的错误提示进行安装)

编译运行doppia/src/applications/objects_detection 

由于我只需要用到doppia的objects_detection的功能,而之前我在编译doppia-v2时,ground_estimation和stixel_world都能编译运行。所以这次在编译doppia-v1时,我就直接切入“主题”,编译运行objects_detection。下面也主要是列出我在编译objects_detection是遇到的问题以及相应的解决方案。

错误一,创建(build)错误 

error:
/home/mx/doppia/src/applications/objects_detection/../../../src/helpers/data/DataSequence.hpp:293:56: error: invalid use of incomplete type ‘class google::protobuf::io::CodedInputStream’
const bool read_size_success = input_coded_stream_p->ReadLittleEndian64(&size);
1
2
1
2

solution: 


doppia/src/helpers/data/DataSequence.hpp
1
1

头文件中,在
#include "DataSequenceHeader.pb.h"
#include <google/protobuf/io/zero_copy_stream_impl.h>
1
2
1
2

两行之间添加一行新的引用,如下,
#include "DataSequenceHeader.pb.h"
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
1
2
3
1
2
3

错误二,创建(build)错误 

error:
/home/mx/doppia/src/applications/objects_detection/../../../src/objects_detection/gpu/integral_channels_detector.cu.hpp:23:9: error: ‘fast_stage_t’ in ‘class doppia::SoftCascadeOverIntegralChannelsModel’ does not name a type
typedef SoftCascadeOverIntegralChannelsModel::fast_stage_t cascade_stage_t;
^
/home/mx/doppia/src/applications/objects_detection/../../../src/objects_detection/gpu/integral_channels_detector.cu.hpp:33:36: error: ‘cascade_stage_t’ was not declared in this scope
typedef Cuda::DeviceMemoryLinear2D<cascade_stage_t> gpu_detection_cascade_per_scale_t;
^
/home/mx/doppia/src/applications/objects_detection/../../../src/objects_detection/gpu/integral_channels_detector.cu.hpp:33:51: error: template argument 1 is invalid
typedef Cuda::DeviceMemoryLinear2D<cascade_stage_t> gpu_detection_cascade_per_scale_t;
^
/home/mx/doppia/src/applications/objects_detection/../../../src/objects_detection/gpu/integral_channels_detector.cu.hpp:33:86: error: invalid type in declaration before ‘;’ token
typedef Cuda::DeviceMemoryLinear2D<cascade_stage_t> gpu_detection_cascade_per_scale_t;
1
2
3
4
5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
10
11

这里出现错误原因是因为common_settings.cmake中没有添加cuda链接库路径。 

solution: 

编辑common_settings.cmake,在其中添加一个条件项
elseif(${HOSTNAME} STREQUAL  "mx-pc")
message(STATUS "Using mx-pc optimisation options")

option(USE_GPU "Should the GPU be used ?" TRUE)
set(CUDA_BUILD_CUBIN OFF)
set(local_CUDA_LIB_DIR "/usr/local/cuda/lib64")
set(cuda_LIBS "")
1
2
3
4
5
6
7
1
2
3
4
5
6
7

这里mx-pc是我电脑的主机名,你需要将它改成自己电脑的主机名。

错误三,创建(build)错误 

error:
/home/mx/doppia/src/objects_detection/SoftCascadeOverIntegralChannelsFastFractionalStage.cpp:24:9: error: ‘swap’ is not a member of ‘std’
std::swap(weak_classifier.level2_true_node, weak_classifier.level2_false_node);
1
2
1
2

solution: 


doppia/src/objects_detection/SoftCascadeOverIntegralChannelsFastFractionalStage.cpp
1
1

文件开头添加一行引用
#include<iostream>
1
1

解决了以上三个错误后,doppia就可以创建(build)成功啦!但要想运行成功,还得改正以下2个错误。

错误四,链接(link)错误 

error:
Linking CXX executable objects_detection
/usr/bin/ld: cannot find -lboost_program_options-mt
/usr/bin/ld: cannot find -lboost_filesystem-mt
/usr/bin/ld: cannot find -lboost_system-mt
/usr/bin/ld: cannot find -lboost_thread-mt
collect2: error: ld returned 1 exit status
make[2]: *** [objects_detection] 错误 1
make[1]: *** [CMakeFiles/objects_detection.dir/all] 错误 2
make: *** [all] 错误 2
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9

这里出现错误的原因,是boost库链接出错,这时候我们需要修改CMakeList.txt文件,这里我就直接把CMakeList.txt贴出来,修改的地方做过注释。 

solution:
# This is a CMake build file, for more information consult:
# http://en.wikipedia.org/wiki/CMake # and
# http://www.cmake.org/Wiki/CMake # http://www.cmake.org/cmake/help/syntax.html # http://www.cmake.org/Wiki/CMake_Useful_Variables # http://www.cmake.org/cmake/help/cmake-2-8-docs.html 
# to compile the local code you can use: cmake ./ && make -j2

# ----------------------------------------------------------------------
# Base CMake setup

cmake_minimum_required (VERSION 2.6)

set(doppia_root "../../..")

set(CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "./" ${doppia_root} ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "/home/rodrigob/work/code/doppia_references/cuda/FindCUDA/CMake/cuda" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "/users/visics/rbenenso/code/references/cuda/FindCUDA/CMake/cuda" ${CMAKE_MODULE_PATH})

# ----------------------------------------------------------------------
# Setup the project

include(FindPkgConfig)
project (ObjectsDetection)

# ----------------------------------------------------------------------
# Site specific configurations
include(${doppia_root}/common_settings.cmake)

# ----------------------------------------------------------------------
# Setup required libraries
pkg_check_modules(libpng REQUIRED libpng)
#pkg_check_modules(OpenEXR REQUIRED OpenEXR)
pkg_check_modules(opencv REQUIRED opencv>=2.3)
#set(vw_LIBRARIES "-lvwCore -lvwImage -lvwStereo -lvwFileIO -lvwMath -lvwInterestPoint")

set(opencv_LIBRARIES
opencv_core opencv_imgproc opencv_highgui opencv_ml
opencv_video opencv_features2d
opencv_calib3d
#opencv_objdetect opencv_contrib
opencv_legacy opencv_flann
) # quick hack for opencv2.4 support

# 修改1:find where is boost
#(+)find_package(Boost REQUIRED
#(+)   COMPONENTS program_options filesystem system thread
#(+) )
find_package(Boost REQUIRED
COMPONENTS program_options filesystem system thread
)

# ----------------------------------------------------------------------
# Setup CUDA
if(USE_GPU)
find_package(CUDA 4.0 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_CUT_INCLUDE_DIR})
endif(USE_GPU)

# ----------------------------------------------------------------------
# Setup link and include directories

set(local_LIBRARY_DIRS
"/usr/local/lib"
"/users/visics/rbenenso/no_backup/usr/local/lib"
"/usr/lib64"
"/usr/lib64/atlas"
"/usr/lib/sse2/atlas"
"/usr/lib/llvm-2.8/lib"
${local_CUDA_LIB_DIR}
)
set(local_INCLUDE_DIRS
"/users/visics/rbenenso/no_backup/usr/local/include"
"/usr/include/eigen2/"
"/usr/local/include/eigen2"
"/usr/local/cuda/include"
${CUDA_INCLUDE_DIRS}
)

link_directories(
${libpng_LIBRARY_DIRS}
${OpenEXR_LIBRARY_DIRS}
${opencv_LIBRARY_DIRS}
${local_LIBRARY_DIRS}
)

include_directories(
"${doppia_root}/libs"
"${doppia_root}/src"
${libpng_INCLUDE_DIRS}
${OpenEXR_INCLUDE_DIRS}
${opencv_INCLUDE_DIRS}
${local_INCLUDE_DIRS}
"${doppia_root}/libs/cudatemplates/include"
)

if(USE_GPU)
cuda_include_directories("${doppia_root}/libs/")
endif(USE_GPU)

# ----------------------------------------------------------------------
# Collect source files

set(doppia_src "${doppia_root}/src")
set(doppia_stereo "${doppia_root}/src/stereo_matching")

file(GLOB SrcCpp
"./ObjectsDetection*.cpp"
"./draw*.cpp"
"${doppia_src}/*.cpp"
#"${doppia_src}/objects_detection/*.c*"
"${doppia_src}/objects_detection/Abstract*.c*"
"${doppia_src}/objects_detection/*Converter.c*"
"${doppia_src}/objects_detection/Base*.c*"
"${doppia_src}/objects_detection/*Factory.c*"
"${doppia_src}/objects_detection/Greedy*.c*"
"${doppia_src}/objects_detection/Detection*.c*"
"${doppia_src}/objects_detection/*Model.c*"
"${doppia_src}/objects_detection/*Stage.c*"
"${doppia_src}/objects_detection/*Integral*.c*"
"${doppia_src}/objects_detection/MultiscalesIntegral*.c*"
"${doppia_src}/objects_detection/integral_channels/Integral*.cpp"
"${doppia_src}/objects_detection/FastestPedestrian*.c*"
"${doppia_src}/objects_detection/DetectorSearchRange.c*"
"${doppia_src}/objects_detection/*.pb.c*"
"${doppia_src}/objects_detection/non_maximal_suppression/*.c*"

"${doppia_src}/objects_tracking/*.cpp"

"${doppia_src}/applications/*.cpp"
"${doppia_src}/applications/stixel_world/*Gui.cpp"
"${doppia_src}/applications/stixel_world/draw*.cpp"

#"${doppia_stereo}/*.cpp"
"${doppia_stereo}/cost_volume/*CostVolume.cpp"
"${doppia_stereo}/cost_volume/*CostVolumeEstimator*.cpp"
"${doppia_stereo}/cost_volume/DisparityCostVolumeFromDepthMap.cpp"
"${doppia_stereo}/cost_functions.cpp"
"${doppia_stereo}/CensusCostFunction.cpp"
"${doppia_stereo}/CensusTransform.cpp"
"${doppia_stereo}/GradientTransform.cpp"
"${doppia_stereo}/AbstractStereoMatcher.cpp"
"${doppia_stereo}/AbstractStereoBlockMatcher.cpp"
"${doppia_stereo}/SimpleBlockMatcher.cpp"
"${doppia_stereo}/MutualInformationCostFunction.cpp"
"${doppia_stereo}/ConstantSpaceBeliefPropagation.cpp"
"${doppia_stereo}/qingxiong_yang/*.cpp"
"${doppia_stereo}/SimpleTreesOptimizationStereo.cpp"
"${doppia_stereo}/OpenCvStereo.cpp"

"${doppia_stereo}/ground_plane/*.cpp"
"${doppia_stereo}/stixels/*.cpp"
#"${doppia_stereo}/stixels/*.cc"
"${doppia_src}/video_input/*.cpp"
"${doppia_src}/video_input/calibration/*.c*"
"${doppia_src}/video_input/preprocessing/*.cpp"
#"${doppia_src}/features_tracking/*.cpp"
"${doppia_src}/image_processing/*.cpp"
"${doppia_src}/drawing/gil/*.cpp"
)

file(GLOB HelpersCpp
#"${doppia_src}/helpers/*.cpp"
"${doppia_src}/helpers/data/*.c*"
"${doppia_src}/helpers/any_to_string.cpp"
"${doppia_src}/helpers/get_section_options.cpp"
"${doppia_src}/helpers/Log.cpp"
"${doppia_src}/helpers/loggers.cpp"
"${doppia_src}/helpers/AlignedImage.cpp"
"${doppia_src}/helpers/replace_environment_variables.cpp"
"${doppia_src}/helpers/objects_detection/*.cpp"
)

file(GLOB SrcGpuCpp
"${doppia_src}/objects_detection/Gpu*.cpp"
"${doppia_src}/objects_detection/integral_channels/Gpu*.cpp"
"${doppia_src}/helpers/gpu/*.cpp"

#"${doppia_stereo}/SimpleTreesGpuStereo.cpp"
)

file(GLOB SrcCuda
"${doppia_src}/objects_detection/integral_channels/gpu/*.cu"
"${doppia_src}/objects_detection/integral_channels/gpu/*.cpp"
"${doppia_src}/objects_detection/gpu/*.cu"
"${doppia_src}/objects_detection/gpu/*.cpp"

#"${doppia_src}/helpers/gpu/*.cu"

#  "${doppia_stereo}/*.cu.c*"
#  "${doppia_stereo}/*.cu"
#  "${doppia_stereo}/gpu/*.cu.c*"
#  "${doppia_stereo}/gpu/*.cu"
)

list(REMOVE_ITEM SrcCpp ${SrcCuda}) # just in case

if(USE_GPU)

# add GPU related source code to the executable list
list(APPEND SrcCpp ${SrcGpuCpp})

# add GPU related libraries
list(APPEND opencv_LIBRARIES opencv_gpu)

# ----------------------------------------------------------------------
# Compile CUDA stuff
cuda_include_directories(${local_CUDA_CUT_INCLUDE_DIRS})
cuda_include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_CUT_INCLUDE_DIR} ${local_CUDA_CUT_INCLUDE_DIR})
link_directories(${local_CUDA_CUT_LIBRARY_DIRS})

cuda_add_library(cuda_stuff_library ${SrcCuda})
target_link_libraries(cuda_stuff_library
${CUDA_LIBRARIES}
${cutil_LIB}
)

#set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --generate-line-info) # used during profiling

endif(USE_GPU)
# ----------------------------------------------------------------------
# Create the executable
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") # required for unrestricted unions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -p") # add gprof information

add_library(cpp_stuff_library  ${SrcCpp} ${HelpersCpp})

add_executable(objects_detection "./objects_detection.cpp")

target_link_libraries(objects_detection

cpp_stuff_library

${cg_LIBRARIES}
# linking with CgGL _after_ boost_program_options generates a segmentation fault ! boost_program_options 1.39 has a bug
#修改2:link to boost
#(-)boost_program_options-mt boost_filesystem-mt boost_system-mt boost_thread-mt
#(+)${Boost_LIBRARIES}
${Boost_LIBRARIES}
protobuf pthread
SDL X11 Xext #Xrandr
gomp
${libpng_LIBRARIES} jpeg
#  ${OpenEXR_LIBRARIES}
${opencv_LIBRARIES}

#${vw_LIBRARIES}
#csparse sparse spblas mv
#lapack blas atlas

${google_perftools_LIBS} # enables profiling, see http://code.google.com/p/google-perftools 
#`OcelotConfig -l`
#ocelot
#boost_system-mt boost_filesystem-mt boost_thread-mt
#GLEW
#LLVMAsmParser LLVMX86Disassembler LLVMX86AsmParser LLVMX86CodeGen LLVMSelectionDAG
#LLVMAsmPrinter LLVMMCParser LLVMX86AsmPrinter LLVMX86Info LLVMJIT
#LLVMExecutionEngine LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa
#LLVMAnalysis LLVMTarget LLVMMC LLVMCore LLVMSupport LLVMSystem
)

if(USE_GPU)
target_link_libraries(objects_detection cuda_stuff_library ${local_CUDA_LIB})
endif(USE_GPU)
# ----------------------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271

到这里就OK啦!

最后运行成功你会看到一个简短地video,以及下面这样的信息
2015-05-09 16:33:23 {7feb06974880} [ BaseIntegralChannelsDetector ] : Warning: At scale index 47 the detection window size is larger than the biggest ground plane corridor. Setting the detection search to a single line.
scale_index == 47, original_height == 18, updated_height == 1
Expected speed gain == 5.28x (num pixels original/updated)
GpuVeryFastIntegralChannelsDetector::compute_v2 max search range (min_x, min_y; max_x, max_y) == (0, 0; 153, 58)
2015-05-09 16:33:23 {7feb06974880} [ GpuIntegralChannelsDetector ] : scaled_x == 640, scaled_y == 480
Requested frame number 11 but frames should be in range (0, 10)
Processed a total of 10 input frames
Average objects detection speed per iteration 29.36 [Hz] (in the last 10 iterations)
End of game, have a nice day.
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9

好啦,doppia编译到此也就结束啦! 

希望这几篇文章能帮助正在读博客的你。

doppia及作者相关介绍链接: 
http://blog.csdn.net/xizero00/article/details/43227019 
https://bitbucket.org/rodrigob/doppia
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐