def create_vot_db(db_name, save_path, vot_path, vot_stats, vot_data_path, bounding_box=None, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for VOT Challenge Dataset. Main function wrappers for VOT Challenge Dataset. Parameters ---------- db_name : string Database name save_path : string the destination of the database vot_path : string the destination of the vot record vot_stats : dictionary the dictionary that contains VOT's stats vot_data_path : string destination of UCF-50 dataset bounding_box : dictionary collection of bounding boxes for each sequence device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics vot_list = vot_stats["vot_list"] num_frames = vot_stats['num_frames'] num_seq = len(vot_list) database = init_database(db_name, save_path) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for i in xrange(num_seq): if vot_list[i] not in database: metadata = {"num_frames": num_frames[i]} record_path = os.path.join(vot_path, vot_list[i]+".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(vot_list[i], record_data, database, group=database, bounding_box=bounding_box[vot_list[i]], metadata=metadata) print "[MESSAGE] Sequence %s is saved" % vot_list[i] database.flush() database.close() print "[MESSAGE] TrackingDataset is saved to %s" % (save_path)
def create_tracking_db(db_name, save_path, tracking_path, tracking_stats, bounding_box=None, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for TrackingDataset. Main function wrappers for TrackingDataset. Parameters ---------- db_name : string Database name save_path : string the destination of the database tracking_path : string the destination of the tracking record tracking_stats : dictionary the dictionary that contains TrackingDataset's stats bounding_box : dictionary collection of bounding boxes for each sequence device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics primary_list = tracking_stats["primary_list"] secondary_list = tracking_stats["secondary_list"] database = init_database(db_name, save_path) gen_tracking_db(database, tracking_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for pc in primary_list: # I didn't record primary group Kalal # FIXME: fix this if I recorded primary group Kalal if pc != "Kalal": for sc in secondary_list[pc]: if sc not in database[pc]: metadata = {"num_frames": len(tracking_stats[sc])} record_path = os.path.join(tracking_path, sc + ".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(sc, record_data, database, group_path=pc, metadata=metadata, bounding_box=bounding_box[sc]) print "[MESSAGE] Sequence %s is saved" % sc database.flush() database.close() print "[MESSAGE] TrackingDataset is saved to %s" % (save_path)
def create_tracking_db(db_name, save_path, tracking_path, tracking_stats, bounding_box=None, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for TrackingDataset. Main function wrappers for TrackingDataset. Parameters ---------- db_name : string Database name save_path : string the destination of the database tracking_path : string the destination of the tracking record tracking_stats : dictionary the dictionary that contains TrackingDataset's stats bounding_box : dictionary collection of bounding boxes for each sequence device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics primary_list = tracking_stats["primary_list"] secondary_list = tracking_stats["secondary_list"] database = init_database(db_name, save_path) gen_tracking_db(database, tracking_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for pc in primary_list: # I didn't record primary group Kalal # FIXME: fix this if I recorded primary group Kalal if pc != "Kalal": for sc in secondary_list[pc]: if sc not in database[pc]: metadata = {"num_frames": len(tracking_stats[sc])} record_path = os.path.join(tracking_path, sc+".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(sc, record_data, database, group_path=pc, metadata=metadata, bounding_box=bounding_box[sc]) print "[MESSAGE] Sequence %s is saved" % sc database.flush() database.close() print "[MESSAGE] TrackingDataset is saved to %s" % (save_path)
def create_ucf50_db(db_name, save_path, ucf50_path, ucf50_stats, ucf50_data_path, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for UCF-50. Main function wrappers for UCF-50. Parameters ---------- db_name : string Database name save_path : string the destination of the database ucf50_path : string the destination of the ucf-50 record ucf50_stats : dictionary the dictionary that contains UCF-50's stats ucf50_data_path : string destination of UCF-50 dataset device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics ucf50_list = ucf50_stats["ucf50_list"] database = init_database(db_name, save_path) gen_ucf50_db(database, ucf50_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for category in ucf50_list: for vidn in ucf50_stats[category]: if vidn not in database[category]: # find number of frames vid_path = os.path.join(ucf50_data_path, category, vidn) num_frames = helpers.count_video_frames(vid_path) metadata = {"num_frames": num_frames} record_path = os.path.join(ucf50_path, category, vidn[:-4]+".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(vidn[:-4], record_data, database, group_path=category, metadata=metadata) print "[MESSAGE] Sequence %s is saved" % vidn[:-4] database.flush() database.close() print "[MESSAGE] TrackingDataset is saved to %s" % (save_path)
# Load groundtruth and image lists print "[MESSAGE] Loading ground truth" groundtruth = np.loadtxt(tracking_dir + pcg + "/" + scg + "/groundtruth.txt", dtype=np.float, delimiter=",") gt = helpers.trans_groundtruth(groundtruth) gt = np.reshape(gt, (gt.shape[0], 4, 2)) print "[MESSAGE] Ground truths and image lists are loaded." base_path = tracking_dir + pcg + "/" + scg + "/" origin_frame = cv2.imread(base_path + tracking_stats[scg][0]) num_frames = len(tracking_stats[scg]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(save_path + scg + ".aedat") (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, fs, _ = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames, fs=3) print len(frames)
num_seq = len(vot_list) bounding_boxes = {} for i in xrange(num_seq): # load groundtruth gt_path = os.path.join(vot_data_path, vot_list[i]+"/groundtruth.txt") gt = np.loadtxt(gt_path, dtype=float, delimiter=",") gt = np.reshape(gt, (gt.shape[0], 4, 2)) # load a frame as reference frame_path = os.path.join(vot_data_path, vot_list[i]+"/00000001.jpg") origin_frame = cv2.imread(frame_path) print "[MESSAGE] Loading sequence %s" % (vot_list[i]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(os.path.join(vot_path, vot_list[i]+".aedat")) (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, _, ts = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames[i], fs=3) ts = np.array(ts) print "[MESSAGE] Number of frames (original): %i" % (num_frames[i]) print "[MESSAGE] Number of frames: %i" % (len(frames)) print "[MESSAGE] Size of TS: %i" % (ts.shape[0]) shift = helpers.cal_img_shift(origin_frame.shape, frames[0].shape) ratio = helpers.cal_bound_box_ratio(gt, origin_frame.shape[0], origin_frame.shape[1]) gt = helpers.cal_bound_box_position(ratio,
num_seq = len(vot_list) bounding_boxes = {} for i in xrange(num_seq): # load groundtruth gt_path = os.path.join(vot_data_path, vot_list[i] + "/groundtruth.txt") gt = np.loadtxt(gt_path, dtype=float, delimiter=",") gt = np.reshape(gt, (gt.shape[0], 4, 2)) # load a frame as reference frame_path = os.path.join(vot_data_path, vot_list[i] + "/00000001.jpg") origin_frame = cv2.imread(frame_path) print "[MESSAGE] Loading sequence %s" % (vot_list[i]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(os.path.join(vot_path, vot_list[i] + ".aedat")) (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, _, ts = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames[i], fs=3) ts = np.array(ts) print "[MESSAGE] Number of frames (original): %i" % (num_frames[i]) print "[MESSAGE] Number of frames: %i" % (len(frames))
def create_vot_db(db_name, save_path, vot_path, vot_stats, vot_data_path, bounding_box=None, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for VOT Challenge Dataset. Main function wrappers for VOT Challenge Dataset. Parameters ---------- db_name : string Database name save_path : string the destination of the database vot_path : string the destination of the vot record vot_stats : dictionary the dictionary that contains VOT's stats vot_data_path : string destination of VOT dataset bounding_box : dictionary collection of bounding boxes for each sequence device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics vot_list = vot_stats["vot_list"] num_frames = vot_stats['num_frames'] num_seq = len(vot_list) database = init_database(db_name, save_path) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for i in xrange(num_seq): if vot_list[i] not in database: metadata = {"num_frames": num_frames[i]} record_path = os.path.join(vot_path, vot_list[i] + ".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(vot_list[i], record_data, database, group=database, bounding_box=bounding_box[vot_list[i]], metadata=metadata) print "[MESSAGE] Sequence %s is saved" % vot_list[i] database.flush() database.close() print "[MESSAGE] VOT Dataset is saved to %s" % (save_path)
pcg = primary_list[0] scg = tracking_stats["secondary_list"][pcg][0] # Load groundtruth and image lists print "[MESSAGE] Loading ground truth" groundtruth = np.loadtxt(tracking_dir+pcg+"/"+scg+"/groundtruth.txt", dtype=np.float, delimiter=",") gt = helpers.trans_groundtruth(groundtruth) gt = np.reshape(gt, (gt.shape[0], 4, 2)) print "[MESSAGE] Ground truths and image lists are loaded." base_path = tracking_dir+pcg+"/"+scg+"/" origin_frame = cv2.imread(base_path+tracking_stats[scg][0]) num_frames = len(tracking_stats[scg]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat( save_path+scg+".aedat") (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, fs, _ = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames, fs=3) print len(frames) shift = helpers.cal_img_shift(origin_frame.shape, frames[0].shape) ratio = helpers.cal_bound_box_ratio(gt, origin_frame.shape[0], origin_frame.shape[1]) new_pts = helpers.cal_bound_box_position(ratio, frames[0].shape[0]-shift[1],
for sc in secondary_list[pc]: # load groundtruth gt_path = os.path.join(td_path, pc, sc, "groundtruth.txt") gt = np.loadtxt(gt_path, dtype=np.float32, delimiter=",") gt = helpers.trans_groundtruth(gt, method="size") gt = np.reshape(gt, (gt.shape[0], 4, 2)) # load one original frame frame_path = os.path.join(td_path, pc, sc, tracking_stats[sc][0]) origin_frame = cv2.imread(frame_path) # loading and process DVS recordings print "[MESSAGE] Loading sequence %s" % (sc) num_frames = len(tracking_stats[sc]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(os.path.join(tracking_path, sc+".aedat")) (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, _, ts = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames, fs=3) ts = np.array(ts) print "[MESSAGE] Number of frames (original): %i" % (num_frames) print "[MESSAGE] Number of frames: %i" % (len(frames)) print "[MESSAGE] Size of TS: %i" % (ts.shape[0]) shift = helpers.cal_img_shift(origin_frame.shape, frames[0].shape) ratio = helpers.cal_bound_box_ratio(gt, origin_frame.shape[0], origin_frame.shape[1]) gt = helpers.cal_bound_box_position(ratio,
def create_caltech256_db(db_name, save_path, caltech256_path, caltech256_stats, device="DAViS240C", fps=10, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for Caltech-256. Main function wrappers for Caltech-256. Parameters ---------- db_name : string Database name save_path : string the destination of the database caltech256_path : string the destination of the Caltech-256 record caltech256_stats : dictionary the dictionary that contains Caltech-256's stats caltech256_data_path : string destination of Caltech-256 dataset device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics caltech256_list = caltech256_stats["caltech256_list"] database = init_database(db_name, save_path) gen_caltech256_db(database, caltech256_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for class_name in caltech256_list: for img_name in caltech256_stats[class_name]: img_n, img_ex = os.path.splitext(img_name) if img_n not in database[class_name]: # find number of frames num_frames = fps metadata = {"num_frames": num_frames} record_path = os.path.join(caltech256_path, class_name, img_n+".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(img_n, record_data, database, group_path=class_name, metadata=metadata) print "[MESSAGE] Sequence %s is saved" % img_n database.flush() database.close() print "[MESSAGE] Caltech-256 is saved to %s" % (save_path)
temp_frame[:, :, 0] = frame temp_frame[:, :, 1] = frame temp_frame[:, :, 2] = frame rgb_frames.append(temp_frame) new_frames = gui.draw_poly_box_sequence(rgb_frames, gt, color=[0, 0, 255]) for i in xrange(len(new_frames)): img_name = join(seq_save_path, "%08d" % (i + 1, ) + ".png") cv2.imwrite(img_name, new_frames[i]) print "Sequence %s is saved at %s" % (vidseq, seq_save_path) if option == "white-test": test_path = os.path.join(data_path, "test.aedat") (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(test_path) event_arr = dvsproc.cal_event_count(timestamps) event_freq = dvsproc.cal_event_freq(event_arr, window=1000) plt.figure(figsize=(18, 8)) plt.plot(event_freq[:, 0] / 1e3, event_freq[:, 1], linewidth=2) plt.xlabel("Time (s)") plt.ylabel("Event Frequency") plt.savefig(os.path.join(data_path, "event_freq.pdf")) timestamps = timestamps - timestamps[0] timestamps = timestamps[:10000] tend = timestamps[-1] vv = np.zeros((tend + 1, )) for i in xrange(timestamps.shape[0]):
def create_caltech256_db(db_name, save_path, caltech256_path, caltech256_stats, device="DAViS240C", fps=10, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for Caltech-256. Main function wrappers for Caltech-256. Parameters ---------- db_name : string Database name save_path : string the destination of the database caltech256_path : string the destination of the Caltech-256 record caltech256_stats : dictionary the dictionary that contains Caltech-256's stats caltech256_data_path : string destination of Caltech-256 dataset device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics caltech256_list = caltech256_stats["caltech256_list"] database = init_database(db_name, save_path) gen_caltech256_db(database, caltech256_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for class_name in caltech256_list: for img_name in caltech256_stats[class_name]: img_n, img_ex = os.path.splitext(img_name) if img_n not in database[class_name]: # find number of frames num_frames = fps metadata = {"num_frames": num_frames} record_path = os.path.join(caltech256_path, class_name, img_n + ".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(img_n, record_data, database, group_path=class_name, metadata=metadata) print "[MESSAGE] Sequence %s is saved" % img_n database.flush() database.close() print "[MESSAGE] Caltech-256 is saved to %s" % (save_path)
Email : [email protected] """ import scipy.signal as ss import matplotlib.pyplot as plt from spikefuel import dvsproc # file_path = "./data/v_Biking_g01_c03.aedat" # file_path_1 = "./data/vot_recordings_30fps/birds1.aedat" file_path_1 = "./data/flashing_moving_square_LCD_tests.aedat" file_path_2 = "./data/powerspectrum_test.aedat" # file_path = "./data/v_BaseballPitch_g01_c01.aedat" # video_path = "./data/v_Biking_g01_c03.avi" # video_path = "./data/v_BaseballPitch_g01_c01.avi" (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(file_path_1) print "[MESSAGE] DATA IS LOADED." event_arr = dvsproc.cal_event_count(timestamps) print "[MESSAGE] EVENT COUNT IS CALCULATED" event_freq = dvsproc.cal_event_freq(event_arr, cwindow=1000) print "[MESSAGE] EVENT FREQUENCY IS CALCULATED" f, pxx_den = ss.periodogram(event_freq[:, 1], 1000) print "[MESSAGE] POWERSPECTRUM DATA IS COMPUTED" plt.figure(0) plt.ylim([1e-4, 1e6]) plt.semilogy(f, pxx_den) plt.xlabel("Frequency [Hz]") plt.ylabel("PSD [V**2/Hz]") plt.title("Power Spectrum from Flashing Moving Square LCD Test") plt.savefig("./data/ps_vot_data.png")
def create_ucf50_db(db_name, save_path, ucf50_path, ucf50_stats, ucf50_data_path, device="DAViS240C", fps=30, monitor_id="SAMSUNG SyncMaster 2343BW", monitor_feq=60): """Create HDF5 database for UCF-50. Main function wrappers for UCF-50. Parameters ---------- db_name : string Database name save_path : string the destination of the database ucf50_path : string the destination of the ucf-50 record ucf50_stats : dictionary the dictionary that contains UCF-50's stats ucf50_data_path : string destination of UCF-50 dataset device : string DVS camera model, in default, it's DAViS240C fps : int Internal refreshing rate set by program, in default, it's 30Hz This factor will approximately determine how long the frame is gonna display monitor_id : string The model name of the monitor used, as default, it's SAMSUNG SyncMaster 2343BW monitor_feq : int Monitor display frequency, 60Hz as default return ------ database : h5py.File a HDF5 file object saved in the given destination """ # tracking statistics ucf50_list = ucf50_stats["ucf50_list"] database = init_database(db_name, save_path) gen_ucf50_db(database, ucf50_stats) # Set dataset metadata database.attrs["device"] = device database.attrs["fps"] = fps database.attrs["monitor_id"] = monitor_id database.attrs["monitor_feq"] = monitor_feq for category in ucf50_list: for vidn in ucf50_stats[category]: vid_n, vid_ex = os.path.splitext(vidn) if vid_n not in database[category]: # find number of frames vid_path = os.path.join(ucf50_data_path, category, vidn) num_frames = helpers.count_video_frames(vid_path) metadata = {"num_frames": num_frames} record_path = os.path.join(ucf50_path, category, vid_n + ".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) save_recording(vid_n, record_data, database, group_path=category, metadata=metadata) print "[MESSAGE] Sequence %s is saved" % vid_n database.flush() database.close() print "[MESSAGE] UCF-50 is saved to %s" % (save_path)
caltech256_list = caltech256_stats["caltech256_list"] # inite dataset dataset.create_caltech256_db(db_name, save_path, caltech256_path, caltech256_stats) db = h5py.File(os.path.join(save_path, db_name + ".hdf5"), mode="r") db.visit(printname) if option == "fix-error-recordings": database = h5py.File(db_path, mode="a") class_name = caltech256_list[62] img_name = caltech256_stats[class_name][63 - 1] img_n, img_ex = os.path.splitext(img_name) # find number of frames num_frames = 10 metadata = {"num_frames": num_frames} record_path = os.path.join(caltech256_path, class_name, img_n + ".aedat") print "[MESSAGE] Loading %s" % (record_path) record_data = dvsproc.loadaerdat(record_path) print record_data[0] dataset.save_recording(img_n, record_data, database, group_path=class_name, metadata=metadata, renew=True) print "[MESSAGE] Sequence %s is saved" % img_n
if pc != "Kalal": for sc in secondary_list[pc]: # load groundtruth gt_path = os.path.join(td_path, pc, sc, "groundtruth.txt") gt = np.loadtxt(gt_path, dtype=np.float32, delimiter=",") gt = helpers.trans_groundtruth(gt, method="size") gt = np.reshape(gt, (gt.shape[0], 4, 2)) # load one original frame frame_path = os.path.join(td_path, pc, sc, tracking_stats[sc][0]) origin_frame = cv2.imread(frame_path) # loading and process DVS recordings print "[MESSAGE] Loading sequence %s" % (sc) num_frames = len(tracking_stats[sc]) (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat( os.path.join(tracking_path, sc + ".aedat")) (timestamps, xaddr, yaddr, pol) = dvsproc.clean_up_events(timestamps, xaddr, yaddr, pol, window=1000) frames, _, ts = dvsproc.gen_dvs_frames(timestamps, xaddr, yaddr, pol, num_frames, fs=3) ts = np.array(ts) print "[MESSAGE] Number of frames (original): %i" % (num_frames)
temp_frame[:, :, 1] = frame temp_frame[:, :, 2] = frame rgb_frames.append(temp_frame) new_frames = gui.draw_poly_box_sequence(rgb_frames, gt, color=[0, 0, 255]) for i in xrange(len(new_frames)): img_name = join(seq_save_path, "%08d" % (i+1,)+".png") cv2.imwrite(img_name, new_frames[i]) print "Sequence %s is saved at %s" % (vidseq, seq_save_path) if option == "white-test": test_path = os.path.join(data_path, "test.aedat") (timestamps, xaddr, yaddr, pol) = dvsproc.loadaerdat(test_path) event_arr = dvsproc.cal_event_count(timestamps) event_freq = dvsproc.cal_event_freq(event_arr, window=1000) plt.figure(figsize=(18, 8)) plt.plot(event_freq[:, 0]/1e3, event_freq[:, 1], linewidth=2) plt.xlabel("Time (s)") plt.ylabel("Event Frequency") plt.savefig(os.path.join(data_path, "event_freq.pdf")) timestamps = timestamps-timestamps[0] timestamps = timestamps[:10000] tend = timestamps[-1] vv = np.zeros((tend+1,)) for i in xrange(timestamps.shape[0]):