Prerequisite: Basics of OpenCV
OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on pictures or videos. It was originally developed by Intel but was later maintained by Willow Garage and is now maintained by Itseez. This library is cross-platform that it is available in multiple programming languages such as Python, C++, etc. In this article, we’ll try to check if the opened image is empty or not by using OpenCV (Open Source Computer Vision).
To do this OpenCV libraries are required to install:
pip install opencv-python
To achieve this objective we will use cv2.imread() method, If this method read the image then it returns the image coordinates matrix otherwise it will return None.
In this example, we will read the image and check found or not.
Image is not empty!!
In this example, here the image is not found.
Image is empty!!
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.