1

我正在实现视频拼接纸并使用 CMake 生成 make 文件。当 CMake 使用 OpenCV 的拼接模块(尤其是搅拌机部分)编译代码时,似乎 CMake 以某种方式未能为编译器传递正确的参数。制作进度因此错误而停止:

/usr/bin/c++   -DOPENCV_TRAITS_ENABLE_DEPRECATED -I/home/kra/dev/Stitcher/include -isystem /usr/local/include -isystem /usr/local/include/opencv  -Wall -Wextra -O3 -DNDEBUG   -std=gnu++11 -o CMakeFiles/stitcher.dir/src/solver.cpp.o -c /home/kra/dev/Stitcher/src/solver.cpp
In file included from /usr/include/c++/5/vector:64:0,
                 from /usr/include/c++/5/bits/random.h:34,
                 from /usr/include/c++/5/random:49,
                 from /usr/include/c++/5/bits/stl_algo.h:66,
                 from /usr/include/c++/5/algorithm:62,
                 from /usr/local/include/opencv2/core/base.hpp:55,
                 from /usr/local/include/opencv2/core.hpp:54,
                 from /usr/local/include/opencv2/stitching/detail/blenders.hpp:50,
                 from /home/kra/dev/Stitcher/src/utilities.cpp:1:
/usr/include/c++/5/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = cv::cuda::GpuMat; _Alloc = std::allocator<cv::cuda::GpuMat>]’:
/usr/include/c++/5/bits/stl_vector.h:425:33:   required from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = cv::cuda::GpuMat; _Alloc = std::allocator<cv::cuda::GpuMat>]’
/usr/local/include/opencv2/stitching/detail/blenders.hpp:126:18:   required from here
/usr/include/c++/5/bits/stl_vector.h:161:9: error: invalid use of incomplete type ‘class cv::cuda::GpuMat’
         - this->_M_impl._M_start); }
         ^
In file included from /usr/local/include/opencv2/core.hpp:54:0,
                 from /usr/local/include/opencv2/stitching/detail/blenders.hpp:50,
                 from /home/kra/dev/Stitcher/src/utilities.cpp:1:
/usr/local/include/opencv2/core/base.hpp:717:22: note: forward declaration of ‘class cv::cuda::GpuMat’
     class CV_EXPORTS GpuMat;
  • Ubuntu 16.04
  • OpenCV 3.4.1

我的 CMake 如下所示:

CMAKE_MINIMUM_REQUIRED (VERSION 3.2)
PROJECT(VideoStitcher CXX)

FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(include)

SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON)

if(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE Release)
endif()

SET(CMAKE_CXX_FLAGS "-Wall -Wextra")

FILE(GLOB all_sources "src/*.cpp")

ADD_EXECUTABLE(stitcher ${all_sources})
TARGET_LINK_LIBRARIES(
  stitcher
  boost_filesystem
  boost_system
  ${OpenCV_LIBS}
)

这很奇怪,因为 OpenCV 成功构建了所有 CPP 示例,我什至可以使用类似于上面的 CMake构建stitching_detailed.cpp示例。以下是我的 OpenCV 构建信息:

-- General configuration for OpenCV 3.4.1 =====================================
--   Version control:               3.4.1
-- 
--   Extra modules:
--     Location (extra):            /home/kra/Softwares/opencv_contrib/modules
--     Version control (extra):     3.4.1-dirty
-- 
--   Platform:
--     Timestamp:                   2018-06-06T22:48:37Z
--     Host:                        Linux 4.13.0-43-generic x86_64
--     CMake:                       3.5.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RelWithDebInfo
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (3 files):          + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (1 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      
--     Linker flags (Debug):        
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-8.0/lib64
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 python_bindings_generator reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    js world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cvv dnn_modern java matlab ovis python2 ts viz
--     Applications:                examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        YES (ver 3.18.9)
--       GThread :                  YES (ver 2.48.2)
--       GtkGlExt:                  NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /home/kra/Softwares/anaconda3/lib/libz.so (ver 1.2.11)
--     JPEG:                        /home/kra/Softwares/anaconda3/lib/libjpeg.so (ver 90)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /home/kra/Softwares/anaconda3/lib/libpng.so (ver 1.6.32)
--     TIFF:                        /home/kra/Softwares/anaconda3/lib/libtiff.so (ver 42 / 4.0.8)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 56.60.100)
--       avformat:                  YES (ver 56.40.101)
--       avutil:                    YES (ver 54.31.100)
--       swscale:                   YES (ver 3.1.101)
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h
--     gPhoto2:                     NO
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2017.0.3 [2017.0.3]
--            at:                   /home/kra/Softwares/opencv/build/3rdparty/ippicv/ippicv_lnx
--     Intel IPP IW:                sources (2017.0.3)
--               at:                /home/kra/Softwares/opencv/build/3rdparty/ippicv/ippiw_lnx
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.2.92)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 8.0, CUFFT CUBLAS)
--     NVIDIA GPU arch:             20 30 35 37 50 52 60 61
--     NVIDIA PTX archs:
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/kra/Softwares/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /home/kra/Softwares/anaconda3/bin/python3 (ver 3.6.2)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1 (ver 3.6.2)
--     numpy:                       /home/kra/Softwares/anaconda3/lib/python3.6/site-packages/numpy/core/include (ver 1.13.3)
--     packages path:               lib/python3.6/site-packages
-- 
--   Python (for build):            /home/kra/Softwares/anaconda3/envs/oc/bin/python3.5
--     Pylint:                      /home/kra/Softwares/anaconda3/bin/pylint (ver: 1.7.2, checks: 116)
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------

我尝试了各种方法将 CUDA 添加到 CMake,但没有运气。我在互联网上也找不到类似的问题。

4

0 回答 0