Engagement Rings

How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10 – danwin.com

For my upcoming Computational Techniques in the Civic Sphere class at Stanford, I desired my trainees to have access to OpenCV so that they might check out computer-vision algorithms, such as face detection with Haar classifiers.

On the Stanford FarmShare devices (which work on Ubuntu 13.10), I had problem getting their setup of OpenCV working, however had the ability to utilize the
Anaconda circulation to set up both Python 2.7.8 and OpenCV through the Binstar plan repo.

Quickly, here are the directions:

  1. Get the Anaconda download link
  2. curl (* the-anaconda-URL-script *) -o/ tmp/anaconda-install. sh && & & celebration/ tmp/anaconda-install. sh
  3. conda set up binstar
  4. conda set up -c opencv

Note: For Mac users for whom ‘brew set up opencv’ isn’t working: Anaconda worked well adequate for me, though I needed to set up from a various pacakge repo:

 conda set up -c opencv

The Anaconda system, which I had not utilized prior to however discover truly hassle-free, immediately upgrades/downgrades the essential reliances (such as numpy).

Utilizing Anaconda works fine on fresh Ubuntu installs (I evaluated on AWS and Digital Ocean), however I wished to see if I might assemble it from source simply in case I could not utilize Anaconda. This wound up being an extremely uncomfortable time of learning blog site posts and Github concerns. Undoubtedly, I’m not a professional at * nix administration, however it’s apparent there’s a great deal of insufficient and differing responses out there.

The help.ubuntu.docs on OpenCV are the most substantial, however right at the top, they specify:

Ubuntu’s newest version, Utopic Unicorn, features a brand-new variation of libav, and opencv sources will stop working to develop with this brand-new library variation. Similarly, some bundles needed by the script no longer exist (libxine-dev, ffmpeg) in the basic repositories. The treatments and script explained below will for that reason not operate at least given that Ubuntu 14.10!

The elimination of ffmpeg from the main Ubuntu plan repo is, from what I can inform, the primary source of mistakes when attempting to assemble OpenCV for Ubuntu 14.04/ 14.10. A lot of the directions handle getting ffmpeg from a personal-package-archive and after that attempting to develop OpenCV. That method didn’t work for me, however undoubtedly, I didn’t evaluate out all the possible variables (such as variation of ffmpeg).

In the end, what worked was to merely just set the flag to develop without ffmpeg:

 cmake [etc] -D WITH_FFMPEG= OFF.

I have actually developed an essence to develop out all the software application I desire for my class devices, however here are the pertinent parts for OpenCV:

 sudo apt-get upgrade && & & sudo apt-get -y upgrade.
sudo apt-get -y dist-upgrade && & & sudo apt-get -y autoremove.

# develop designer tools. A few of these are most likely non-pertinent.
sudo apt-get set up -y git-core curl zlib1g-dev build-essential.
libssl-dev libreadline-dev libyaml-dev libsqlite3-dev.
libxml2-dev libxslt1-dev libcurl4-openssl-dev.

# numpy is a dependence for OpenCV, so the majority of these other.
# bundles are most likely optional.
sudo apt-get set up -y python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose.
## Other clinical libraries (certainly not required for OpenCV).
pip set up -U scikit-learn.
pip set up -U nltk.

### opencv from source.
# initially, setting up some energies.
sudo apt-get set up -y qt-sdk unzip.
OPENCV_VER= 2.4.10.
curl" -o opencv-$ {OPENCV_VER}. zip.
unzip "opencv-$ {OPENCV_VER}. zip" && & & cd" opencv-$ {OPENCV_VER} ".
mkdir develop && & & cd develop.
# develop without ffmpeg.

A repeating problem I had actually stumbled upon– I didn’t evaluate it myself, however simply saw it in the range of speculation concerning the trouble of structure OpenCV– is that constructing with a Python besides the system’s Python would trigger issues. So, for what it deserves, the above procedure deals with 14.04’s Python 2.7.6, and 14.10’s 2.7.8. I’m very little of a Python user myself so I do not understand much about finest practices concerning environment … pyenv works quite easily (that is, it works much like rbenv), however I didn’t attempt it in relation to constructing OpenCV.

Likewise, this isn’t the bare minimum … I’m not exactly sure what dev tools or which cmake flags are are definitely required, or if qt-sdk is required if you do not develop with Qt assistance. However it works, so ideally anybody Googling this problem will have the ability to make some development.

Note: Other things I attempted that did not deal with tidy installs of Ubuntu 14.04/ 14.10:

The Python code required to do easy face-detection looks something like this (based off of examples from OpenCV-Python and Practical Python and OpenCV:

( You can discover pre= constructed XML classifiers at the OpenCV repo)

import cv2.
face_cascade_path="/ YOUR/PATH/TO/ haarcascade_frontalface_default. xml"
face_cascade = cv2.CascadeClassifier( face_cascade_path).

scale_factor = 1.1.
min_neighbors = 3.
min_size = (30, 30).
flags = cv2.cv.CV _ HAAR_SCALE_IMAGE.

# pack the image.
image_path="YOUR/PATH/TO/ image.jpg".
image = cv2.imread( image_path).

# this does the work.
rects = face_cascade. detectMultiScale( image, scaleFactor = scale_factor,.
minNeighbors = min_neighbors, minSize = min_size, flags = flags).

for( x, y, w, h) in rects:.
cv2.rectangle( image, (x, y), (x + w, y + h), (255, 255, 0), 2).

cv2.imwrite(" YOUR/PATH/TO/ output.jpg", image).

Source link