Beispiel #1
0
    roots="/DATACENTER4/hao.yang/project/Qin/data/preProcess/extractFrame/"
    rootsName=['0706_checkout']
    for rootName in rootsName:
        rootdir=os.path.join(roots,rootName)
        tardir=os.path.join(roots,rootName+"All") #不用创建
        print(rootdir,tardir)
        i=1
        if os.path.exists(rootdir):
            FILES.mkdir(tardir)
            alldirs=FILES.get_sub_dirs(rootdir)
            for dirName in alldirs:
                if 'test' in dirName:
                    continue
                dirpath=os.path.join(rootdir,dirName)
                # print(dirpath)
                alljpg=sorted([x for x in FILES.get_files(dirpath) if ".jpg" in x])#审核为.jpg形成列表
                for jpg in alljpg:
                    # rename
                    # newJpg=dirpath.split("/")[-1]+str("%06d"%i)+".jpg"
                    newJpg='{}_{}'.format(dirName,jpg)
                    # newJpg=jpg
                    i+=1
                    oldpath=os.path.join(dirpath,jpg)
                    newpath=os.path.join(tardir,newJpg)
                    shutil.copy(oldpath,newpath)
        print(time.clock()-timeStart)


# i=1
# dir1=r"E:\BUS\BUS1"
# filelist=os.listdir(dir1) 
Beispiel #2
0
#encoding=utf8
#由于文件夹中只标注了部分refer,因此按照xx.refer复制已标注的xx.jpg和xx.refer到新的文件夹
#单文件夹
import os
import shutil
import time
from basicFun import FILES
if __name__=="__main__":
    count=0    
    start=time.time()
    operators=['gs','hs','px','tsy','zxy','yy','wzx','lf','dxj']
    referDir1="/DATACENTER6/hao.yang/dataRoom/Qin/trade/labelTask_phone/labels_phone/"
    referForm=".xml"
    allRefers=[x for x in FILES.get_files(referDir1) if referForm in x]#审核为.refer形成列表
    # dirName='safe_close'
    for operator in operators:
        count=0
        # referDir2=referDir1.replace('door_close','door_open')
        sourDir="/DATACENTER6/hao.yang/dataRoom/Qin/trade/labelTask_phone/{}".format(operator)
        sourForm=".jpg"
        tarDir='/DATACENTER6/hao.yang/dataRoom/Qin/trade/labelTask_phone/abandon/'
        # tarDir=os.path.join(tarDir,operator)
        tarForm=".jpg"
        FILES.mkdir(tarDir)
        allImgs=[x for x in FILES.get_files(sourDir) if sourForm in x]
        for img in allImgs:
            if img.replace(sourForm,referForm) not in allRefers:
                sour=img.split('.')[0]+sourForm
                tar=img.split('.')[0]+tarForm
                sourPath=os.path.join(sourDir,sour)
                tarPath=os.path.join(tarDir,tar)
Beispiel #3
0
        # font_label = ImageFont.truetype('/DATACENTER2/yh/resources/heiti.TTF',50)
        # img_PIL = Image.fromarray(cv2.cvtColor(image,cv2.COLOR_BGR2RGB)) # cv2==>PIL
        # draw = ImageDraw.Draw(img_PIL)
        # draw.text((xmin,ymax-50),label_name,font_color,font=font_label)
        # image = cv2.cvtColor(numpy.asarray(img_PIL),cv2.COLOR_RGB2BGR) # PIL==>cv2
    # img_PIL = Image.fromarray(cv2.cvtColor(image,cv2.COLOR_BGR2RGB)) # cv2==>PIL
    # draw = ImageDraw.Draw(img_PIL)
    # image = cv2.cvtColor(numpy.asarray(img_PIL),cv2.COLOR_RGB2BGR) # PIL==>cv2
    return image


if __name__ == "__main__":
    start = time.time()
    jpgDir = r"/disk2/hao.yang/project/Qin/data/xmls/isle/complete/imgs_overlook_16000_test/"
    xmlDir = r"/disk2/hao.yang/project/Qin/data/xmls/isle/complete/isle_FMXX_test_16000/"
    outDir = r"/disk2/hao.yang/project/Qin/data/xmls/isle/complete/imgs_overlook_16000_test_truth/"
    FILES.rm_mkdir(outDir)
    allJpgs = FILES.get_files(jpgDir)
    for jpg in allJpgs:
        # print(jpg)
        if '.jpg' in jpg:
            jpgPath = os.path.join(jpgDir, jpg)
            xmlPath = os.path.join(xmlDir, jpg.split('.')[0] + '.xml')
            objs = XML.read_objects(xmlPath)
            image = cv2.imread(jpgPath)
            img = drawXml(image, objs)
            desImg = os.path.join(outDir, jpg)
            cv2.imwrite(desImg, img)

    # extraFrames(davDir,mp4Dir)