Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

OpenCV Read image

  • imread
  • imshow
  • waitKey
import cv2 as cv
import sys

if len(sys.argv) != 2:
    exit(f"Usage: {sys.argv[0]} FILENAME")

filename = sys.argv[1]

original = cv.imread(filename)
#print(type(original))  # numpy.ndarray
print(original.shape)

cv.imshow('Original', original)
cv.waitKey(0)
  • press any key to stop the display