{"id":140,"date":"2018-10-15T10:11:02","date_gmt":"2018-10-15T08:11:02","guid":{"rendered":"https:\/\/www.nerdluecht.de\/?p=140"},"modified":"2019-03-09T22:37:44","modified_gmt":"2019-03-09T21:37:44","slug":"compile-opencv-3-4-3-for-anaconda-python-3-7","status":"publish","type":"post","link":"https:\/\/www.nerdluecht.de\/index.php\/2018\/10\/15\/compile-opencv-3-4-3-for-anaconda-python-3-7\/","title":{"rendered":"Compile OpenCV 3.4.4 for Anaconda Python 3.6, 3.7"},"content":{"rendered":"\r\n\r\nThis guide is based on <a href=\"https:\/\/www.scivision.co\/anaconda-python-opencv3\/\">https:\/\/www.scivision.co\/anaconda-python-opencv3\/<\/a>. It is targeted at installing a minimal OpenCV 3.4.4 in an Anaconda environment with Python 3.6 or 3.7.\r\n\r\n\r\n\r\n\r\n\r\nI assume you already use conda.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Create an environment<\/h2>\r\n\r\n\r\n\r\n\r\nCreate an environment and activate it. Make sure you install all packages that you will need later (e.g. scikit-image).\r\n\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>conda create -n my-env python=3.7 numpy\r\nconda activate my-env<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Get OpenCV<\/h2>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/opencv\/opencv.git\r\ncd opencv\r\ngit checkout tags\/3.4.4<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Configure CMake<\/h2>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>mkdir release-myenv\r\ncd release-myenv\r\ncmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DWITH_OPENGL=ON -DWITH_OPENCL=OFF -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_EIGEN=OFF -DWITH_V4L=OFF -DWITH_VTK=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_python3=yes -DCMAKE_INSTALL_PREFIX=$(python -c \"import sys; print(sys.prefix)\") -DPYTHON3_EXECUTABLE=$(which python) -DPYTHON3_INCLUDE_DIR=$(python -c \"from distutils.sysconfig import get_python_inc; print(get_python_inc())\") -DPYTHON3_PACKAGES_PATH=$(python -c \"from distutils.sysconfig import get_python_lib; print(get_python_lib())\") ..<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Build &amp; Install<\/h2>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>make -j -l 4\r\nmake install<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Test OpenCV<\/h2>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code># Output should be empty\r\npython -c \"import cv2\"<\/code><\/pre>\r\n\r\n\r\n\r\n\r\nFor a more advanced test, use the example in the article mentioned at the beginning: <a href=\"https:\/\/www.scivision.co\/anaconda-python-opencv3\/#2-test-opencv\">https:\/\/www.scivision.co\/anaconda-python-opencv3\/#2-test-opencv<\/a>\r\n<h2>Problems<\/h2>\r\nIf the package is not importable, you may have to copy over the .so file to the correct location (e.g. &lt;path\/to\/anaconda&gt;\/envs\/&lt;env&gt;\/lib\/python3.7\/site-packages).\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>This guide is based on https:\/\/www.scivision.co\/anaconda-python-opencv3\/. It is targeted at installing a minimal OpenCV 3.4.4 in an Anaconda environment with Python 3.6 or 3.7. I assume you already use conda. Create an environment Create an environment and activate it. Make sure you install all packages that you will need later (e.g. scikit-image). Get OpenCV Configure &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.nerdluecht.de\/index.php\/2018\/10\/15\/compile-opencv-3-4-3-for-anaconda-python-3-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Compile OpenCV 3.4.4 for Anaconda Python 3.6, 3.7&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[17,16,18],"_links":{"self":[{"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/posts\/140"}],"collection":[{"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":6,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/posts\/140\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nerdluecht.de\/index.php\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}