{"id":651,"date":"2019-12-28T21:02:17","date_gmt":"2019-12-28T21:02:17","guid":{"rendered":"http:\/\/blog.davcloud.top\/?p=651"},"modified":"2020-02-16T18:55:52","modified_gmt":"2020-02-16T18:55:52","slug":"install-opencv-environment-on-ubuntu-16-04","status":"publish","type":"post","link":"https:\/\/blog.davcloud.top\/?p=651","title":{"rendered":"Install OpenCV Environment on Ubuntu 16.04"},"content":{"rendered":"\n<h2>Abstract<\/h2>\n\n\n\n<p>This article aims at installing OpenCV 3.4.8 with opencv_contrib environment on Ubuntu 16.04.<\/p>\n\n\n\n<p class=\"has-text-color has-vivid-green-cyan-color\">Note: Though this is for Ubuntu 16.04.6, it may still adapt to the similar version like Ubuntu 18.04.<\/p>\n\n\n\n<p class=\"has-text-color has-vivid-green-cyan-color\">Note: Though this is for OpenCV 3.4.8, it may still adapt to the similar version.<\/p>\n\n\n\n<h2>Step 1. Install dependences<\/h2>\n\n\n\n<p>Install dependences required:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo apt-get install build-essential\n~$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev\n~$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-vivid-red-color\">Attention: This dependences are for version 3.4.8, for other version, please see official documents in <a href=\"https:\/\/opencv.org\/\">https:\/\/opencv.org\/<\/a>.<\/p>\n\n\n\n<h2>Step 2. Download sources<\/h2>\n\n\n\n<p>Download OpenCV 3.4.8 source file(source.zip) from Github repo: <a href=\"https:\/\/github.com\/opencv\/opencv\/releases\/tag\/3.4.8\">https:\/\/github.com\/opencv\/opencv\/releases\/tag\/3.4.8<\/a><\/p>\n\n\n\n<p>Download OpenCV_Contrib 3.4.8 source file(source.zip) from Github repo: <a href=\"https:\/\/github.com\/opencv\/opencv_contrib\/releases\/tag\/3.4.8\">https:\/\/github.com\/opencv\/opencv_contrib\/releases\/tag\/3.4.8<\/a><\/p>\n\n\n\n<p class=\"has-text-color has-vivid-red-color\">Attention: Please make sure the version of OpenCV and OpenCV_Contrib are the same, otherwise it will install failure.<\/p>\n\n\n\n<h2>Step 3. Unzip and move files<\/h2>\n\n\n\n<p>Unzip the two downloaded files in the same directory, take ~\/ as an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ unzip opencv-3.4.8.zip\n~$ unzip opencv_contrib-3.4.8.zip<\/code><\/pre>\n\n\n\n<p>Now two folder will appear in the ~\/ directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>opencv-3.4.8\nopencv_contrib-3.4.8<\/code><\/pre>\n\n\n\n<p>Move the folder opencv_contrib-3.4.8 to the folder opencv-3.4.8:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ mv opencv_contrib-3.4.8 opencv-3.4.8<\/code><\/pre>\n\n\n\n<h2>Step 4. Building OpenCV from Source Using CMake<\/h2>\n\n\n\n<p>Create a new folder &#8220;build&#8221; in the folder &#8220;opencv-3.4.8&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ cd opencv-3.4.8\n~\/opencv-3.4.8$ mkdir build\n~\/opencv-3.4.8$ cd build<\/code><\/pre>\n\n\n\n<p>Configuring with cmake commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=\/usr\/local -DOPENCV_EXTRA_MODULES_PATH=\/home\/&lt;yourusername>\/opencv-3.4.8\/opencv_contrib-3.4.8\/modules ..<\/code><\/pre>\n\n\n\n<p>If no error occurs, run command below to make the project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/opencv-3.4.8\/build$ make -j7<\/code><\/pre>\n\n\n\n<p>If no error occurs, run command below to install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo make install<\/code><\/pre>\n\n\n\n<p>Finally, run command below to reload config and reboot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ldconfig\nreboot<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Abstract This article aims at installing OpenCV 3.4.8 with opencv_contrib environment on Ubuntu 16.04. Note: Though this is for Ubuntu 16.04.6, it may still adapt to the similar version like Ubuntu 18.04. Note: Though this is for OpenCV 3.4.8, it may still adapt to the similar version. Step 1. Install dependences Install dependences required: Attention: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[128,13],"tags":[129,25],"_links":{"self":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/651"}],"collection":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=651"}],"version-history":[{"count":22,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":1213,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/651\/revisions\/1213"}],"wp:attachment":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}