def get_dict(labels): """ Given labels(output from the labels object in fileHandler.py), it creates a dictionary of the form {key:value} Where, key = start time in seconds = start_secs value = line corresponding to that start time = [start, end, name, start_secs, end_secs] Returns: Dictionary """ d = {} for item in labels: #Things are extracted based on labels format name = item[2] #We obtain the start and end time in seconds start_secs = timeFunc.get_seconds(item[0]) end_secs = timeFunc.get_seconds(item[1]) item.append(start_secs) item.append(end_secs) #Create the dictionary d[start_secs] = item return d
def test_generate(): input_file_path = '../test/test.mp4' labels_file_path = '../test/test_labels.txt' input_labels = [] for line in open(labels_file_path): line = line.strip() strt_string, end_string, ad_name = line.split(' - ') strt = get_seconds(strt_string) end = get_seconds(end_string) input_labels.append([strt, end, ad_name]) ad_det = ComDet() ad_det.fingerprint_file(input_file_path, input_labels)
def get_list(labels): l = [] for item in labels: name = item[2] t3 = timeFunc.get_seconds(item[0]) hid = name[0:2] + str(t3) item.append(t3) item.append(hid) l.append(item) return l
def get_line(self, index): """ Function gets the line in the database file based on the index. The index is acting as the line number in the database file. Returns: [name(string), duration(int)] """ f = open(self.filename) i = 0 for line in f: if i == index: line = line.split(",") name = line[0] duration = line[1] duration = timeFunc.get_seconds(duration) return [name, duration] i += 1 print index, i print "Db and csv are not in sync" raise Exception(DB_CSV_OUT_OF_SYNC_ERROR) return -1