I want to read multiple images on a same folder using opencv (python). To do that do I need to use for
loop or while
loop with imread
funcion? If so, how? please help me...
I want to get images into an array and then processed them one at a time through a loop.
At first, we imported the pathlib module from Path. Then we pass the directory/folder inside Path() function and used it . glob('*. png') function to iterate through all the images present in this folder.
You can add two images with the OpenCV function, cv. add(), or simply by the numpy operation res = img1 + img2. Both images should be of same depth and type, or the second image can just be a scalar value.
import glob
import cv2
images = [cv2.imread(file) for file in glob.glob("path/to/files/*.png")]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With