{"id":182,"date":"2009-07-22T10:57:00","date_gmt":"2009-07-22T15:57:00","guid":{"rendered":"http:\/\/dwaynephillips.net\/workingup\/?p=182"},"modified":"2009-07-22T10:57:00","modified_gmt":"2009-07-22T15:57:00","slug":"working-with-opencv-on-os-x","status":"publish","type":"post","link":"https:\/\/dwaynephillips.net\/workingup\/2009\/07\/working-with-opencv-on-os-x\/","title":{"rendered":"Working with OpenCV on OS X"},"content":{"rendered":"<p>by Dwayne Phillips<\/p>\n<p><strong>I return to some of my technical roots this week. I am experimenting with the OpenCV image processing and computer vision library. This is fun.<\/strong><\/p>\n<p>This is a &#8220;techie&#8221; blog post. Many years ago I worked with image processing. I did this work in graduate school and then wrote a lot of magazine articles on the topic for the old <a href=\"http:\/\/www.ddj.com\/cpp\/cuj.jhtml\">C\/C++ Users Journal<\/a>. I even published <a href=\"http:\/\/dwaynephillips.net\/#books\">a book on the topic<\/a>. Later, I revised the book and <a href=\"http:\/\/homepages.inf.ed.ac.uk\/rbf\/BOOKS\/PHILLIPS\/\">the eBook or PDF of all that is available at this link<\/a>.<\/p>\n<p>Just in the last couple of weeks, I started looking at the OpenCV library of image processing and computer vision routines (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Opencv\">the Wikipedia page on OpenCV is here<\/a>). There is a good <a href=\"http:\/\/oreilly.com\/catalog\/9780596516130\/\">book out now about this topic from O&#8217;Reilly<\/a>.<\/p>\n<p>As the pages on the Internet state, the OS X work on OpenCV is the most immature. MS Windows leads the way with Linux implementations close behind. Well, I work on Apple computers with OS X at home, so&#8230;<\/p>\n<p>The <a href=\"http:\/\/opencv.willowgarage.com\/wiki\/Welcome\">OpenCV wiki<\/a> is quite helpful. I used the <a href=\"http:\/\/opencv.willowgarage.com\/wiki\/Mac_OS_X_OpenCV_Port\">loading and installation instructions found at this link<\/a>. It wasn&#8217;t simple and straightforward, but it worked. <em>First<\/em>, I had subversion loaded on my machine. Subversion is a version control program that was simple to download and install on OS X. Here is <a href=\"http:\/\/subversion.tigris.org\/\">the main page for Subversion<\/a>. <em>Second<\/em>, I needed the cmake package. It was also simple to download and install on OS X. Here is <a href=\"http:\/\/www.cmake.org\/\">the main page for cmake<\/a>. <em>Third<\/em>, well the good new is there was no third.<\/p>\n<p>The following subversion command downloaded OpenCV:<\/p>\n<blockquote>\n<pre>svn co http:\/\/opencvlibrary.svn.sourceforge.net\/svnroot\/opencvlibrary\/trunk opencv<\/pre>\n<\/blockquote>\n<p>The following statements &#8220;installed&#8221; OpenCV. Actually, they built the libraries so that I could link to the routines I called when writing my own programs. Run these from a directory called opencv. You could call the directory anything you want (foo, foobar, whatever).<\/p>\n<blockquote>\n<pre>mkdir opencv\/build\r\ncd opencv\/build\r\ncmake ..\r\nccmake .\r\nmake -j8\r\nsudo make install<\/pre>\n<\/blockquote>\n<p>I was finally ready to write a little program and try to link with OpenCV&#8217;s libraries. This is where I stumbled around for a few hours. Finally, I &#8220;figured it out.&#8221; The following uses the gcc compiler family to make a program called <em>foo <\/em>from a source file <em>foo.c<\/em> and the OpenCV libraries.<\/p>\n<blockquote>\n<pre>gcc -o foo foo.c -I\/usr\/local\/include\/opencv -L\/usr\/local\/lib -lcxcore -lcv -lml -lhighgui -lcvaux<\/pre>\n<\/blockquote>\n<p>So there you have it. Twenty five years and a few generations of hardware and operating systems later, I am sort of programming with a computer vision library. If I only had tools like this back then&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>by Dwayne Phillips I return to some of my technical roots this week. I am experimenting with the OpenCV image processing and computer vision library. This is fun. This is a &#8220;techie&#8221; blog post. Many years ago I worked with image processing. I did this work in graduate school and then wrote a lot of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,37,23,3],"tags":[142,159,145,126],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-learning","category-os-x","category-programming","category-technology","tag-learning","tag-os-x","tag-programming","tag-technology"],"_links":{"self":[{"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/comments?post=182"}],"version-history":[{"count":4,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/posts\/182\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dwaynephillips.net\/workingup\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}