コード例 #1
0
ファイル: filterLabels.py プロジェクト: kevincao91/Tools
    print("cate: {} MinW={}, MinH={}, MinA={}".format(cate, MinW, MinH, MinA))


def find_xmls_with_minimal_size_of_each_cate(xmlDir):
    allCates = find_all_cates(xmlDir)
    for cate in allCates:
        find_xmls_with_minimal_size_of_this_cate(xmlDir, cate)


if __name__ == "__main__":
    xmlDir = r'/DATACENTER4/hao.yang/project/Qin/data/xmls/checkout/xml_checkout_10972_total/'
    tarDir = '/DATACENTER4/hao.yang/project/Qin/data/xmls/checkout/pos_use/'
    FILES.rm_mkdir(tarDir)
    # Uncomment to find some xmls containing all categories and copy matching jpgs
    # find_xmls_with_all_cates(xmlDir)
    # Uncomment to find xmls and jpgs containing given cates
    cates = ['pos_use']
    # filter_short_cates(xmlDir,cates)
    filter_xmls_with_cates(xmlDir, cates)
    # move_xmls_with_cates(xmlDir,cates)
    # filter_xmls_without_cates(xmlDir,cates)
    # Uncomment to find boxes with minimal area, minimal width and minimal height of each category
    # find_xmls_with_minimal_size_of_each_cate(xmlDir)
    # Uncomment to filter xml and jpg whose amount of label_person > label_helmet
    # filter_lack_helmet(xmlDir)
    # Uncomment to copy jpgs referring xmls
    jpgDir = r"/DATACENTER4/hao.yang/project/Qin/data/imgs/checkout/imgs_labeled_all_10972/"
    jpgTar = tarDir
    FILES.mkdir(jpgTar)
    FILES.shutil_by_refer(tarDir, '.xml', '.jpg', jpgDir, jpgTar)
コード例 #2
0
import os
import shutil
import random
# personal lib
from basicFun import FILES
if __name__ == "__main__":
    namei = 0
    members = ['hs', 'yy', 'wzx', 'lf', 'dxj', 'zzh']
    taskImg = r'/disk3/hao.yang/project/Qin/dataRoom/XiWan/safe/img/'
    taskXml = r'/disk3/hao.yang/project/Qin/dataRoom/XiWan/safe/xml/'
    outRoot = r'/disk3/hao.yang/project/Qin/dataRoom/XiWan/safe/labelTaskAssign_safe_XiWan/'
    FILES.rm_mkdir(outRoot)
    for member in members:
        outDir = os.path.join(outRoot, member)
        FILES.mkdir(outDir)
    allXmls = FILES.get_sorted_files(taskXml)
    for xml in [x for x in allXmls if 'xml' in x]:
        desDir = os.path.join(outRoot, members[namei])
        xmlPath = os.path.join(taskXml, xml)
        desXml = os.path.join(desDir, xml)
        # copy file
        shutil.copy(xmlPath, desXml)
        namei += 1
        if namei == len(members):
            namei = 0
            # disorder members list to increase randomness
            random.shuffle(members)
    for member in members:
        outDir = os.path.join(outRoot, member)
        FILES.shutil_by_refer(outDir, '.xml', '.jpg', taskImg, outDir)