码迷,mamicode.com
首页 > 系统相关 > 详细

opencv3.4.2 ubuntu16.04安装

时间:2018-08-21 11:38:09      阅读:683      评论:0      收藏:0      [点我收藏+]

标签:print   level   erro   make   tesseract   新建文件夹   git   ref   exe   

最近需要用用opencv。在阿里云服务器ubuntu16.04上安装部署了下。

 

没啥好说的,下载最新opencv-3.4.2 

文件准备

1.opencv-3.4.2.zip 
2. opencv_contrib-3.4.2.zip

(我是放在/home/myname/download/下)然后

wget https://github.com/Itseez/opencv/archive/3.4.2.zip

wget https://github.com/opencv/opencv_contrib/archive/3.4.2.zip

准备

先安装以下依赖包

sudo apt-get install build-essential  

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev  

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  

sudo apt-get install build-essential qt5-default ccache libv4l-dev libavresample-dev  libgphoto2-dev libopenblas-base libopenblas-dev doxygen  openjdk-8-jdk pylint libvtk6-dev

sudo apt-get install pkg-config

1.解压下载好的包:(我是放在/home/myname/download/下)然后

unzip opencv-3.4.2.zip
unzip opencv_contrib-3.4.2.zip

2.解压完后需要将opencv_contrib.zip提取到opencv目录下,同时在该目录下新建一个文件夹build:

cp -r opencv_contrib-3.3.1 opencv-3.3.1  #复制opencv_contrib到opencv目录下

cd opencv-3.4.21

mkdir build                              #新建文件夹build

编译

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.2/modules -D PYTHON_EXECUTABLE=/usr/bin/python3 -D BUILD_EXAMPLES=ON ..

 

make时出现错误:

 /usr/local/include/tesseract/baseapi.h: In member function ‘int tesseract::TessBaseAPI::Init(const char*, const char*)’:
/usr/local/include/tesseract/baseapi.h:235:50: error: ‘nullptr’ was not declared in this scope
     return Init(datapath, language, OEM_DEFAULT, nullptr, 0, nullptr, nullptr, false);
                                                  ^
/usr/local/include/tesseract/baseapi.h: In member function ‘Boxa* tesseract::TessBaseAPI::GetTextlines(Pixa**, int**)’:
/usr/local/include/tesseract/baseapi.h:413:51: error: ‘nullptr’ was not declared in this scope
     return GetTextlines(false, 0, pixa, blockids, nullptr);
                                                   ^
/usr/local/include/tesseract/baseapi.h: In member function ‘Boxa* tesseract::TessBaseAPI::GetComponentImages(tesseract::PageIteratorLevel, bool, Pixa**, int**)’:
/usr/local/include/tesseract/baseapi.h:464:75: error: ‘nullptr’ was not declared in this scope
     return GetComponentImages(level, text_only, false, 0, pixa, blockids, nullptr);
                                                                           ^
modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/build.make:62: recipe for target ‘modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/opencv_text_pch_dephelp.cxx.o‘ failed
make[2]: *** [modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/opencv_text_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:13717: recipe for target ‘modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/all‘ failed
make[1]: *** [modules/text/CMakeFiles/opencv_text_pch_dephelp.dir/all] Error 2
Makefile:160: recipe for target ‘all‘ failed
make: *** [all] Error 2
 
 
原因是C11选项未打开。技术分享图片修改
 opencv-3.4.2目录下面CMakeLists.txt 参考上图,添加一行即可。从新CMake
技术分享图片


然后 编译:
make
然后:
sudo make install

完事!
 
 

opencv3.4.2 ubuntu16.04安装

标签:print   level   erro   make   tesseract   新建文件夹   git   ref   exe   

原文地址:https://www.cnblogs.com/blueridge/p/9510177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!