{"id":1070,"date":"2020-01-17T02:10:40","date_gmt":"2020-01-16T17:10:40","guid":{"rendered":"https:\/\/ahnbk.com\/?p=1070"},"modified":"2020-01-17T02:11:44","modified_gmt":"2020-01-16T17:11:44","slug":"build-and-install-opencv-4-2-0-on-ubuntu-with-gpu-support","status":"publish","type":"post","link":"https:\/\/ahnbk.com\/?p=1070","title":{"rendered":"Build and Install OpenCV 4.2.0 on Ubuntu with GPU support"},"content":{"rendered":"\n<p>Current OpenCV version only support CUDA 10.1.<\/p>\n\n\n\n<p>Download sources<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wget https:\/\/github.com\/opencv\/opencv\/archive\/4.2.0.tar.gz\n$ wget https:\/\/github.com\/opencv\/opencv_contrib\/archive\/4.2.0.tar.gz<\/code><\/pre>\n\n\n\n<p>Extract the compressed files<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ tar zxf opencv-4.2.0.tar.gz\n$ tar zxf opencv_contrib-4.2.0.tar.gz<\/code><\/pre>\n\n\n\n<p>CMake configuration<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cd opencv-4.2.0\n$ mkdir build\n$ cd build\n$ cmake -DOPENCV_EXTRA_MODULES_PATH=..\/..\/opencv_contrib-4.2.0\/modules -DWITH_CUDA=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release ..<\/code><\/pre>\n\n\n\n<p>Build<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ make -j8<\/code><\/pre>\n\n\n\n<p>It takes 15 ~ 20 minutes.  And install,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo make install<\/code><\/pre>\n\n\n\n<p>Check installations<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ opencv_version \n4.2.0\n\n$ python3\nPython 3.6.9 (default, Nov  7 2019, 10:44:02) \n&#91;GCC 8.3.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import cv2\n>>> cv2\n&lt;module 'cv2' from '\/usr\/local\/lib\/python3.6\/dist-packages\/cv2\/python-3.6\/cv2.cpython-36m-x86_64-linux-gnu.so'>\n>>> <\/code><\/pre>\n\n\n\n<p>Done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Current OpenCV version only support CUDA 10.1. Download sources Extract the compressed files CMake configuration Build It takes 15 ~ 20 minutes. And install, Check installations Done.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[62],"tags":[20,147],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXSW-hg","jetpack-related-posts":[],"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1070"}],"collection":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1070"}],"version-history":[{"count":2,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1072,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1070\/revisions\/1072"}],"wp:attachment":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}