The first thing to do is to install the Open Cv library. Open the terminal in Pycharm and write
pip install opencv-python on the pycharm terminal
Then import the cv2 library. import cv2 as pp Then read the image using imread. This method returns an image if the given path is correct otherwise it
returns None. This is the way you do it.
Then import the cv2 library. import cv2 as pp Then read the image using imread. This method returns an image if the given path is correct otherwise it
returns None. This is the way you do it.
pic = pp.imread("K:\\Blogspot\\pics\\program output\\latest.png")
This obviously is the full path to the image on my computer.
what is the return value. It is an <class 'numpy.ndarray'>
Here is the full program to load and display an image.
Here is the full program to load and display an image.
import cv2 as pp
pic = pp.imread("K:\\Blogspot\\pics\\program output\\latest.png")
print()
if pic is None:
print("Picture not found")
else:
print(type(pic))
print(pic)
output=pp.imshow("Show Picture", pic)
print(output)
output=pp.waitKey(0)
print(output)
imshow takes 2 inputs windowname and image and returns None. waitKey(0) keeps the window open till it is closed.
Here is the output of the program.
0 Comments