Skip to content

Instantly share code, notes, and snippets.

@MuhammadFaizanKhan
Last active January 24, 2018 07:38
Show Gist options
  • Save MuhammadFaizanKhan/82b2b35aa93ce41dea316f739322d2ec to your computer and use it in GitHub Desktop.
Save MuhammadFaizanKhan/82b2b35aa93ce41dea316f739322d2ec to your computer and use it in GitHub Desktop.
How to Load image in OpenCV
import cv2 #Import openCV
import sys #import Sys. Sys will be used for reading from the command line. We give Image name parameter with extension when we will run python script
#Read the image. The first Command line argument is the image
image = cv2.imread(sys.argv[1]) #The function to read from an image into OpenCv is imread()
#imshow() is the function that displays the image on the screen.
#The first value is the title of the window, the second is the image file we have previously read.
cv2.imshow("OpenCV Image Reading", image)
cv2.waitKey(0) #is required so that the image doesn’t close immediately. It will Wait for a key press before closing the image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment