OpenCV imshow无法显示图片

问题:imshow图片无法显示

症状:

 

解决方案,将cv2.waitKey(0)与cv.imshow('imgage', img)写到一起

 

 

 

 1 import numpy as np
 2 import cv2
 3 
 4 img = cv2.imread('F:/team.jpg', 0)  
 5 cv2.imshow('image', img)
 6 # waitKey, represent the Keyboard function
 7 k = cv2.waitKey(0)
 8 if k == 27:         # wait for ESC key to exit
 9     cv2.destroyAllWindows()
10 elif k == ord('s'):   # wait for 's' key to save and exit
11     cv2.imwrite('messigray.png',img)
12     cv2.destroyAllWindows()
13

 

posted @ 2018-03-16 16:10  bellum  阅读(1196)  评论(0编辑  收藏  举报