Reading and displaying images using OpenCV


In this article, we will learn how to read and display images using the OpenCV library.

OpenCV is a library of programming functions mainly aimed at real time computer vision. Before reading an image, make sure that the image is in the same directory as your program.

Algorithm

Step 1: Import OpenCV.
Step 2: Read an image using imread().
Step 3: Display the image using imshow().

Example Code

import cv2 as cv
image = cv.imread ('ronaldo.jpg')
cv.imshow('Cristiano Ronaldo', image)

Output

Updated on: 17-Mar-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements