read images which start with certain string opencv – python
Question:
I have a folder which is containing thousands of images. I want to read only the images which start with a certain string, let’s say input, how can I do this exactly ?
I am using opencv, so this is how I read all images
inputA_path = os.path.join(inputA_dir, '*g')
inputFilesA =glob.glob(inputA_path)
for f1 in inputFilesA:
inputA = cv2.imread(f1)
Answers:
You could just use glob.glob right away and filter for files starting with input and ending with g.
inputFilesA = glob.glob(inputA_dir+"input*g")
for f1 in inputFilesA:
inputA = cv2.imread(f1)
I have a folder which is containing thousands of images. I want to read only the images which start with a certain string, let’s say input, how can I do this exactly ?
I am using opencv, so this is how I read all images
inputA_path = os.path.join(inputA_dir, '*g')
inputFilesA =glob.glob(inputA_path)
for f1 in inputFilesA:
inputA = cv2.imread(f1)
You could just use glob.glob right away and filter for files starting with input and ending with g.
inputFilesA = glob.glob(inputA_dir+"input*g")
for f1 in inputFilesA:
inputA = cv2.imread(f1)