title: Compile OpenCV with Cmake to integrate it within a Conda env
body: <p>I am trying to follow these instructions inspired from <a href="http://www.codebind.com/cpp-tutorial/install-opencv-ubuntu-cpp/" rel="nofollow noreferrer">here</a> to compile OpenCV so that it gets integrated within a Conda environment that I previously set. However, when I import cv2 within this conda environment, python3 doesn't find it.</p>
  
  <p>Here are the instructions that I follow to install Opencv :</p>
  
  <pre><code>sudo apt-get update
  sudo apt-get upgrade
  
  
  sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  
  sudo apt-get install python3.6-dev python3-numpy libtbb2 libtbb-dev
  
  sudo apt-get install libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libdc1394-22-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtbb-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libavutil-dev libavfilter-dev libavresample-dev
  
  sudo -s
  cd /opt
  git clone https://github.com/Itseez/opencv.git
  git clone https://github.com/Itseez/opencv_contrib.git
  
  
  cd opencv
  mkdir release
  cd release
  
  
  cmake -D WITH_CUDA=OFF -D BUILD_TIFF=ON -D BUILD_opencv_java=OFF -D ENABLE_AVX=ON -D WITH_OPENGL=ON -D WITH_OPENCL=ON -D WITH_IPP=ON -D WITH_TBB=ON -D WITH_EIGEN=ON -D WITH_V4L=ON -D WITH_VTK=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python2=OFF -D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") -D PYTHON3_EXECUTABLE=$(which python3) -D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON_EXECUTABLE=~/anaconda3/envs/cvenv2/bin/python -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules -D BUILD_EXAMPLES=ON /opt/opencv/
  
  make -j8
  make install
  ldconfig
  exit
  cd ~
  </code></pre>
  
  <p>The conda virtual environment is ~/anaconda3/envs/cvenv2. I believe that compilation is needed because I am not able to use ffmpeg without it.</p>