I read in the filenames of some images which are stored like this:
(path/to/images/1_1.png)
(path/to/images/1_2.png) ...
(path/to/images/10_1.png) ...
(path/to/images/1000_1.png)
When reading the filenames to a list with this code
import cv2
import glob
folders = glob.glob(r'C:\Users\tobis\OneDrive\Desktop\Masterarbeit\data\2017-IWT4S-CarsReId_LP-dataset\*')
imagenames_list = []
for folder in folders:
for f in glob.glob(folder+'/*.png'):
imagenames_list.append(f)
The first image in my list is the one that's filename is (path/to/images/1000_1.png)
instead of (path/to/images/1_1.png)
. It is important to get the files in the right order because I need to match the images with another list. Is there a way to sort the list in the way I need it?