def _find_doxygen_input_files(dirs, includes=[]): allfile = set() for d in dirs: includes.append(os.path.dirname(d[0])) for path, exts, recurse in dirs: if os.path.isfile(path): allfile.add(path) allfile = allfile.union(_find_doxygen_dependencies(path, includes)) if not os.path.isdir(path): continue for e in exts: matches = glob.glob(os.path.join(path, e)) allfile = allfile.union(matches) for m in matches: allfile = allfile.union(_find_doxygen_dependencies(m,includes)) if recurse: for d in os.dirlist(path): if os.path.isdir(d): allfile.union(_find_doxygen_input_files((d,exts,recurse), includes)) files = [] for f in allfile: if len(f) > 0 and \ not f.startswith('/usr/include/') and \ not f.startswith('/usr/lib/'): files.append(f) files.sort() return files
def get_label_image(path,coor_list,label_list1): """ 标签和图片,单个图片为单位 path: jpg图片的存储目录 coor_list: 图片中坐标序列,输入图片为单位 label_list1: 图片中标签序列,输入图片为单位 return image_list, label_list 处理后图片为单位 """ image_list = [] label_list = [] picture_name = os.dirlist(path) for i in range(len(picture_name)): picture_path = path + '\\' + picture_name[i] img = cv2.imread(picture_path,0) count = 0 for coord in coor_list[i]: # post1 原图中的四个角点 post1 = [] for i in range(0,8,2): post1.append([coord[i],coord[i+1]]) post1 = np.float32(post1) long = max(np.sqrt(np.sum(np.square(post1[0]-post1[3]))), np.sqrt(np.sum(np.square(post1[1]-post1[2])))) height = max(np.sqrt(np.sum(np.square(post1[0]-post1[1]))), np.sqrt(np.sum(np.square(post1[2]-post1[3])))) # post2 变换后的左上、右上、左下、右下 post2 = np.float([[0,0],[long,0],[0,height],[long,height]]) # 生成透视变换矩阵 M = cv2.getPerspectiveTransform(post1,post2) # 进行透视变换,参数3是目标图像大小参数 dst = cv2.warpPerspective(img,M,(long,height)) # 保存图片到指定位置 label和image对应 pre_label = label_list1[i][count] count += 1 pre_path = '...' + '\\' + pre_label cv2.imwrite(pre_label,dst) # 存为png格式,怎么到指定位置??? image_list.append(pre_path) label_list.append(pre_label) image_list = np.asarray(image_list) label_list = np.asarray(label_list) return image_list, label_list
def check_files(dir_path,file_name_list,update_enable): #update_enable:1 update 0: not update data_type=data_type_check(file_name_list) basename_list=[] update_file_list=[] if data_type is list: for data in file_name_list: basename=os.path.basename(data) basename_list.append(basename) elif data_type is str: basename=os.path.basename(file_name_list) basename.append(basename) else: print("file_name_list data type error") exit() file_list=os.dirlist(dir_path) for file in file_list: for check_file in basename_list: if update_enable: update_file_list.append(check_file) update_file_list.append(check_file) return update_file_list
# -*- coding: utf-8 -*- """ Created on Thu Jul 25 08:49:37 2019 @author: novanto """ import os import cv import cv2 PATH = "C:/Users/novanto/Downloads/AI AU Materials/FINAL PROJECT 4" data_path = PATH + "/test_images" data_dir_list = os.dirlist(data_path) for i in data_dir_list: img1 = cv.imread(data_path + "/" + i) img2 = cv2.resize(img1, (224, 224), interpolation=cv2.INTER.CUBIC) cv2.imwrite(data_path + "/" + i, img2) print(data_path + "/" + i)
def search(x): file_list = [f for f in os.dirlist('.') if os.path.isfile(f)]
import glob import geant as geant baseDir = '/global/scratch/bcplimley/electrons/parameterTests/' dirform = 'e_Si_*' fform = 'Mat_*.dat' dirlist = glob.glob(os.path.join(baseDir,dirform)) print('Found ' + str(len(dirlist)) + 'directories') print('') for d in dirlist[0]: flist = glob.glob(os.path.join(baseDir,d,fform)) fullflist = os.dirlist(os.path.join(baseDir,d)) print('Found ' + str(len(flist)) + ' files in ' + d) print('') for f in flist: savename = 'ranges_' + f[4:-4] + '.txt' if savename in fullflist: continue electron = geant.separateElectrons(geant.loadG4Data( os.path.join(baseDir,d,f))) savefile = open(os.path.join(baseDir,d,savename),'w') for e in electron: energyString = str(geant.measureEnergyKev(e)) rangeString = str(geant.measureExtrapolatedRangeX(e)) writeString = energyString + ',' + rangeString + '\n' savefile.write(writeString)
import glob import geant as geant baseDir = '/global/scratch/bcplimley/electrons/parameterTests/' dirform = 'e_Si_*' fform = 'Mat_*.dat' dirlist = glob.glob(os.path.join(baseDir, dirform)) print('Found ' + str(len(dirlist)) + 'directories') print('') for d in dirlist[0]: flist = glob.glob(os.path.join(baseDir, d, fform)) fullflist = os.dirlist(os.path.join(baseDir, d)) print('Found ' + str(len(flist)) + ' files in ' + d) print('') for f in flist: savename = 'ranges_' + f[4:-4] + '.txt' if savename in fullflist: continue electron = geant.separateElectrons( geant.loadG4Data(os.path.join(baseDir, d, f))) savefile = open(os.path.join(baseDir, d, savename), 'w') for e in electron: energyString = str(geant.measureEnergyKev(e)) rangeString = str(geant.measureExtrapolatedRangeX(e)) writeString = energyString + ',' + rangeString + '\n' savefile.write(writeString)
def init_engines(self): for file_name in os.dirlist(properties.engines): print "engine", file_name
def run(**args): print("[*] In dirlist module") files = os.dirlist(".") return str(files)