https://www.samontab.com/web/2017/06/installing-opencv-3-2-0-with-contrib-modules-in-ubuntu-16-04-lts/

Installing OpenCV 3.2.0 with contrib modules in Ubuntu 16.04 LTS

OpenCV 3.2.0 has been out for a while and contains many improvements and exciting new features, so it’s time to update this guide using the latest Ubuntu 16.04LTS.

A big change in OpenCV 3.2.0 is that now many of the newest algorithms now reside separately in the contrib repository.

Some of these modules include Face Recognition, RGB-Depth processing, Image Registration, Saliency, Structure From Motion, Tracking, and much more.

So let’s install OpenCV 3.2.0 with the contrib modules and other good stuff by executing the following code on the command line:

01 sudo apt-get update
02 sudo apt-get upgrade
03 sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff5-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev
04 cd ~
05 mkdir opencv
06 cd opencv
08 tar -xvzf 3.2.0.tar.gz
10 unzip 3.2.0.zip
11 cd opencv-3.2.0

But before we build it, we need to fix one problem currently present in the contrib modules, specifically in the freetype module, which allows you to draw UTF-8 strings. If you are getting an error similar to ImportError: /usr/local/lib/libopencv_freetype.so.3.2: undefined symbol: hb_shape, this will fix it:

1 sed -i 's/${freetype2_LIBRARIES} ${harfbuzz_LIBRARIES}/${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES}/g' ../opencv_contrib-3.2.0/modules/freetype/CMakeLists.txt

Since now that problem is solved, now we are ready to build OpenCV.

01 mkdir build
02 cd build
03 cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON .. -DCMAKE_BUILD_TYPE=RELEASE -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.2.0/modules ..
04 make
05 sudo make install
06 echo '/usr/local/lib' | sudo tee --append /etc/ld.so.conf.d/opencv.conf
07 sudo ldconfig
08 echo 'PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig' | sudo tee --append ~/.bashrc
09 echo 'export PKG_CONFIG_PATH' | sudo tee --append ~/.bashrc
10 source ~/.bashrc

Now you should be able to compile with the OpenCV libraries, including the contrib repositories.

For example, let’s compute some Fine-Grained Saliency, which is available in the saliency module of the contrib repository:

1 cd ~
2 mkdir saliency
3 cd saliency
4 cp ../opencv/opencv_contrib-3.2.0/modules/saliency/samples/computeSaliency.cpp .
5 cp ../opencv/opencv-3.2.0/samples/data/Megamind.avi .
6 g++ -o computeSaliency `pkg-config opencv --cflags` computeSaliency.cpp `pkg-config opencv --libs`
7 ./computeSaliency FINE_GRAINED Megamind.avi 23

Original Image:

Computed Saliency:

Posted in Image Processing, Open Source, Programming.

15 comments

By samontab
June 3, 2017

最新文章

  1. Python(七)Socket编程、IO多路复用、SocketServer
  2. python习题 (1):login
  3. 图书馆管理系统—NABCD模型竞争性需求分析
  4. jquery面试需要看的基本东西
  5. 修改win7登录界面
  6. 走进Vue.js
  7. 18_高级映射:一对一查询(使用resultMap)
  8. [转载] 与WIN不同,linux替换文件夹会删除原文件夹下的全部内容!
  9. hdu 1695 GCD(欧拉函数+容斥)
  10. Absolute sort
  11. QF——iOS通知中心(NotificationCener)
  12. BZOJ 1927: [Sdoi2010]星际竞速(最小费用最大流)
  13. call_create_syn.sql
  14. 201521123008《Java程序设计》第十三周学习总结
  15. Activiti-06-.事件
  16. SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、属性配置、多环境配置
  17. JAVA 的 Date、Calendar的常用用法
  18. QCanvasItem介绍-QT3
  19. 零基础学Python--------第2章 Python语言基础
  20. centos7下安装vnc更改vnc默认端口号

热门文章

  1. 5.Linux解决Device eth0 does not seem to be present
  2. espcms P8.19082801 vulnerability
  3. Windows安装tensorflow,配置vs2013,anaconda3.4,cudn9.0,cudnn7.0和pycharm
  4. 学习进度05(billbill长评爬取02)
  5. P1049 数列的片段和
  6. UVA - 679 Dropping Balls(二叉树的编号)
  7. CSS - input 只显示下边框
  8. MongoDB 3.2 升级至 3.4.6
  9. 小程序地图开发周边信息POI展示为列表
  10. 【转载】Asp .Net Web Api路由路径问题