1import cv2
2img = cv2.imread('/path_to_image/opencv-logo.png')
3cv2.imshow('image',img)
4cv2.waitKey(0)
5cv2.destroyAllWindows()
6
7# to use it in a loop
8k = cv2.waitKey(0)
9if k == 27: # wait for ESC key to exit
10 cv2.destroyAllWindows()
11elif k == ord('s'): # wait for 's' key to save and exit
12 cv2.imwrite('messigray.png',img)
13 cv2.destroyAllWindows()
14
1import cv2
2#Best Usage
3path = r'image location'
4img = cv2.imread(path)
5#if you use resizde img
6resized_img = cv2.resize(img, (640, 680)) #example 640, 680
7cv2.imshow('resized_img', resized_img)
8cv2.imshow('img', img)
9cv2.waitKey(0)
10cv2.destroyAllWindows()
11
12
13
14