messigray.py

来源:互联网 发布:mysql root默认密码 编辑:程序博客网 时间:2024/06/06 00:09

# -*- coding: utf-8 -*-
"""
Created on Wed Jan 1 20:49:33 2014

@author: duan
"""
import numpy as np
import cv2

img = cv2.imread('messi5.jpg',0)
cv2.imshow('image',img)
k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
    cv2.destroyAllWindows()
elif k == ord('s'): # wait for 's' key to save and exit
    cv2.imwrite('messigray.png',img)
    cv2.destroyAllWindows()


警告:如果你用的是64 位系统,你需要将 k = cv2.waitKey(0) 这行改成
k = cv2.waitKey(0)&0xFF。


0 0
原创粉丝点击