博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
opencv 4.0 + linux + cuda静态编译
阅读量:6261 次
发布时间:2019-06-22

本文共 5127 字,大约阅读时间需要 17 分钟。

#下载最新的opencv

git clone "https://github.com/opencv/opencv.git"

git clone "https://github.com/opencv/opencv_contrib.git"

#定义自己的生成目录

mkdir 20190509_cuda
mkdir -p opencv-master/build_cuda
cd opencv-master/build_cuda

#生成配置的时候选择带上opencv-contrib

#  注意 -DCUDA_CUDA_LIBRARY= 这个一定要加,这个是配置项的一个BUG,只能从这里绕过去。地址是cuda库中libcuda.so的绝对路径

cmake -DOPENCV_EXTRA_MODULES_PATH=/home/admin/opencv/opencv_contrib-master/modules -DCUDA_CUDA_LIBRARY=/usr/local/cuda-9.0/lib64/stubs/libcuda.so -DCMAKE_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/stubs/ ..

#执行ccmake,配置编译选项

ccmake ..

#按t,切换进入高级模式

#主要修改的配置项如下:

1 //Build CUDA modules stubs when no CUDA SDK  2 BUILD_CUDA_STUBS:BOOL=OFF  3   4 //Create build rules for OpenCV Documentation  5 BUILD_DOCS:BOOL=OFF  6   7 //Build all examples  8 BUILD_EXAMPLES:BOOL=OFF  9  10 //Create Java wrapper exporting all functions of OpenCV library 11 // (requires static build of OpenCV modules) 12 BUILD_FAT_JAVA_LIB:BOOL=OFF 13  14 //Build IPP IW from source 15 BUILD_IPP_IW:BOOL=OFF 16  17 //Build Intel ITT from source 18 BUILD_ITT:BOOL=OFF 19  20 //Build libjasper from source 21 BUILD_JASPER:BOOL=OFF 22  23 //Enable Java support 24 BUILD_JAVA:BOOL=OFF 25  26 //Build libjpeg from source 27 BUILD_JPEG:BOOL=OFF 28  29 //Build openexr from source 30 BUILD_OPENEXR:BOOL=OFF 31  32 //Build performance tests 33 BUILD_PERF_TESTS:BOOL=OFF 34  35 //Build libpng from source 36 BUILD_PNG:BOOL=OFF 37  38 //Force to build libprotobuf from sources 39 BUILD_PROTOBUF:BOOL=OFF 40  41 //Build shared libraries (.dll/.so) instead of static ones (.lib/.a) 42 BUILD_SHARED_LIBS:BOOL=OFF 43  44 //Download and build TBB from source 45 BUILD_TBB:BOOL=OFF 46  47 //Build accuracy & regression tests 48 BUILD_TESTS:BOOL=OFF 49  50 //Build libtiff from source 51 BUILD_TIFF:BOOL=OFF 52  53 //Build WebP from source 54 BUILD_WEBP:BOOL=OFF 55  56 //Include debug info into release binaries ('OFF' means default 57 // settings) 58 BUILD_WITH_DEBUG_INFO:BOOL=OFF 59  60 //Enables dynamic linking of IPP (only for standalone IPP) 61 BUILD_WITH_DYNAMIC_IPP:BOOL=OFF 62  63 //Build zlib from source 64 BUILD_ZLIB:BOOL=OFF 65  66 //Include opencv_face module into the OpenCV build 67 BUILD_opencv_face:BOOL=OFF 68  69 //Include opencv_highgui module into the OpenCV build 70 BUILD_opencv_highgui:BOOL=OFF 71  72 //Include opencv_java_bindings_generator module into the OpenCV 73 // build 74 BUILD_opencv_java_bindings_generator:BOOL=OFF 75  76 //Include opencv_xfeatures2d module into the OpenCV build 77 BUILD_opencv_xfeatures2d:BOOL=OFF 78  79 //Choose the type of build, options are: None Debug Release RelWithDebInfo 80 // MinSizeRel ... 81 CMAKE_BUILD_TYPE:STRING=Debug 82  83 //Installation Directory 84 CMAKE_INSTALL_PREFIX:PATH=/home/admin/opencv/2019-05-09_cuda 85  86 //"cudart" library 87 CUDA_CUDART_LIBRARY:FILEPATH=/usr/local/cuda/lib64/libcudart.so 88  89 //Path to a program. 90 CUDA_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda/bin/nvcc 91  92 //Path to a file. 93 CUDA_TOOLKIT_INCLUDE:PATH=/usr/local/cuda/include 94  95 //Toolkit location. 96 CUDA_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda 97  98 //Use the static version of the CUDA runtime library if available 99 CUDA_USE_STATIC_CUDA_RUNTIME:BOOL=ON100 101 //Enable ADE framework (required for Graph API module)102 WITH_ADE:BOOL=OFF103 104 //Include Aravis GigE support105 WITH_ARAVIS:BOOL=OFF106 107 //Include NVidia Cuda Runtime support108 WITH_CUDA:BOOL=ON109 110 //Include Intel Inference Engine support111 WITH_INF_ENGINE:BOOL=OFF112 113 //Include Intel IPP support114 WITH_IPP:BOOL=OFF115 116 //Include Intel ITT support117 WITH_ITT:BOOL=OFF118 119 //Include JPEG2K support120 WITH_JASPER:BOOL=OFF121 122 //Include JPEG support123 WITH_JPEG:BOOL=OFF124 125 //Include Lapack library support126 WITH_LAPACK:BOOL=OFF127 128 //Include NVidia Video Decoding library support129 WITH_NVCUVID:BOOL=ON130 131 //Include PNG support132 WITH_PNG:BOOL=OFF133 134 //Enable libprotobuf135 WITH_PROTOBUF:BOOL=OFF136 137 //Include Intel TBB support138 WITH_TBB:BOOL=OFF139 140 //Include TIFF support141 WITH_TIFF:BOOL=OFF142 143 //Include Vulkan support144 WITH_VULKAN:BOOL=OFF145 146 //Include WebP support147 WITH_WEBP:BOOL=OFF

 

make -j 20

make install

 =============================

2019-05-10补充:

//Build openexr from source

BUILD_OPENEXR:BOOL=ON

//Include ILM support via OpenEXR

WITH_OPENEXR:BOOL=ON

以上两项要打开,否则链接程序的时候出现大量如下错误:

/home/admin/opencv/opencv-master/modules/imgcodecs/src/grfmt_exr.cpp:250: undefined reference to `Imf::Slice::Slice(Imf::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'/home/admin/opencv/opencv-master/modules/imgcodecs/src/grfmt_exr.cpp:252: undefined reference to `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)'/home/admin/opencv/opencv-master/modules/imgcodecs/src/grfmt_exr.cpp:257: undefined reference to `Imf::Slice::Slice(Imf::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'/home/admin/opencv/opencv-master/modules/imgcodecs/src/grfmt_exr.cpp:259: undefined reference to `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)'

 

转载于:https://www.cnblogs.com/ahfuzhang/p/10839495.html

你可能感兴趣的文章
计算机程序的思维逻辑 (8) - char的真正含义
查看>>
2019 年技术大趋势预测
查看>>
推荐一款基于vue的滚动条插件vuescroll
查看>>
安全圈有多大?也许就这么大!
查看>>
App基于手机壳颜色换肤?先尝试一下用 KMeans 来提取图像中的主色
查看>>
RecyclerView的滚动事件研究
查看>>
XXL-MQ v1.2.2 发布,分布式消息队列
查看>>
多线程:GCD
查看>>
深度解读 2018 JavaScript 趋势报告(含视频)
查看>>
以 RAIDs 分析作为架构驱动力
查看>>
Rust 2018 年度调查报告
查看>>
Tensorflow快餐教程(1) - 30行代码搞定手写识别
查看>>
聊聊flink Table的Set Operations
查看>>
3.3 卷积神经网络进阶-Inception-mobile_net
查看>>
JS学习系列 06 - 变量对象
查看>>
Swift开发应用时如何更方便地使用颜色?
查看>>
ubuntu虚拟机设置静态ip(windows能够ping通ubuntu虚拟机)
查看>>
Redis高级特性介绍及实例分析
查看>>
Android的复选框的详细开发案例分析
查看>>
iOS FMDB数据库之增删改查使用
查看>>