Python OpenCV – imdecode() Function
Python cv2.imdecode() function is used to read image data from a memory cache and convert it into image format. This is generally used for loading the image efficiently from the internet.
- buf – It is the image data received in bytes
- flags – It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR
Return: Image array
Note: If buf given is not image data then NULL will be returned.
Example 2: If grayscale is required, then 0 can be used as flag.
Example 3: Reading image from a file