Learn Before
Concept

Loading in Assets in OpenCV

This command will work to load in the file named logo.jpg from the assets folder. If you did not include a separate folder to store images and video files, but they are in the same folder as the python script you can just include its file name.

img = cv2.imread('assets/logo.jpg` )

By default OpenCV loads files in BGR and not RGB. We can specify what mode we want to read in the images.

-1, cv2.IMREAD_COLOR #default flag, ignore all transparent areas and load in full image 0, cv2.IMREAD_GRAYSCALE # loads image in grayscale 1, cv2.IMREAD_UNCHANGED # loads in image with alpha channel (transparency info)

0

1

Updated 2021-06-08

Tags

Python Programming Language

Data Science