python - Loading all images using imread from a given folder -


loading , saving images in opencv quite limited, so... preferred ways load images given folder? should search files in folder .png or .jpg extensions, store names , use imread every file? or there better way?

why not try loading files in folder? if opencv can't open it, oh well. move on next. cv2.imread() returns none if image can't opened. kind of weird doesn't raise exception.

import cv2 import os  def load_images_from_folder(folder):     images = []     filename in os.listdir(folder):         img = cv2.imread(os.path.join(folder,filename))         if img not none:             images.append(img)     return images 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -