示例#1
0
def writeList():
    root_path = '/home/gcao/bash_cmd/music/'
    filenames = loadstr(root_path + 'mylist.txt')
    lst = []
    for f in filenames:
        lst.append('file ' + '\'' + root_path + f + '\'')
    writestr('mylist2.txt', lst)
示例#2
0
def genSrt(srt_dict):
    keys = loadstr(root_path + 'keyframes_santa.list')
    lines = []
    lines.append(1)
    num = double(keys[0][1:5]) -1 
    hour = '00'
    minute = str(int(num/5/60)).zfill(2)
    second = str(num/5.0%60).replace('.',',').zfill(4)
    start_t = hour + ':' + minute + ':' + second + '00'
    srt = srt_dict[root_path + 'data/santa/key/' + keys[0]]
    for k,i in zip(keys[1:], range(1,len(keys))):
        num = double(k[1:5]) 
        minute = str(int(num/5/60)).zfill(2)
        second = str(num/5.0%60).replace('.',',').zfill(4)
        end_t = hour + ':' + minute + ':' + second + '00'
        lines.append(start_t + ' --> ' + end_t)
        lines.append(srt)
        lines.append('')
        start_t = hour + ':' + minute + ':' + second + '25'
        srt = srt_dict[root_path + 'data/santa/key/' + k]
        lines.append(int(i)+1)
    end_t = hour + ':' + minute + ':' + second + '25'
    lines.append(start_t + ' --> ' + end_t)
    lines.append(srt)
    writestr(root_path + 'santa.srt', lines)
示例#3
0
def genSrt(srt_dict):
    keys = loadstr(root_path + 'keyframes_santa.list')
    lines = []
    lines.append(1)
    num = double(keys[0][1:5]) - 1
    hour = '00'
    minute = str(int(num / 5 / 60)).zfill(2)
    second = str(num / 5.0 % 60).replace('.', ',').zfill(4)
    start_t = hour + ':' + minute + ':' + second + '00'
    srt = srt_dict[root_path + 'data/santa/key/' + keys[0]]
    for k, i in zip(keys[1:], range(1, len(keys))):
        num = double(k[1:5])
        minute = str(int(num / 5 / 60)).zfill(2)
        second = str(num / 5.0 % 60).replace('.', ',').zfill(4)
        end_t = hour + ':' + minute + ':' + second + '00'
        lines.append(start_t + ' --> ' + end_t)
        lines.append(srt)
        lines.append('')
        start_t = hour + ':' + minute + ':' + second + '25'
        srt = srt_dict[root_path + 'data/santa/key/' + k]
        lines.append(int(i) + 1)
    end_t = hour + ':' + minute + ':' + second + '25'
    lines.append(start_t + ' --> ' + end_t)
    lines.append(srt)
    writestr(root_path + 'santa.srt', lines)
示例#4
0
def recordRare():
    rare_countries = {}
    for year in range(2010, 2016):
        rare_countries[year] = {} 
        fracs, freq, countries = analysis(year)
        for c in countries:
            if freq[c] < 3 and freq[c] > 0:
                rare_countries[year][c] = freq[c]
    writestr(path + 'info/figures/rare.txt', [rare_countries])
示例#5
0
def genKeyframes():
    Thresh = .2 # We pre-define the threhold to differentiate the key frames.
    dataDir = root_path + 'data/percurso_1/img/'
    # Get all image frames
    from os import listdir
    from os.path import isfile, join
    img_files = [f for f in listdir(dataDir) if isfile(join(dataDir, f))]
    img_files = sorted(img_files)
    keyFrames = []
    hist_ref = processImg(dataDir + img_files[0])
    keyFrames.append(img_files[0])
    for f in tqdm(img_files, 'Generating key frames'):
        hist = processImg(dataDir + f)
        if dist_metrics.eucl_dist(hist_ref, hist) > Thresh:
            keyFrames.append(f)
            hist_ref = hist # Use the first frame of a shot as ref..
    print(shape(keyFrames))
    writestr(root_path + 'keyframes_percurso_1.list', keyFrames)
示例#6
0
def genKeyframes():
    Thresh = .2 # We pre-define the threhold to differentiate the key frames.
    dataDir = root_path + 'data/santa/img/' 
    # Get all image frames
    from os import listdir
    from os.path import isfile, join
    img_files = [f for f in listdir(dataDir) if isfile(join(dataDir, f))]
    img_files = sorted(img_files)
    keyFrames = []
    hist_ref = processImg(dataDir + img_files[0])
    keyFrames.append(img_files[0])
    for f in img_files:
        print f
        hist = processImg(dataDir + f)
        if dist_metrics.eucl_dist(hist_ref, hist) > Thresh:
            keyFrames.append(f)
            hist_ref = hist # Use the first frame of a shot as ref..
    print shape(keyFrames)
    writestr(root_path + 'keyframes_santa.list', keyFrames)