Python Opencv之环境搭建(macos)

网上有cmake安装方法那个是源码安装,如果是学习C++的opencv的话建议用cmake源码安装,可以在网上搜索在Xcode环境下搭建Opencv3。我个人是准备后期添加Tensorflow深度学习的有关知识,所以用的是python,python安装方法比较简单。


1.python3安装

先用brew安装python3

brew install python3

opencv3安装

brew install opencv3 --with-python3

拷贝cv2.so

ln -s /usr/local/Cellar/opencv3/3.2.0/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so /usr/local/lib/python3.6/site-packages/cv2.so

在IDLE上测试

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 20:42:06) 

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type "copyright", "credits" or "license()" for more information.

>>> import cv2

>>> cv2.__version__

'3.4.3'

>>> import numpy

>>> numpy.__version__

'1.15.4'

>>>

2.因为我个人用的是pycharm,所以是在pycharm的

Preference --> Project Interpreter -->


Python Opencv之环境搭建(macos)_第1张图片

左下角+号搜索pip、pencv-pyrhon和NumPy并点install packages即可添加,所以pycharm添加还挺方便的。

你可能感兴趣的:(Python Opencv之环境搭建(macos))