Let's get started with the basics of OpenCV's Python API. All the scripts we will write and run will be done using the OpenCV library, which must be imported with the line
import cv2. We will import a few more libraries as needed in the next sections and chapters.
cv2.imread() method is used to import an image. It takes two arguments. The first argument is the image filename. The image should either be in the same directory where the Python script is, or the absolute path should be provided to
cv2.imread(). It reads images and saves it as a NumPy array.
The second argument is a flag which specifies the mode the image should be read in. The flag can have following values:
cv2.IMREAD_COLOR: This loads a color image. This is ...