Mac+anaconda3+eclipse+opencv4编译环境
版本
anaconda3:Anaconda3-5.3.0-MacOSX-x86_64.pkg(对应python3.7)
opencv4.0.0:https://github.com/opencv/opencv/archive/4.0.0.zip
opencv_contrib4.0.0:https://github.com/opencv/opencv_contrib/archive/4.0.0.zip
eclipse: 2018-09 (4.9.0)
anaconda3安装
与windows下安装软件一样,一路next就可以,安装完成后,软件位置在/anaconda3/目录下
Opencv4.0.0编译
1.下载opencv4.0.0.zip,并解压
2.下载opencv_contrib4.0.0.zip,并解压
3.在opencv-4.0.0目录下创建cmake_binary目录,命令行进入cmakebinary目录
4.编译
cmake
-DBUILD_TIFF=ON
-DBUILD_opencv_java=OFF
-DOPENCV_EXTRA_MODULES_PATH=/Users/AI/opencv/opencv_contrib-4.0.0/modules
-DWITH_CUDA=OFF
-DWITH_OPENGL=ON
-DWITH_OPENCL=ON
-DWITH_IPP=ON
-DWITH_TBB=ON
-DWITH_EIGEN=ON
-DWITH_V4L=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=
(
/
a
n
a
c
o
n
d
a
3
/
b
i
n
/
p
y
t
h
o
n
3.7
−
c
"
i
m
p
o
r
t
s
y
s
;
p
r
i
n
t
(
s
y
s
.
p
r
e
f
i
x
)
"
)
−
D
P
Y
T
H
O
N
E
X
E
C
U
T
A
B
L
E
=
(/anaconda3/bin/python3.7 -c "import sys; print(sys.prefix)") -DPYTHON_EXECUTABLE=
(/anaconda3/bin/python3.7−c"importsys;print(sys.prefix)")−DPYTHONEXECUTABLE=(/anaconda3/bin/python3.7)
-DPYTHON_INCLUDE_DIR=
(
/
a
n
a
c
o
n
d
a
3
/
b
i
n
/
p
y
t
h
o
n
3.7
−
c
"
f
r
o
m
d
i
s
t
u
t
i
l
s
.
s
y
s
c
o
n
f
i
g
i
m
p
o
r
t
g
e
t
p
y
t
h
o
n
i
n
c
;
p
r
i
n
t
(
g
e
t
p
y
t
h
o
n
i
n
c
(
)
)
"
)
−
D
P
Y
T
H
O
N
P
A
C
K
A
G
E
S
P
A
T
H
=
(/anaconda3/bin/python3.7 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_PACKAGES_PATH=
(/anaconda3/bin/python3.7−c"fromdistutils.sysconfigimportgetpythoninc;print(getpythoninc())")−DPYTHONPACKAGESPATH=(/anaconda3/bin/python3.7 -c “from distutils.sysconfig import get_python_lib; print(get_python_lib())”) .
注意相关路径替换
make
make install
5.将/anaconda3/python/cv2/python-3.7/cv2.cpython-37m-darwin.so移动到/anaconda3/lib/python3.7/cv2.cpython-37m-darwin.so目录下
6.命令行输入python,并导入cv2不保存
Eclipse安装配置
1.下载eclipse后解压到想安装的目录,点击启动
2.help->install new soft
3.安装pydey,在弹出的窗口输入http://pydev.org/updates,如下图
一路next即可,网络不好需要等待一段时间
4.重启eclipse切换到pydev视图
5.配置eclipse的python环境eclipse->preferences,如下图
整体测试
eclipse新建pydev项目,添加如下代码运行,完美,我老婆出现了(哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈)
import cv2
img = cv2.imread("./yune.jpeg", 1)
cv2.imshow("1", img)
cv2.waitKey()