官方编译的OpenCV中只带了Python2的链接库,Python3的链接库需要自己特别编译,官方编译版下载地址:http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
1. 解压opencv-3.0.0.exe到D:/,安装cmake,安装Python3.4(32位)且Python 需要安装 numpy(我装的是Anaconda,自带numpy)。
2. CMake设置:
1) cmake选择编译器为Visual Studio 10
2) Build类型中选择Build_opencv_python3,ps. 需要正确填写python3的参数,才能生成Build_opencv_python3的选项
3) 生成OpenCV的VS项目
3. 用Release模式编译bindings/opencv_python3部分,将 “<BinaryOutput>\lib\release\cv2.pyd” 和 “<BinaryOutput>\bin\Release下所有的dll文件” 全部拷贝到C:\Anaconda3\DLLs
4. 测试cv2模块:
import cv2 img = cv2.imread("D:\\acircles_pattern.png") cv2.namedWindow("Image") cv2.imshow("Image", img) cv2.waitKey (0) cv2.destroyAllWindows()
Reference:
1] http://stlt1sean.blogspot.sg/2013/05/64python-cv2pyd.html
2] http://www.crifan.com/summary_python_unicodedecode_error_possible_reasons_and_solutions/
3] http://www.360doc.com/content/14/0702/12/16740871_391447981.shtml