Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pknowledge/ce4fa9e544fd96dcf549a6c1d7746da9 to your computer and use it in GitHub Desktop.
Save pknowledge/ce4fa9e544fd96dcf549a6c1d7746da9 to your computer and use it in GitHub Desktop.
OpenCV Python Tutorial For Beginners - How to Read, Write, Show Images in OpenCV
import cv2
img = cv2.imread('lena.jpg', -1)
cv2.imshow('image', img)
k = cv2.waitKey(0) & 0xFF
if k == 27:
cv2.destroyAllWindows()
elif k == ord('s'):
cv2.imwrite('lena_copy.png', img)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment