{"id":1005,"date":"2015-07-03T15:31:42","date_gmt":"2015-07-03T06:31:42","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=1005"},"modified":"2017-06-16T10:08:14","modified_gmt":"2017-06-16T01:08:14","slug":"os-x-opencv-3-python-2-3","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2015\/07\/os-x-opencv-3-python-2-3\/","title":{"rendered":"Mac OS X \u3067 OpenCV 3 + Python 2\/3 \u306e\u958b\u767a\u74b0\u5883\u3092\u6574\u5099\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"
Mac OS X \u3067 OpenCV 3 + Python 2\/3 \u306e\u958b\u767a\u74b0\u5883\u3092\u6574\u5099\u3059\u308b\u65b9\u6cd5\u3092\u307e\u3068\u3081\u307e\u3059. \u4eca\u56de\u3053\u306e\u65b9\u6cd5\u3067\u5c0e\u5165\u30c6\u30b9\u30c8\u3092\u884c\u306a\u3063\u305f\u74b0\u5883\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059.<\/p>\n
<\/p>\n
Mac OS X + OpenCV 2 + Python 2 \u3067\u306e\u74b0\u5883\u69cb\u7bc9\u306b\u3064\u3044\u3066\u306f\u3053\u3061\u3089<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044.<\/p>\n \u3053\u308c\u306b\u3064\u3044\u3066\u306f\u591a\u304f\u306e\u65b9\u304c\u65e2\u306b\u5c0e\u5165\u3055\u308c\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u7701\u7565\u3057\u307e\u3059. \u8a73\u3057\u304f\u306f Homebrew \u306e\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044.<\/p>\n NumPy \u306f homebrew-python<\/a>, OpenCV \u306f homebrew-science<\/a> \u306b Formula \u304c\u3042\u308b\u306e\u3067, \u305d\u308c\u305e\u308c tap \u3057\u3066\u304a\u304d\u307e\u3059.<\/p>\n Homebrew \u304b\u3089\u6700\u65b0\u5b89\u5b9a\u7248\u306e Python 2.7 \/ 3.4 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059.<\/p>\n OS X \u306b\u5165\u3063\u3066\u3044\u308b Python \u3067\u306f\u306a\u304f, Homebrew \u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f Python \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059. Homebrew \u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092 \/usr\/local \u4ee5\u4e0b (\u30c7\u30d5\u30a9\u30eb\u30c8) \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u5834\u5408<\/p>\n \u3092\u5b9f\u884c\u3057\u3066,<\/p>\n \u304c\u8868\u793a\u3055\u308c\u308c\u3070 OK \u3067\u3059. Python 3 \u306b\u3064\u3044\u3066\u3082\u540c\u69d8\u306e\u65b9\u6cd5\u3067\u30c1\u30a7\u30c3\u30af\u3067\u304d\u307e\u3059.<\/p>\n OpenCV \u306e Python \u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306f\u30c7\u30fc\u30bf\u3092\u6271\u3046\u305f\u3081\u306b NumPy \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u305f\u3081\u5c0e\u5165\u3057\u307e\u3059. virtualenv \u7b49\u306f\u7528\u3044\u305a\u306b, \u76f4\u63a5\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044. Python 3 \u3067\u3082\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u660e\u793a\u7684\u306b\u30aa\u30d7\u30b7\u30e7\u30f3 ( OpenCV 3 \u3092 Homebrew \u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059. OpenCV 2 \u3068\u306f Formula \u306e\u540d\u524d\u304c\u5909\u308f\u3063\u3066\u3044\u307e\u3059.<\/p>\n \u3092\u5b9f\u884c\u3057, \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3059. \u5fc5\u8981\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066, \u4ee5\u4e0b\u306e\u3088\u3046\u306b OpenCV 3 \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u5b9f\u884c\u3057\u307e\u3059.<\/p>\n 2017\u5e746\u6708\u8ffd\u8a18: \u73fe\u5728\uff0cPython 2 \u307e\u305f\u306f 3 \u306e\u3069\u3061\u3089\u304b\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3057\u304b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059. Python 2 \u304b\u3089 OpenCV 3 \u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f,<\/p>\n Python 3 \u304b\u3089\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f,<\/p>\n \u3092\u5b9f\u884c\u3057\u307e\u3059.\u00a0\u4f9d\u5b58\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3082\u542b\u3081\u5c11\u3057\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059.<\/p>\nHomebrew \u306e\u5c0e\u5165<\/h2>\n
brew tap homebrew\/python\r\nbrew tap homebrew\/science\r\n<\/pre>\n
Python \u306e\u5c0e\u5165<\/h2>\n
brew install python python3\r\n<\/pre>\n
which python\r\n<\/pre>\n
\/usr\/local\/bin\/python\r\n<\/pre>\n
\/usr\/bin\/python<\/code> \u3068\u306a\u308b\u5834\u5408\u306f
PATH<\/code> \u306e\u8a2d\u5b9a\u304c\u51fa\u6765\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081, Homebrew \u306e\u5c0e\u5165\u624b\u9806\u3092\u518d\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044.<\/p>\n
NumPy \u306e\u5c0e\u5165<\/h2>\n
--with-python3<\/code>) \u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059.<\/p>\n
brew install numpy --with-python3\r\n<\/pre>\n
OpenCV \u306e\u5c0e\u5165<\/h2>\n
brew info opencv3\r\n<\/pre>\n
brew install opencv3 --with-python3\r\n<\/pre>\n
brew install opencv3 --with-python3 --without-python\r\n<\/pre>\n
Python \u304b\u3089 OpenCV 3 \u3092\u5229\u7528\u3059\u308b<\/h2>\n
1. \u30b0\u30ed\u30fc\u30d0\u30eb\u74b0\u5883\u306e Python \u3067 OpenCV \u3092\u5229\u7528\u3059\u308b<\/h3>\n