{"id":16195,"date":"2023-01-26T13:09:02","date_gmt":"2023-01-26T13:09:02","guid":{"rendered":"https:\/\/engagement-rings.cornerd.com\/?p=16195"},"modified":"2023-01-26T13:10:02","modified_gmt":"2023-01-26T13:10:02","slug":"how-to-compile-opencv-2-4-10-on-ubuntu-14-04-and-14-10-danwin-com","status":"publish","type":"post","link":"https:\/\/cornerd.com\/how-to-compile-opencv-2-4-10-on-ubuntu-14-04-and-14-10-danwin-com\/","title":{"rendered":"How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10 – danwin.com"},"content":{"rendered":"

<\/p>\n

\n

For my upcoming Computational Methods within the Civic Sphere class at Stanford, I wished my college students to have entry to OpenCV in order that they may discover computer-vision algorithms, resembling face detection with Haar classifiers.<\/p>\n

On the Stanford FarmShare machines (which run on Ubuntu 13.10), I had bother getting their set up of OpenCV working, however was ready to make use of the
Anaconda distribution to put in each Python 2.7.8 and OpenCV 2.4.9.1 by way of the Binstar bundle repo. <\/p>\n

Briefly, listed here are the directions:<\/p>\n

    \n
  1. Get the Anaconda obtain hyperlink<\/li>\n
  2. curl (*the-anaconda-URL-script*) -o \/tmp\/anaconda-install.sh && bash \/tmp\/anaconda-install.sh<\/code><\/li>\n
  3. conda set up binstar<\/code><\/li>\n
  4. conda set up -c opencv<\/code><\/li>\n<\/ol>\n

    Note: For Mac customers for whom `brew set up opencv` isn\u2019t working: Anaconda labored nicely sufficient for me, although I needed to set up from a special pacakge repo:\n<\/p>\n

    conda set up -c  opencv<\/pre>\n

    The Anaconda system, which I hadn’t used earlier than however discover actually handy, mechanically upgrades\/downgrades the mandatory dependencies (resembling numpy<\/code>).<\/p>\n

    Using Anaconda works fantastic on contemporary Ubuntu installs (I examined on AWS and Digital Ocean), however I wished to see if I might compile it from supply simply in case I could not use Anaconda. This ended up being a really painful time of wading via weblog articles and Github points. Admittedly, I’m in no way an knowledgeable at *nix administration, but it surely’s apparent there’s lots of incomplete and ranging solutions on the market.<\/p>\n

    The assist.ubuntu.docs on OpenCV are probably the most intensive, however proper on the high, they state: <\/p>\n

    \n

    \nUbuntu’s newest incarnation, Utopic Unicorn, comes with a brand new model of libav, and opencv sources will fail to construct with this new library model. Likewise, some packages required by the script now not exist (libxine-dev, ffmpeg) in the usual repositories. The procedures and script described beneath will due to this fact not work not less than since Ubuntu 14.10!\n<\/p>\n<\/blockquote>\n

    The elimination of ffmpeg from the official Ubuntu bundle repo is, from what I can inform, the primary supply of errors when making an attempt to compile OpenCV for Ubuntu 14.04\/14.10. Many of the directions cope with getting ffmpeg from a personal-package-archive after which making an attempt to construct OpenCV. That method did not work for me, however admittedly, I did not check out all of the doable variables (resembling model of ffmpeg).<\/p>\n

    In the tip, what labored<\/strong> was to easily simply set the flag to construct with out ffmpeg:<\/p>\n

      cmake [etc] -D WITH_FFMPEG=OFF\n<\/code><\/pre>\n

    I’ve created a gist to construct out all of the software program I would like for my class machines, however listed here are the related elements for OpenCV:<\/p>\n

    sudo apt-get replace && sudo apt-get -y improve\nsudo apt-get -y dist-upgrade && sudo apt-get -y autoremove\n\n# construct developer instruments. Some of those are most likely non-pertinent\nsudo apt-get set up -y git-core curl zlib1g-dev build-essential \n     libssl-dev libreadline-dev libyaml-dev libsqlite3-dev \n     libxml2-dev libxslt1-dev libcurl4-openssl-dev \n     python-software-properties\n\n# numpy is a dependency for OpenCV, so most of those different\n# packages are most likely non-compulsory\nsudo apt-get set up -y python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose\n## Other scientific libraries (clearly not wanted for OpenCV)\npip set up -U scikit-learn\npip set up -U nltk\n\n### opencv from supply\n# first, putting in some utilities\nsudo apt-get set up -y qt-sdk unzip\nOPENCV_VER=2.4.10\ncurl \" -o opencv-${OPENCV_VER}.zip\nunzip \"opencv-${OPENCV_VER}.zip\" && cd \"opencv-${OPENCV_VER}\"\nmkdir construct && cd construct\n# construct with out ffmpeg\ncmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON \n      -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON \n      -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON \n      -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON \n      -D WITH_FFMPEG=OFF ..\n<\/code><\/pre>\n

    A recurring situation I had come throughout \u2013 I did not check it myself, however simply noticed it within the number of hypothesis concerning the issue of constructing OpenCV \u2013 is that constructing with a Python aside from the system’s Python<\/em> would trigger issues. So, for what it is value, the above course of works with 14.04’s Python 2.7.6, and 14.10’s 2.7.8. I’m not a lot of a Python person myself so I do not know a lot about greatest practices concerning surroundings\u2026pyenv works fairly effortlessly (that’s, it really works identical to rbenv), however I did not strive it in relation to constructing OpenCV.<\/p>\n

    Also, this is not the naked minimal\u2026I’m unsure what dev instruments or which cmake<\/code> flags are are completely wanted, or if qt-sdk<\/code> is required in the event you do not construct with Qt assist. But it really works, so hopefully anybody Googling this situation will be capable of make some progress.<\/p>\n

    Note: Other issues I attempted that didn’t work on clear installs of Ubuntu 14.04\/14.10:<\/p>\n

    The Python code wanted to do easy face-detection seems to be one thing like this (based mostly off of examples from OpenCV-Python and Practical Python and OpenCV: <\/p>\n

    (You can discover pre=constructed XML classifiers on the OpenCV repo)<\/p>\n

    \nimport cv2\nface_cascade_path=\"\/YOUR\/PATH\/TO\/haarcascade_frontalface_default.xml\"\nface_cascade = cv2.CascadeClassifier(face_cascade_path)\n\nscale_factor = 1.1\nmin_neighbors = 3\nmin_size = (30, 30)\nflags = cv2.cv.CV_HAAR_SCALE_IMAGE\n\n# load the picture\nimage_path = \"YOUR\/PATH\/TO\/picture.jpg\"\npicture = cv2.imread(image_path)\n\n# this does the work\nrects = face_cascade.detectMultiScale(picture, scaleFactor = scale_factor,\n  minNeighbors = min_neighbors, minSize = min_size, flags = flags)\n\nfor( x, y, w, h ) in rects:\n  cv2.rectangle(picture, (x, y), (x + w, y + h), (255, 255, 0), 2)\n\ncv2.imwrite(\"YOUR\/PATH\/TO\/output.jpg\", picture)\n<\/code><\/pre>\n<\/p><\/div>\n

    Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

    For my upcoming Computational Methods within the Civic Sphere class at Stanford, I wished my college students to have entry to OpenCV in order that they may discover computer-vision algorithms, resembling face detection with Haar classifiers. On the Stanford FarmShare machines (which run on Ubuntu 13.10), I had bother getting their set up of OpenCV<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[230],"tags":[21038,21036,19123,21037,21039],"acf":[],"_links":{"self":[{"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/posts\/16195"}],"collection":[{"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/comments?post=16195"}],"version-history":[{"count":1,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/posts\/16195\/revisions"}],"predecessor-version":[{"id":16196,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/posts\/16195\/revisions\/16196"}],"wp:attachment":[{"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/media?parent=16195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/categories?post=16195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cornerd.com\/wp-json\/wp\/v2\/tags?post=16195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}