美文网首页
opencv python版-lesson 01

opencv python版-lesson 01

作者: writ | 来源:发表于2019-10-09 20:17 被阅读0次

    此为读取显示保存的方法,cv2.imread('opencv.jpg',0)读取灰度图

    import cv2
    # show and save the picture 
    img = cv2.imread('opencv.jpg',0)
    cv2.imshow('image',img)
    cv2.namedWindow('image',cv2.WINDOW_NORMAL)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    cv2.imwrite('{}'.format('opencv.png'),img)
    

    选择分支

    import cv2
    # show and save the picture 
    img = cv2.imread('opencv.jpg',0)
    cv2.imshow('image',img)
    cv2.namedWindow('image',cv2.WINDOW_NORMAL)
    k=cv2.waitKey(0)
    if k==27:
        cv2.destroyAllWindows()
    elif k==ord('s'):
        cv2.imwrite('{}'.format('opencv.png'),img)
        cv2.destroyAllWindows()
    

    相关文章

      网友评论

          本文标题:opencv python版-lesson 01

          本文链接:https://www.haomeiwen.com/subject/oitnpctx.html