Install opencv and opencv_contrib ubuntu16.04 & ubuntu14.04

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/weixin_39675633/article/details/82318491

Stepped on a lot of pits, write it down, avoid other people like me:

Separate installation opencvI believe we have no problem, but at the same installation opencv_contrib, the problems may occur, such as a few of the following questions:

  • ‘class cv::String’ has no member named ‘assign’, value->assign(buf.data(), size);
  • error: ‘class cv::AutoBuffer’ has no member named ‘data’, float * const wc = _wc.data();
  • ‘cv::kinfu::Params::PlatformType’ is not a class or namespace

These problems often encountered for starters, there are two main reasons summarize the following:

  • Not through git clonecloning download command opencvand opencv_contribtwo libraries, but by downloading the compressed form.
  • Use the opencvversion with opencv_contribinconsistent versions, the need to pay attention, fucked me for a long time.

Specific steps are given below:

  • Cloning opencvand opencv_contriblibrary
  git clone https://github.com/opencv/opencv.git
  cd opencv
  git clone https://github.com/opencv/opencv_contrib.git

After the above two steps, in opencva first you will be added to the opencv_contribfolder

  • View oepncvand opencv_contribversion
git checkout [按tab键]  #将得到类似下面的版本
2.2                    2.4.10.4               2.4.13.4               2.4.4-beta             2.4.7.2                3.0.0-beta             3.3.1                  3.4.3-openvino 
2.3.0                  2.4.11                 2.4.13.5               2.4.5                  2.4.7-rc1              3.0.0-rc1              3.3.1-cvsdk            FETCH_HEAD 
2.3.1                  2.4.12                 2.4.13.6               2.4.6                  2.4.8                  3.0-ocl-tech-preview   3.4                    HEAD 
2.4                    2.4.12.1               2.4.13.7               2.4.6.1                2.4.8.1                3.0-ocl-tp2            3.4.0                  master 
2.4.0                  2.4.12.2               2.4.2                  2.4.6.2                2.4.8.2                3.1.0                  3.4.0-rc               origin/2.4 
2.4.1                  2.4.12.3               2.4.3                  2.4.6.2r2              2.4.8.3                3.2.0                  3.4.1                  origin/3.4 
2.4.10                 2.4.13                 2.4.3.1                2.4.6.2r3              2.4.9                  3.2.0-rc               3.4.1-cvsdk            origin/HEAD 
2.4.10.1               2.4.13.1               2.4.3.2                2.4.6.2-rc1            2.4.9.1                3.3.0                  3.4.2                  origin/master 
2.4.10.2               2.4.13.2               2.4.3-rc               2.4.7                  3.0.0                  3.3.0-cvsdk            3.4.2-openvino         
2.4.10.3               2.4.13.3               2.4.4                  2.4.7.1                3.0.0-alpha            3.3.0-rc               3.4.3                  

git checkout 3.4.2 # 选择一个版本,例如这里我选择3.4.2版本,当然你也可以选择其他版本

cd opencv_contrib
git checkout [按tab键] 
3.0.0           3.0.0-rc1       3.2.0           3.3.0           3.3.1           3.4.0           3.4.2           FETCH_HEAD      master          origin/3.4      origin/master   
3.0.0-beta      3.1.0           3.2.0-rc        3.3.0-rc        3.4             3.4.1           3.4.3           HEAD            ORIG_HEAD       origin/HEAD     

git checkout 3.4.2 #这里选择3.4.2版本,需要注意的是,opencv_contrib的版本必须与opencv的对应版本一样
  • Compile opencvandopencv_contrib
cd opencv
mkdir build
cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules -DCVV_DEBUG_MODE=ON DBUILD_opencv_CVV=ON -DWITH_cvv:bool=ON -DWITH_QT=ON  CMAKE_CXX_FLAGS=-std=c11 ..
make -j4
sudo make install #默认将opencv安装到/usr/local路径下
  • Uninstall opencv(optional)
cd opencv/build
sudo make uninstall

Guess you like

Origin blog.csdn.net/weixin_39675633/article/details/82318491