def iterframes(self, *args, **kwargs): for (left, right), oxts, velodyne in izip( self.iter_stereo_frames(*args, **kwargs), self.iter_oxts_frames(*args, **kwargs), self.iter_velodyne_frames(*args, **kwargs)): yield AttrDict(left=left, right=right, velodyne=velodyne, pose=oxts.pose, oxts=oxts.packet)
def itervalues_for_keys(self, keys, inds=None, verbose=False): for key in keys: if key not in self.keys: raise RuntimeError( 'Key %s not found in dataset. keys: %s' % (key, self.keys)) items = (self.itervalues_for_key(key) for key in keys) return izip(*items)
def iterchunks_keys(self, keys, batch_size=10, verbose=False): """ Iterate in chunks and izip specific keys """ for key in keys: if key not in self.keys_: raise RuntimeError( 'Key %s not found in dataset. keys: %s' % (key, self.keys_)) iterables = [self.iterchunks( key, batch_size=batch_size, verbose=verbose) for key in keys] return izip(*iterables)
def iter_gt_frames(self, *args, **kwargs): """ Iterate over all the ground-truth data - For noc, occ disparity conversion, see devkit_stereo_flow/matlab/disp_read.m """ for (left, right), noc, occ, calib in izip( self.iter_stereo_frames(*args, **kwargs), self.noc.iteritems(*args, **kwargs), self.occ.iteritems(*args, **kwargs), self.calib.iteritems(*args, **kwargs)): yield AttrDict(left=left, right=right, depth=(occ/256).astype(np.float32), noc=(noc/256).astype(np.float32), occ=(occ/256).astype(np.float32), calib=calib, pose=None)
def iter_keys_values(self, keys, inds=None, verbose=False): for key in keys: if key not in self.keys_: raise RuntimeError( 'Key %s not found in dataset. keys: %s' % (key, self.keys_)) idx, ii = 0, 0 total_chunks = len(self.meta_file_.chunks) inds = np.sort(inds) if inds is not None else None for chunk_idx, chunk in enumerate(self.meta_file_.chunks): data = AttrDict.load(self.get_chunk_filename(chunk_idx)) # if inds is None: items = (data[key] for key in keys) for item in izip(*items): yield item
def iter_stereo_velodyne_frames(self, *args, **kwargs): return izip(self.left.iteritems(*args, **kwargs), self.right.iteritems(*args, **kwargs), self.velodyne.iteritems(*args, **kwargs))
def iterframes(self, *args, **kwargs): for (left, right), pose in izip( self.iter_stereo_frames(*args, **kwargs), self.poses.iteritems(*args, **kwargs)): yield AttrDict(left=left, right=right, velodyne=None, pose=pose)
def iteritems(self, *args, **kwargs): return izip(self.left.iteritems(*args, **kwargs), self.right.iteritems(*args, **kwargs))
def publish_point_type(pub_channel, _arr, c='r', point_type='POINT', flip_rb=False, frame_id='camera', element_id=0, reset=True): """ Publish point cloud on: pub_channel: Channel on which the cloud will be published arr: numpy array (N x 3) for point cloud data c: Option 1: 'c', 'b', 'r' etc colors accepted by matplotlibs color Option 2: float ranging from 0 to 1 via matplotlib's jet colormap Option 3: numpy array (N x 3) with r,g,b vals ranging from 0 to 1 s: supported only by matplotlib plotting alpha: supported only by matplotlib plotting Supports POINT=1, LINE_STRIP=2, LINE_LOOP=3, LINES=4, TRIANGLE_STRIP=5, TRIANGLE_FAN=6, TRIANGLES=7, QUAD_STRIP=8, QUADS=9, POLYGON=10 """ global g_viz_pub # point3d list collection msg pc_list_msg = vs.point3d_list_collection_t() pc_list_msg.id = g_viz_pub.channel_uid(pub_channel) pc_list_msg.name = pub_channel pc_list_msg.type = getattr(vs.point3d_list_collection_t, point_type) pc_list_msg.reset = reset # pc_list_msg.point_lists = [] # Create the point cloud msg if isinstance(_arr, list) or isinstance(_arr, deque): element_ids = element_id if isinstance(element_id, list) else [0] * len(_arr) # print 'Multiple elements: ', element_ids assert (len(c) == len(_arr)) for element_id, _arr_item, _carr_item in izip(element_ids, _arr, c): arr, carr = copy_pointcloud_data(_arr_item, _carr_item, flip_rb=flip_rb) pc_msg = arr_msg(arr, carr=carr, frame_uid=g_viz_pub.channel_uid(frame_id), element_id=element_id) pc_list_msg.point_lists.extend([pc_msg]) else: # print 'Single element: ', element_id arr, carr = copy_pointcloud_data(_arr, c, flip_rb=flip_rb) pc_msg = arr_msg(arr, carr=carr, frame_uid=g_viz_pub.channel_uid(frame_id), element_id=element_id) pc_list_msg.point_lists.extend([pc_msg]) # add to point cloud list # print('published %i lists %s' % (len(_arr), reset)) pc_list_msg.nlists = len(pc_list_msg.point_lists) g_viz_pub.publish("POINTS_COLLECTION", serialize(pc_list_msg))