0

I need to read a folder with a lot of .bmp files, and put all of the images on a lits of images. I do not know how to handle the adress. I was doing some thing like this:

adress = "c:/Users/My Name/Desktop/assignment/*.bmp"

imageArray = [cv2.imread(file) for file in glob.glob(adress)]

numImg = len(imageArray)

Inside the assignment folder, there is the Images folder with all the images I need. How to make this work?

guib
  • 115
  • 5

1 Answers1

0

Change working directory first:

If you change to the directory of interest first, it may be easier.

import glob, os
os.chdir("/mydir")

image_type = "*.bmp"

imageArray = [cv2.imread(file) for file in glob.glob(image_type)]

numImg = len(imageArray)

This LINK has some nice info about reading files in directories

Dodge
  • 3,219
  • 3
  • 19
  • 38