this the output but i want to arrange these file names in numerical order like(0,1,2,...1000) and not based on the first value(0,1,10,100)
D:\deep>python merge.py
./data/00.jpg
./data/01.jpg
./data/010.jpg
./data/0100.jpg
./data/0101.jpg
./data/0102.jpg
./data/0103.jpg
./data/0104.jpg
./data/0105.jpg
./data/0106.jpg
./data/0107.jpg
./data/0108.jpg
./data/0109.jpg
./data/011.jpg
./data/0110.jpg
./data/0111.jpg
./data/0112.jpg
./data/0113.jpg
./data/0114.jpg
./data/0115.jpg
./data/0116.jpg
./data/0117.jpg
./data/0118.jpg
./data/0119.jpg
the code i used is the below. i want to sort the filenames in a numerical order i tried using sort function with key as int but it dint work
import cv2
import os
import numpy as np
image_folder = 'd:/deep/data'
video_name = 'video.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".jpg")]
print(images)
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
fourcc = cv2.VideoWriter_fourcc(*'XVID')
video = cv2.VideoWriter(video_name, fourcc,15.0, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()