コード例 #1
0
ファイル: kthactions.py プロジェクト: jethrotan/bobo
def export(outdir=None, clean=False):
    # Unpack dataset
    cache = Cache(cacheroot=outdir, subdir=VISET)        
    outfile = cache.abspath('%s.csv' % VISET)            

    if clean:
        cache.clean()
    elif os.path.isfile(outfile):
        print '[bobo.viset.kthactions]: exporting "%s"' % outfile
        return outfile
                        
    print '[bobo.viset.kthactions][WARNING]: downloads will not show percent progress since content length is unknown'
    for (url, label, sha1) in zip(URLS, LABELS, SHA1):
        cache.unpack(cache.get(url, sha1), cache.abspath(label), cleanup=False)

    # Check for frame export utility
    #if not isexe('ffmpeg'):
    #    raise IOError('[bobo.viset.kthactions]: ffmpeg not found on path')
                    
    # Video list
    with open(outfile, 'wb') as csvfile:
        f = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)                   
        for (idx_category, category) in enumerate(os.listdir(cache.root())):
            if os.path.isdir(os.path.join(cache.root(), category)):
                for (idx_video, filename) in enumerate(os.listdir(os.path.join(cache.root(), category))):    
                    [avibase,ext] = os.path.splitext(filename)
                    if ext == '.avi':
                        imdir = cache.abspath(os.path.join(category, avibase))                        
                        print '[bobo.viset.kthactions]: exporting "%s" to "%s"' % (filename, imdir)
                        f.writerow([os.path.join(category, avibase, 'im_%08d.png'), category]);                                        
                        cmd = "ffmpeg -i \'%s\' %s/im_%%08d.png &> /dev/null" % (os.path.join(cache.root(), category, filename), imdir)
                        remkdir(imdir)                        
                        if os.system(cmd) != 0:
                            raise IOError('Error running ffmpeg')
    return outfile
コード例 #2
0
ファイル: hmdb.py プロジェクト: jethrotan/bobo
def export(outdir=None, clean=False):
    # Unpack dataset
    cache = Cache(cacheroot=outdir, subdir=VISET)        
    if clean:
        cache.clean()
                        
    rarfile = unpack(cache.get(URL, SHA1), cache.root())

    vidlist = []
    for (idx_category, category) in enumerate(os.listdir(cache.root())):
        if os.path.isdir(os.path.join(cache.root(), category)):
            for (idx_video, filename) in enumerate(os.listdir(os.path.join(cache.root(), category))):    
                [avibase,ext] = os.path.splitext(filename)
                if ext == '.avi':
                    vidlist.append( (os.path.join(category, filename), category) )
    return vidlist