Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import from builtins import range import os import cv2 # import numpy as np import h5py import matplotlib.pyplot as plt import spiker from spiker import log logger = log.get_logger("hdf5-test", log.INFO) hdf5_path = os.path.join( spiker.SPIKER_DATA, "rosbag", "test-walk_speed-monstruck_rec_2018-02-02-18-49-15-foyer-ccw.hdf5") dataset = h5py.File(hdf5_path, "r") pwm_data = dataset["/extra/pwm/pwm_data"][()] plt.figure() # steering data plt.plot(pwm_data[:, 0]) plt.show() for frame_id in range(dataset["extra/bind/bind_data"].shape[0]):
"""ResNets. With only TensorFlow backend. Follows fchollet's design Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import from builtins import range from spiker import log logger = log.get_logger("models-resnet", log.DEBUG) try: from keras.layers import Input from keras.layers import Dense from keras.layers import Conv2D from keras.layers import BatchNormalization from keras.layers import Activation from keras.layers import GlobalAveragePooling2D from keras.layers import add from keras.models import Model from keras.regularizers import l2 except ImportError: logger.critical("There is no keras available.") def resnet_block(input_tensor,
Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function from builtins import range import os import numpy as np import rosbag import h5py import spiker from spiker import log from spiker.data import rosbag as rb logger = log.get_logger("rosbag-test", log.INFO) bag_path = os.path.join( spiker.SPIKER_DATA, "rosbag", "test-walk_speed-monstruck_rec_2018-02-02-18-49-15-foyer-ccw.bag") hdf5_path = bag_path[:-4] + ".hdf5" bag = rosbag.Bag(bag_path, "r") bag_topics = rb.get_topics(bag) for key, value in bag_topics.iteritems(): logger.info("Topic: %s" % (key)) num_images = rb.get_msg_count(bag, "/dvs/image_raw") logger.info("Number of images: %d" % (num_images))
aps_head = 0 pwm_head = np.nonzero(pwm_time > aps_time[0])[0][0] if aps_time[-1] <= pwm_time[-1]: # pwm finish after aps_tail = aps_time.shape[0] pwm_tail = np.nonzero(pwm_time > aps_time[-1])[0][0] - 1 elif aps_time[-1] > pwm_time[-1]: # pwm finish before aps_tail = np.nonzero(aps_time > pwm_time[-1])[0][0] pwm_tail = pwm_time.shape[0] return aps_head, pwm_head, aps_tail, pwm_tail logger = log.get_logger("hdf5-exporter", log.INFO) dvs_bin_size = 100 # ms clip_value = 8 hdf5_path = os.path.join(spiker.SPIKER_DATA, "rosbag", "monstruck_rec_2018-01-19_indoor_cw_speeddrive.hdf5") # write to new file hdf5_path_new = hdf5_path[:-5] + "_exported.hdf5" dataset = h5py.File(hdf5_path, "r") # basic stats aps_time = dataset["aps/aps_ts"][()] print(aps_time[0]) print(aps_time[346])
"""Utility Function at Spiker Package Level. Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import import os from spiker import log logger = log.get_logger("utils", log.DEBUG) def makedir(path, log_msg=None, verbose=False): """Make directory. Parameters ---------- path : string the path of the directory. absolute path perferred. log_msg : str print log message if there is any. """ try: os.makedirs(path) logger.info(log_msg) except OSError: if verbose is True:
"""HDF5 related files. This file contains a set of functions that related to read and write HDF5 files. Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import import h5py from spiker import log logger = log.get_logger("data-hdf5", log.DEBUG) def init_hdf5(file_path, mode="w", cam_type="davis"): """Init HDF5 file object. # Parameters file_path : str absolute path for the HDF5 file. mode : str w : for writing r : for reading cam_type : str davis : for DAVIS camera dvs : for DVS camera # Returns
Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function, absolute_import import os import sys import yaml import spiker from spiker import log if os.name == 'posix' and sys.version_info[0] < 3: import subprocess32 as subprocess else: import subprocess logger = log.get_logger("rosbag-module", spiker.LOG_LEVEL) try: import rosbag from cv_bridge import CvBridge, CvBridgeError frame_bridge = CvBridge() except ImportError: logger.warning("You need to install ROS to enable this module.") def get_topics(bag, topic_filters=None): """Get the list of topics from a ROS bag. # Parameters bag: rosbag.Bag a target rosbag.
Author: Yuhuang Hu Email : [email protected] """ from __future__ import print_function from builtins import range import os import numpy as np import rosbag import cv2 import spiker from spiker import log from spiker.data import rosbag as rb logger = log.get_logger("rosbag-new-bind-test", log.INFO) bag_path = os.path.join(spiker.SPIKER_DATA, "rosbag", "monstruck_rec_2018-01-22-19-22-34.bag") bag = rosbag.Bag(bag_path, "r") bag_topics = rb.get_topics(bag) for key, value in bag_topics.iteritems(): logger.info("Topic: %s" % (key)) num_images = rb.get_msg_count(bag, "/dvs_bind") logger.info("Number of images: %d" % (num_images)) start_time = bag.get_start_time() # time in second logger.info("Start time: %f" % (start_time)) end_time = bag.get_end_time()