Python OpenCV – haveImageReader() function
Last Updated :
03 Jan, 2023
In this article, we are going to learn about the haveImageReader() function of the OpenCV library.
The haveImageReader() function is used to check whether specified images can be decoded or read successfully by OpenCV or not. Sometimes we need to detect if the specified image file is being correctly read before continuing. In such a case we can use this function.
Syntax: return_value=cv2.haveImageReader(Image_File_Name)
Parameter:
- Image_File_Name: Name of the image
Return value: This method returns True if specified image read successfully otherwise it returns False.
Example 1:
We will use the following image in our code and check whether it can be read correctly or not.
Sky.jpg
Code:
Python3
import cv2
return_val = cv2.haveImageReader( "Sky.jpg" )
print (return_val)
|
Output:
True
Example 2:
Now we will check what will be the output when we give the wrong image name.
Python3
import cv2
return_val = cv2.haveImageReader( "rose.jpg" )
print (return_val)
|
Output:
False
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...