{"id":1937,"date":"2016-06-24T19:05:00","date_gmt":"2016-06-24T10:05:00","guid":{"rendered":"http:\/\/avinton.com\/?page_id=1937"},"modified":"2017-10-02T17:38:48","modified_gmt":"2017-10-02T08:38:48","slug":"install-python2-7-opencv","status":"publish","type":"page","link":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/","title":{"rendered":"Install Python2.7 &#038; OpenCV"},"content":{"rendered":"<h1>Python OpenCV Setup<\/h1>\n<p>This was tested with Ubuntu 16.04<\/p>\n<h2>Python Install<\/h2>\n<p>Make sure we are in our home directory<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd ~\n<\/pre>\n<p><\/br><\/p>\n<h3>Update &amp; Upgrade OS<\/h3>\n<p>Upgrade any currently installed packages (may take a long time)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get update\nsudo apt-get upgrade\n<\/pre>\n<p><\/br><\/p>\n<h3>Install Tools:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install build-essential\nsudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev\nsudo apt-get install python-dev python-numpy\nsudo apt-get install -y unzip wget\n<\/pre>\n<p><\/br><\/p>\n<h3>Install File Format Libs<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev\n<\/pre>\n<p><\/br><\/p>\n<h3>Install Image -> GUI handler<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install libgtk2.0-dev\n<\/pre>\n<p><\/br><\/p>\n<h3>If you want to do any Video Processing:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev\n<\/pre>\n<p><\/br><\/p>\n<h3>Install OpenCV Optimisation Libs<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install libatlas-base-dev gfortran\n<\/pre>\n<p><\/br><\/p>\n<h3>Install Python Package Manager (PIP)<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nwget https:\/\/bootstrap.pypa.io\/get-pip.py\nsudo -H python get-pip.py\n<\/pre>\n<p><\/br><\/p>\n<h3>Install Python 2.7<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -H apt-get install python2.7-dev\n<\/pre>\n<p><\/br><\/p>\n<h3>Install Python Numpy<\/h3>\n<p>Numpy is used by Python for Image representation.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo pip install numpy\n<\/pre>\n<p> <\/br><\/p>\n<h2>OpenCV Setup<\/h2>\n<h3>Copy OpenCV Repo<\/h3>\n<p>Get OpenCV 3.3 build from GitHub<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd ~\nwget https:\/\/github.com\/opencv\/opencv\/archive\/3.3.0.zip\nunzip 3.3.0.zip\nmv opencv-3.3.0\/ opencv\ncd opencv\n<\/pre>\n<p> <\/br><\/p>\n<h3>Build OpenCV<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd ~\/opencv\n$ mkdir build\n$ cd build\n$ sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=\/usr\/local ..\n<\/pre>\n<p> <\/br><\/p>\n<h3>Compile OpenCV<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmake -j7\n<\/pre>\n<p> <\/br><\/p>\n<p>If you run out of disk space on your VM check out the little guide on extending your Virtual Disk<br \/>\n<a href=\"https:\/\/avinton.com\/en\/academy\/extending-virtualbox-virtual-drive\/\">https:\/\/avinton.com\/en\/academy\/extending-virtualbox-virtual-drive\/<\/a><\/p>\n<h3>Install OpenCV<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo make install\nsudo ldconfig\n<\/pre>\n<p><\/br><\/p>\n<h2>Test<\/h2>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython\n<\/pre>\n<p><\/br><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport cv2\ncv2.__version__\n<\/pre>\n<p>The above should return 3.3.0 (The OpenCV Version you installed)<br \/>\n<\/br><br \/>\nExit python interpreter and return to terminal<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nexit()\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any currently installed packages (may take a long time) sudo apt-get update sudo apt-get upgrade Install Tools: sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev<br \/><a href=\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\" class=\"more\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1906,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1937","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Install Python2.7 &amp; OpenCV - Avinton Japan<\/title>\n<meta name=\"description\" content=\"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Install Python2.7 &amp; OpenCV - Avinton Japan\" \/>\n<meta property=\"og:description\" content=\"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any\" \/>\n<meta property=\"og:url\" content=\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\" \/>\n<meta property=\"og:site_name\" content=\"Avinton Japan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Avintons\/\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-02T08:38:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/avinton.com\/wp-content\/uploads\/2020\/02\/avinton-japan-big-data.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@AvintonJapan\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\",\"url\":\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\",\"name\":\"Install Python2.7 & OpenCV - Avinton Japan\",\"isPartOf\":{\"@id\":\"https:\/\/avinton.com\/en\/#website\"},\"datePublished\":\"2016-06-24T10:05:00+00:00\",\"dateModified\":\"2017-10-02T08:38:48+00:00\",\"description\":\"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any\",\"breadcrumb\":{\"@id\":\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/avinton.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Avinton Academy\",\"item\":\"https:\/\/avinton.com\/en\/academy\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Install Python2.7 &#038; OpenCV\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/avinton.com\/en\/#website\",\"url\":\"https:\/\/avinton.com\/en\/\",\"name\":\"Avinton Japan\",\"description\":\"Tailored Solutions and Consulting in AI and Big Data\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/avinton.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Install Python2.7 & OpenCV - Avinton Japan","description":"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/","og_locale":"en_US","og_type":"article","og_title":"Install Python2.7 & OpenCV - Avinton Japan","og_description":"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any","og_url":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/","og_site_name":"Avinton Japan","article_publisher":"https:\/\/www.facebook.com\/Avintons\/","article_modified_time":"2017-10-02T08:38:48+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/avinton.com\/wp-content\/uploads\/2020\/02\/avinton-japan-big-data.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_site":"@AvintonJapan","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/","url":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/","name":"Install Python2.7 & OpenCV - Avinton Japan","isPartOf":{"@id":"https:\/\/avinton.com\/en\/#website"},"datePublished":"2016-06-24T10:05:00+00:00","dateModified":"2017-10-02T08:38:48+00:00","description":"Python OpenCV Setup This was tested with Ubuntu 16.04 Python Install Make sure we are in our home directory cd ~ Update &amp; Upgrade OS Upgrade any","breadcrumb":{"@id":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/avinton.com\/en\/academy\/install-python2-7-opencv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/avinton.com\/en\/"},{"@type":"ListItem","position":2,"name":"Avinton Academy","item":"https:\/\/avinton.com\/en\/academy\/"},{"@type":"ListItem","position":3,"name":"Install Python2.7 &#038; OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/avinton.com\/en\/#website","url":"https:\/\/avinton.com\/en\/","name":"Avinton Japan","description":"Tailored Solutions and Consulting in AI and Big Data","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/avinton.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/comments?post=1937"}],"version-history":[{"count":10,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1937\/revisions"}],"predecessor-version":[{"id":6659,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1937\/revisions\/6659"}],"up":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1906"}],"wp:attachment":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/media?parent=1937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/categories?post=1937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/tags?post=1937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}