예제 #1
0
def calculate_ws_on_rawdata(frame_path, store_path, dim):
    fl = Frameloader(frame_path)
    fl.validate(store_path)
    while len(fl.frame_parent_paths) != 0:
        name = fl.get_current_video_name()
        frames = np.array(fl.load_frames(mode='color'))
        ws = Weightedsum(name, frames, store_path)
        if dim == 0:
            ws.mean_descriptor_gen()
        else:
            ws.ws_on_raw_data(dim)
예제 #2
0
def cal_mean(s_path, W_path):
    nr = Npyfilereader(s_path)
    nr.validate(W_path)
    video_num = len(nr.npy_paths)
    for i in range(video_num):
        name, contents = nr.read_npys()
        ws = Weightedsum(name, contents, W_path)
        # if ws.pre_processing() == -1:
        #     print(name)
        #     problem_path.append(name)
        #     continue
        ws.mean_descriptor_gen()
예제 #3
0
def calculate_weightedsum(frame_features_path, store_path, dim, flip=False):
    nr = Npyfilereader(frame_features_path)
    nr.validate(store_path)
    video_num = len(nr.npy_paths)
    for i in range(video_num):
        name, contents = nr.read_npys()
        # contents = contents[0::5]
        if flip == True:
            contents = np.flip(contents, axis=0)
        ws = Weightedsum(name, contents, store_path)
        if dim == 0:
            ws.mean_descriptor_gen()
        else:
            ws.ws_descriptor_gen(dim)
예제 #4
0
def calculate_weightedsum_fixed_len(train_data, dim, clip_len, flip=False):
    trans_m = None
    ws_des = []
    for data in train_data:
        if flip == True:
            data = np.flip(data, axis=0)
        ws = Weightedsum(None, data, None)
        if dim == 0:
            ws.mean_descriptor_gen()
        else:
            if trans_m is None:
                trans_m = ws.transformation_matrix_gen(dim, clip_len)
            ws_des.append(
                ws.ws_descriptor_gen(dim, save=False, trans_matrix=trans_m))
    return np.array(ws_des)
예제 #5
0
def ws_flows(flow1_path, flow2_path, save_path1, save_path2, dim):
    # flow 1
    nr1 = Npyfilereader(flow1_path)
    nr1.validate(save_path1)
    # flow 2
    nr2 = Npyfilereader(flow2_path)
    nr2.validate(save_path2)

    video_num = len(nr1.npy_paths)
    for i in range(video_num):
        name1, contents1 = nr1.read_npys()
        name2, contents2 = nr2.read_npys()
        ws1 = Weightedsum(name1, contents1, save_path1)
        ws2 = Weightedsum(name2, contents2, save_path2)
        if dim == 0:
            ws1.mean_descriptor_gen()
            ws2.mean_descriptor_gen()
        else:
            trans_m = ws1.transformation_matrix_gen(dim, ws1.frame_features.shape[0])
            ws1.ws_descriptor_gen(dim, trans_matrix=trans_m)
            ws2.ws_descriptor_gen(dim, trans_matrix=trans_m)