- Building Computer Vision Projects with OpenCV 4 and C++
- David Millán Escrivá Prateek Joshi Vinícius G. Mendon?a Roy Shilkrot
- 230字
- 2021-07-02 12:28:30
Linux
Let's see how to install OpenCV on Ubuntu. We need to install some dependencies before we begin. Let's install them using the package manager by running the following command in your Terminal:
$ sudo apt-get -y install libopencv-dev build-essential cmake libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
Now that you have installed the dependencies, let's download, build, and install OpenCV:
$ wget "https://github.com/opencv/opencv/archive/4.0.0.tar.gz" -O opencv.tar.gz $ wget "https://github.com/opencv/opencv_contrib/archive/4.0.0.tar.gz" -O opencv_contrib.tar.gz $ tar -zxvf opencv.tar.gz $ tar -zxvf opencv_contrib.tar.gz $ cd opencv-4.0.0 $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/full/path/to/opencv-4.0.0/build -D INSTALL_C_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/full/path/to/opencv_contrib-4.0.0/modules ../ $ make -j4 $ sudo make install
Let's copy the pkgconfig file in opencv.pc to /usr/local/lib/pkgconfig, and name it opencv4.pc:
$ cp /full/path/to/opencv-4.0.0/build/lib/pkgconfig/opencv.pc /usr/local/lib/pkgconfig/opencv4.pc
We're finished! We will now be able to use it to compile our OpenCV programs from the command line. Also, if you already have an existing OpenCV 3.x.x installation, there will be no conflict.
Let's check the installation is working properly:
$ cd /full/path/to/opencv-4.0.0/samples/cpp $ g++ -ggdb `pkg-config --cflags --libs opencv4` opencv_version.cpp -o /tmp/opencv_version && /tmp/opencv_version
If you see Welcome to OpenCV 4.0.0 printed on your Terminal, you should be good to go. In the following chapters, we will learn how to use CMake to build our OpenCV projects.
- Python數據挖掘:入門、進階與實用案例分析
- Mastering Ninject for Dependency Injection
- 商業分析思維與實踐:用數據分析解決商業問題
- Access 2016數據庫技術及應用
- 數據架構與商業智能
- 基于Apache CXF構建SOA應用
- 智能數據時代:企業大數據戰略與實戰
- 數據庫技術及應用教程
- 一本書講透Elasticsearch:原理、進階與工程實踐
- 新手學會計(2013-2014實戰升級版)
- Augmented Reality using Appcelerator Titanium Starter
- 算法設計與分析
- 大數據隱私保護技術與治理機制研究
- 一類智能優化算法的改進及應用研究
- 一本書讀懂區塊鏈(第2版)