OpenCV 3 latest with Cuda and Python 2.7 and 3.4

Directions for installing Cuda 6.5 on AWS GPU Instance is here: http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/

Install all the necessary packages to build opencv:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential git cmake cmake-curses-gui zlib1g-dev libeigen3-dev

sudo apt-get install checkinstall pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libncurses5-dev libv4l-dev python-dev python3-dev python-numpy python3-numpy python-pip python3-pip python-dbg python3-dbg python-matplotlib python3-matplotlib python-scipy python-scipy3 libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

may GRR not work - sudo apt-get install python3-numpy
sudo pip3 install numpy

Make the necessary source and build folders:
(I assume you are using bash here)
export todaysdate=`date "+%Y%m%d"`
mkdir opencvsrc$todaysdate
mkdir opencvbld$todaysdate

Download the opencv source:
cd opencvsrc$todaysdate
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git

Upgrade Cmake (Ubuntu 14.04 default cmake is 2.8, need 3.2 or higher to detect Python 3.4)

wget https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz
tar zxvpf cmake-3.3.2.tar.gz
cd cmake-3.3.2/
./configure
make -j 12
sudo make install
export CMAKE_ROOT=/usr/local/share/cmake-3.3
cmake --version

Go into the build directory and use ccmake to configure your build.
cd ../opencvbld$todaysdate
ccmake ../opencvsrc$todaysdate/opencv

Hit ‘c’ to configure and then change these variables by moving to that line and hitting Enter.

BUILD_EXAMPLES ON
INSTALL_C_EXAMPLES ON
INSTALL_PYTHON_EXAMPLES ON
INSTALL_TESTS ON
OPENCV_EXTRA_MODULES_PATH=../opencvsrc$todaysdate/opencv_contrib/modules
WITH_NVCUVID ON

Hit ‘c’ to configure
Hit ‘g’ to generate

Now build and install opencv.
make -j8
sudo make install

For getting test data and running tests on that data do this:
cd
git clone git://github.com/Itseez/opencv_extra.git
export OPENCV_TEST_DATA_PATH=/home/ubuntu/opencv_extra/testdata/
/usr/local/bin/opencv_test_video

Lots of tests are in /usr/local/bin

If you just want to use my public AMI with the OpenCV source from March 25,2015 it is here (for US-East): ami-fa200b92

Leave a Reply

Your email address will not be published.