﻿{"id":1292,"date":"2015-02-13T15:56:31","date_gmt":"2015-02-13T07:56:31","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=1292"},"modified":"2015-03-12T15:45:07","modified_gmt":"2015-03-12T07:45:07","slug":"mac%e4%b8%8aopencv%e5%ae%89%e8%a3%85%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/nick.txtcc.com\/index.php\/mac-os\/1292","title":{"rendered":"mac\u4e0aopencv\u5b89\u88c5\u6b65\u9aa4"},"content":{"rendered":"<ol>\n<li>\n<p>\u53bb\u00a0<a href=\"http:\/\/opencv.org\/\" target=\"_blank\"><a href=\"http:\/\/opencv.org\">http:\/\/opencv.org<\/a><\/a>\u00a0\u4e0b\u8f7d\u6700\u65b0\u7248OpenCV for Linux\/Mac\u6e90\u6587\u4ef6\uff0c\u76ee\u524d\u7248\u672c\u662f2.4.3\u3002\u4e0b\u8f7d\u540e\u89e3\u538b\u3002<\/p>\n<\/li>\n<li>\n<p>\u53bb\u00a0<a href=\"http:\/\/www.cmake.org\/\" target=\"_blank\"><a href=\"http:\/\/www.cmake.org\">http:\/\/www.cmake.org<\/a><\/a>\u00a0\u4e0b\u8f7d\u6700\u65b0\u7248cmake\uff0c.dmg\u6587\u4ef6\uff0c\u5efa\u8bae\u4f7f\u7528<a href=\"http:\/\/www.cmake.org\/files\/v2.8\/cmake-2.8.12.2-Darwin64-universal.dmg\">2.8.12.2\u7248\u672c<\/a>\u3002\u4e0b\u8f7d\u540e\u5b89\u88c5\u3002<\/p>\n<\/li>\n<li>\n<p>\u63a5\u4e0b\u6765\u5f00\u59cb\u5b89\u88c5opencv(\u6ce8: \u5982\u679c\u9700\u8981\u542f\u7528\u591a\u6838\u652f\u6301, \u53ef\u4ee5\u5148\u6309\u7b2c6\u70b9\u8fdb\u884c\u4fee\u6539\u540e\u518d\u7f16\u8bd1,\u672a\u7ecf\u6d4b\u8bd5)<\/p>\n<\/li>\n<\/ol>\n<p>\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u8fdb\u5165opencv\u89e3\u538b\u7f29\u7684\u76ee\u5f55\uff0c\u5982cd \u7136\u540e\u628a\u6587\u4ef6\u5939\u62fd\u8fdb\u53bb\u3002\nmkdir release\ncd .\/release\ncmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=\/usr\/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..\nmake\nsudo make install<\/p>\n<ol start=\"4\">\n<li>\u81f3\u6b64opencv\u5e94\u8be5\u5df2\u7ecf\u88c5\u4e0a\u4e86\u3002\n<span style=\"color: #ff0000;\">\u00a0\u6ce8\uff1a\u5982\u679ccmake\u51fa\u73b0\u9519\u8bef\uff0c\u8bf7\u5230\u82f9\u679c\u5f00\u53d1\u8005\u7f51\u7ad9\u90a3\u91cc\u4e0b\u8f7dCommand Line Tools\u5b89\u88c5\u3002\uff08\u5173\u952e\uff09<\/span><\/li>\n<\/ol>\n<p>\u7531\u4e8e\u672c\u4eba\u662f\u8981\u5199python\uff0c\u6240\u4ee5\u8fd8\u8981\u8fdb\u884c\u4e0b\u4e00\u6b65\u914d\u7f6e\u3002\u672c\u4ebamac\u662frmbp15\uff0c\u81ea\u5e26\u7684python\u7248\u672c\u662f2.7\uff0c\u7ec8\u7aef\u4e0b\u8f93\u5165python\u540e\u8f93\u5165import cv\uff0c\u5982\u679c\u63d0\u793a\u6ca1\u6709\u627e\u5230cv\uff0c\u8bf7\u6309\u5982\u4e0b\u6b65\u9aa4\u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0ccd ~<\/li>\n<li>vim .profile<\/li>\n<li>\u6dfb\u52a0export PYTHONPATH=\/usr\/local\/lib\/python2.7\/site-packages\/\uff0c\u5176\u4e2dpython2.7\u6839\u636e\u4e2a\u4ebapython\u7248\u672c\u800c\u5b9a\u3002<\/li>\n<li>source .profile<\/li>\n<li>\u81f3\u6b64\u5e94\u8be5\u5168\u90e8\u5b8c\u6210\u4e86\u3002<\/li>\n<\/ol>\n<p>6.\u8865\u5145:<\/p>\n<p>I got this working with OpenCV 2.4.10 and GCC 4.9.2. I also had to make the following additional changes to the <span class=\"skimlinks-unlinked\">CMakeLists.txt<\/span> in the root OpenCV directory:<\/p>\n<p>OCV_OPTION(WITH_OPENEXR \u201cInclude ILM support via OpenEXR\u201d OFF)\nOCV_OPTION(WITH_OPENMP \u201cInclude OpenMP support\u201d ON)\nOCV_OPTION(BUILD_OPENEXR \u201cBuild openexr from source\u201d OFF )<\/p>\n<p>I originally was running into errors with \u201cUndefined symbols for architecture x86_64 cv::imshow, cv::imread, cv::imwrite, etc,\u201d because Homebrew installed a clang OpenCV whereas my project was using GCC. One solution would be to rebuild everything with clang but that was not appealing in my case because I wanted OpenMP support. So I instead used your solution to build a GCC version of OpenCV.<\/p>","protected":false},"excerpt":{"rendered":"<p>\u53bb\u00a0<a href=\"http:\/\/opencv.org\">http:\/\/opencv.org<\/a>\u00a0\u4e0b\u8f7d\u6700\u65b0\u7248OpenCV for Linux\/Mac\u6e90\u6587\u4ef6\uff0c\u76ee\u524d\u7248\u672c\u662f2.4.3\u3002\u4e0b\u8f7d\u540e\u89e3\u538b\u3002 \u53bb\u00a0<a href=\"http:\/\/www.cmake.org\">http:\/\/www.cmake.org<\/a>\u00a0\u4e0b\u8f7d\u6700\u65b0\u7248cmake&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[340],"tags":[350,402,342,445],"class_list":["post-1292","post","type-post","status-publish","format-standard","hentry","category-mac-os","tag-build","tag-cmake","tag-mac","tag-opencv"],"_links":{"self":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=1292"}],"version-history":[{"count":4,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1292\/revisions"}],"predecessor-version":[{"id":1298,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1292\/revisions\/1298"}],"wp:attachment":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=1292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=1292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=1292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}