def find_device_that_supports_advanced_mode() : ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices() for dev in devices: if dev.supports(rs.camera_info.product_id) and str(dev.get_info(rs.camera_info.product_id)) in ["0AD1", "0AD2", "0AD3", "0AD4", "0AD5", "0AF6", "0AFE", "0AFF", "0B00", "0B01", "0B03", "0B07"]: if dev.supports(rs.camera_info.name): print("Found device that supports advanced mode:", dev.get_info(rs.camera_info.name)) return dev raise Exception("No device that supports advanced mode was found")
def find_device_that_supports_advanced_mode() : ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices(); for dev in devices: if dev.supports(rs.camera_info.product_id) and str(dev.get_info(rs.camera_info.product_id)) in DS5_product_ids: if dev.supports(rs.camera_info.name): print("Found device that supports advanced mode:", dev.get_info(rs.camera_info.name)) return dev raise Exception("No device that supports advanced mode was found")
def main(): # Initialize the camera capture objects. # Get one output directory per view. rospy.init_node("data_collection", disable_signals=True) try: ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices() # device_ids = ['817612071456', '819112072363', '801212070655'] # Manuela's lab USB IDs device_ids = ['817612071456', '826212070528', '826212070219'] # device_indices = ['1', '2', '3'] device_indices = ['2'] collect_n_pictures_parallel(device_indices, args.num_pics) except KeyboardInterrupt: print("Make videos..") assert len(GLOBAL_DEPTH_BUFFER) == len(GLOBAL_IMAGE_BUFFER) view_dirs, vid_paths, debug_path, seqname, view_dirs_depth, depth_paths, debug_path_depth = setup_paths_w_depth( ) offsets = [] for view_idx, vid_path in enumerate(vid_paths): if not os.path.exists(vid_paths[view_idx].strip('.mp4')): os.makedirs(vid_paths[view_idx].strip('.mp4')) if not os.path.exists(depth_paths[view_idx].strip('.mp4')): os.makedirs(depth_paths[view_idx].strip('.mp4')) files = sorted(os.listdir(vid_path.strip('.mp4'))) offsets.append(int(len(files) / 2)) for t in range(0, len(GLOBAL_DEPTH_BUFFER)): stacked_images = GLOBAL_IMAGE_BUFFER[t][0][:, :, ::-1] for view_idx in range(len(device_indices)): cv2.imwrite( os.path.join(vid_paths[view_idx].strip('.mp4'), '{0:06d}.png'.format(t + offsets[view_idx])), GLOBAL_IMAGE_BUFFER[t][view_idx][:, :, ::-1]) cv2.imwrite( os.path.join(depth_paths[view_idx].strip('.mp4'), '{0:06d}.png'.format(t + offsets[view_idx])), GLOBAL_DEPTH_BUFFER[t][view_idx].astype(np.uint8)) np.save( os.path.join(vid_paths[view_idx].strip('.mp4'), '{0:06d}.npy'.format(t + offsets[view_idx])), GLOBAL_PIXEL_BUFFER[t][view_idx]) for p, q in zip(vid_paths, depth_paths): print('Writing final color picture to: %s' % p.strip('.mp4')) print('Writing final depth picture to: %s' % q.strip('.mp4')) try: sys.exit(0) except SystemExit: os._exit(0) # pylint: disable=protected-access
def main(): # Initialize the camera capture objects. # Get one output directory per view. rospy.init_node("data_collection", disable_signals=True) rospy.sleep(1) ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices() # device_ids = ['817612071456', '819112072363', '801212070655'] # Manuela's lab USB IDs device_ids = ['831612072676', '826212070528', '826212070219'] # device_indices = ['1', '2', '3'] for device in devices: print(device) device_indices = ['2'] # cross-check with IDs assigned in /home/zhouxian/ros_ws/src/realsense-2.1.0/realsense2_camera/launch/rs_multiple_devices.launch collect_n_pictures_parallel(device_indices) print("Save images to file..") assert len(GLOBAL_DEPTH_BUFFER) == len(GLOBAL_IMAGE_BUFFER) view_dirs, vid_paths, debug_path, seqname, view_dirs_depth, depth_paths, debug_path_depth = setup_paths_w_depth(args) offsets = [] if not os.path.exists(vid_paths[0].split('_view')[0]): os.makedirs(vid_paths[0].split('_view')[0]) if not os.path.exists(depth_paths[0].split('_view')[0]): os.makedirs(depth_paths[0].split('_view')[0]) for t in range(0, len(GLOBAL_DEPTH_BUFFER)): stacked_images = GLOBAL_IMAGE_BUFFER[t][0][:,:,::-1] for view_idx in range(len(device_indices)): object_name = vid_paths[view_idx].strip('.mp4').split('/')[-1].split('_view')[0] # if t == 0: # cv2.imwrite(os.path.join('/'.join(vid_paths[0].strip('.mp4').split('/')[:-2]), 'backgrounds', '{0}_{1:06d}_view{2}.png'.format(object_name, t, view_idx)), GLOBAL_IMAGE_BUFFER[t][view_idx][:,:,::-1]) cv2.imwrite(os.path.join(vid_paths[0].strip('.mp4').split('_view')[0], '{0}_{1:06d}_view{2}.png'.format(object_name, t, view_idx)), GLOBAL_IMAGE_BUFFER[t][view_idx][:,:,::-1]) cv2.imwrite(os.path.join(depth_paths[0].strip('.mp4').split('_view')[0], '{0}_{1:06d}_view{2}.png'.format(object_name, t, view_idx)), GLOBAL_DEPTH_BUFFER[t][view_idx].astype(np.uint8)) for p, q in zip(vid_paths, depth_paths): print('Writing final color picture to: %s' % p.strip('.mp4')) print('Writing final depth picture to: %s' % q.strip('.mp4')) try: sys.exit(0) except SystemExit: os._exit(0) # pylint: disable=protected-access
def find_device_that_supports_advanced_mode(): global device_id ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices() for dev in devices: if dev.supports(rs.camera_info.product_id) and str( dev.get_info(rs.camera_info.product_id)) in DS5_product_ids: name = rs.camera_info.name if dev.supports(name): if not camera_name or ( camera_name.lower() == dev.get_info(name).split()[2].lower()): progress( "INFO: Found device that supports advanced mode: %s" % dev.get_info(name)) device_id = dev.get_info(rs.camera_info.serial_number) return dev raise Exception("No device that supports advanced mode was found")
def main(): # Initialize the camera capture objects. # Get one output directory per view. rospy.init_node("data_collection", disable_signals=True) try: tf_listener = tf.TransformListener() ctx = rs.context() ds5_dev = rs.device() devices = ctx.query_devices() # device_ids = ['817612071456', '819112072363', '801212070655'] # Manuela's lab USB IDs device_ids = ['817612071456', '826212070528', '826212070219'] # device_indices = ['1', '2', '3'] #device_indices = ['1', '2'] device_indices = ['2'] collect_images_parallel(device_indices) except KeyboardInterrupt: print("Make videos..") assert len(GLOBAL_DEPTH_BUFFER) == len(GLOBAL_IMAGE_BUFFER) view_dirs, vid_paths, debug_path, seqname, view_dirs_depth, depth_paths, debug_path_depth = setup_paths_w_depth( ) # Save baxter joint values save_baxter_values(limb='right', seqname=seqname) for view_idx in range(len(device_indices)): save_tf_frame_values(view_idx, seqname, device_indices=device_indices, tf_listener=tf_listener) writers = [ imageio.get_writer(vidpath, fps=FPS) for vidpath in vid_paths ] writers_depth = [ imageio.get_writer(depthpath, fps=FPS) for depthpath in depth_paths ] writer_debug = imageio.get_writer(debug_path, fps=FPS) writers_depth_raw = [[]] * len(writers) for t in range(0, len(GLOBAL_DEPTH_BUFFER)): stacked_images = GLOBAL_IMAGE_BUFFER[t][0] for view_idx in range(len(device_indices)): writers[view_idx].append_data(GLOBAL_IMAGE_BUFFER[t][view_idx]) writers_depth[view_idx].append_data( GLOBAL_DEPTH_BUFFER[t][view_idx].astype(np.uint8)) writers_depth_raw[view_idx].append( GLOBAL_DEPTH_RAW_BUFFER[t][view_idx]) if view_idx > 0: stacked_images = np.concatenate( [stacked_images, GLOBAL_IMAGE_BUFFER[t][view_idx]], axis=1) writer_debug.append_data(stacked_images) for i, depthpath in enumerate(depth_paths): np.save(depthpath.split('.mp4')[0] + '.npy', writers_depth_raw[i]) for idx in range(len(writers)): writers[idx].close() writers_depth[idx].close() writer_debug.close() for p, q in zip(vid_paths, depth_paths): print('Writing final color video to: %s' % p) print('Writing final depth video to: %s' % q) if debug_path: print('Writing debug video to: %s' % debug_path) try: sys.exit(0) except SystemExit: os._exit(0) # pylint: disable=protected-access
def do_hardware_reset(self): rs.device(self.__serial_number).hardware_reset()
def find_device_json_input_interface(): ctx = rs.context() ds5_dev = rs.device() dev = ctx.query_devices() return dev