Skip to content

Instantly share code, notes, and snippets.

@nickgravish
Last active August 28, 2016 19:29
Show Gist options
  • Save nickgravish/ece1b12dba96f8a111d0b2816500c04e to your computer and use it in GitHub Desktop.
Save nickgravish/ece1b12dba96f8a111d0b2816500c04e to your computer and use it in GitHub Desktop.
Science environment setup in python

Steps to install opencv3 for use with Python 3 and h264 videos

  1. On fresh install of ubuntu download and install conda (I like to work with Conda)
  2. To get h264 videos working we need to install the codec. We also need to install ffmpeg for opencv. First the code
sudo apt-get install ubuntu-restricted-extras
  1. Install and compile ffmpeg based on [https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu]{https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu}

  2. Download and compile opencv 3. Good instructions here [http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/]{http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/} Most importantly note the cmake instructions I had to use

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON \
    -D PYTHON3_PACKAGES_PATH = ~/anaconda3/lib/python3.5/site-packages ..

Other notes

opencv has trouble finding certain external library files in the conda environment

For example error messages like

Determining if the include file /home/nick/anaconda3/include/libpng/png.h exists failed with the following output:
Change Dir: /home/nick/opencv/build/CMakeFiles/CMakeTmp

The answer to this can be found in this thread [opencv/opencv#6027https://github.com/opencv/opencv/issues/6027}

Turn off the C_EXAMPLES because we don't care about them (when installing into conda environment). Also note I had to manually place the location of the python 3 site packages. CMake was not recognizing them.

http://stackoverflow.com/questions/24400935/how-could-we-install-opencv-on-anaconda http://rodrigoberriel.com/2014/10/installing-opencv-3-0-0-on-ubuntu-14-04/ http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/

sudo mount -t vboxsf shared_folder ~/shared_folder

also add user to vboxsf group

sudo usermod -aG vboxsf $(whoami)
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment