Skip to content

Instantly share code, notes, and snippets.

@fanhang64
Last active July 24, 2019 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanhang64/a17e4dbc1836b2f4f0205919319c5e7e to your computer and use it in GitHub Desktop.
Save fanhang64/a17e4dbc1836b2f4f0205919319c5e7e to your computer and use it in GitHub Desktop.
images path
def creat_images_path(video_path, img_path): # aa/
carID_folder_list = os.listdir(video_path)
for carid in carID_folder_list:
carid_path = os.path.join(video_path, carid) # aa/123 aa/456
rootdir_folder_list = os.listdir(carid_path)
rootdir_folder_list.sort()
for camdir in rootdir_folder_list:
if camdir in cam_dict:
file_count = 0
dirpath = carid_path + '/' + camdir
dirnames = os.listdir(carid_path + '/' + camdir)
# for dirpath, dirnames, _ in os.walk(carid_path + '/' + camdir):
dir_names = []
for dirname in dirnames:
dir_name = os.path.join(dirpath, dirname)
dir_names.append(dir_name)
for dir_name in dir_names:
for videoname in os.listdir(dir_name):
filename_path = os.path.join(dir_name, videoname)
if videoname.split('.')[1] == 'hevc':
time_Array = time.strptime(
videoname[:14], '%Y-%m-%d--%H')
time_Stamp = int(
time.mktime(time_Array) * 1000) + 1
file_count += 1
images_folder = carid + "_" + str(cam_dict[camdir]) + "_" + \
str(time_Stamp) + '_' + str(time_Stamp - 1) + \
'_' + 'V' + "%02d" % file_count
videos_path_list = dir_name.split('/')
new_img_path = img_path + '/' + \
videos_path_list[-3] + '/' + \
videos_path_list[-2] + '/' + \
videos_path_list[-1] + '/' + \
images_folder
os.makedirs(new_img_path)
images_folder_dict.update(
{new_img_path: filename_path})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment