opencv学习——cv2.imshow()显示图片

两种方法,对显示的图片窗口关闭或最大化。

import cv2

img = cv2.imread('images/1.jpg')

## way1: can change the shape of the window and close the window 

#cv2.namedWindow('result',0)
#cv2.startWindowThread()
#cv2.imshow('result',img)
#cv2.waitKey(0)
#cv2.destroyAllWindows()

## way2: can close the window 
##       can not change the shape of the window

cv2.imshow('result.jpg',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.waitKey(1)
cv2.waitKey(1)
cv2.waitKey(1)
cv2.waitKey(1)

你可能感兴趣的:(opencv学习——cv2.imshow()显示图片)