def __init__(self, path_to_images, frame=None, loop=True):
        """Create a new virtualized Primesense sensor.

        This requires a directory containing a specific set of files.

        First, the directory must contain a set of images, where each
        image has three files:
        - color_{#}.png
        - depth_{#}.npy
        - ir_{#}.npy
        In these, the {#} is replaced with the integer index for the
        image. These indices should start at zero and increase
        consecutively.

        Second, the directory must contain CameraIntrisnics files
        for the color and ir cameras:
        - {frame}_color.intr
        - {frame}_ir.intr
        In these, the {frame} is replaced with the reference frame
        name that is passed as a parameter to this function.

        Parameters
        ----------
        path_to_images : :obj:`str`
            The path to a directory containing images that the virtualized
            sensor will return.
        frame : :obj:`str`
            The name of the frame of reference in which the sensor resides.
            If None, this will be discovered from the files in the directory.
        loop : :obj:`str`
            Whether or not to loop back to the first image after running out
        """
        self._running = False
        self._path_to_images = path_to_images
        self._im_index = 0
        self._num_images = 0
        self._frame = frame
        filenames = os.listdir(self._path_to_images)

        # get number of images
        for filename in filenames:
            if filename.find('depth') != -1 and filename.endswith('.npy'):
                self._num_images += 1

        # set the frame dynamically
        self._color_ext = '.png'
        for filename in filenames:
            file_root, file_ext = os.path.splitext(filename)
            color_ind = file_root.rfind('color')

            if file_ext in VirtualSensor.SUPPORTED_FILE_EXTS \
               and color_ind != -1:
                self._color_ext = file_ext

            if self._frame is None and file_ext == INTR_EXTENSION and color_ind != -1:
                self._frame = file_root[:color_ind-1]
                self._color_frame = file_root
                self._ir_frame = file_root

        # load color intrinsics
        color_intr_filename = os.path.join(self._path_to_images, '%s_color.intr' %(self._frame))
        ir_intr_filename = os.path.join(self._path_to_images, '%s_ir.intr' %(self._frame))
        generic_intr_filename = os.path.join(self._path_to_images, '%s.intr' %(self._frame))
        if os.path.exists(color_intr_filename):
            self._color_intr = CameraIntrinsics.load(color_intr_filename)
        else:
            self._color_intr = CameraIntrinsics.load(generic_intr_filename)
        if os.path.exists(ir_intr_filename):            
            self._ir_intr = CameraIntrinsics.load(ir_intr_filename)
        else:
            self._ir_intr = CameraIntrinsics.load(generic_intr_filename)
def __init__ ( self , path_to_images , frame = None , loop = True ) : self . _running = False self . _path_to_images = path_to_images self . _im_index = 0 self . _num_images = 0 self . _frame = frame filenames = os . listdir ( self . _path_to_images ) for filename in filenames : if filename . find ( 'depth' ) != - 1 and filename . endswith ( '.npy' ) : self . _num_images += 1 self . _color_ext = '.png' for filename in filenames : file_root , file_ext = os . path . splitext ( filename ) color_ind = file_root . rfind ( 'color' ) if file_ext in VirtualSensor . SUPPORTED_FILE_EXTS and color_ind != - 1 : self . _color_ext = file_ext if self . _frame is None and file_ext == INTR_EXTENSION and color_ind != - 1 : self . _frame = file_root [ : color_ind - 1 ] self . _color_frame = file_root self . _ir_frame = file_root color_intr_filename = os . path . join ( self . _path_to_images , '%s_color.intr' % ( self . _frame ) ) ir_intr_filename = os . path . join ( self . _path_to_images , '%s_ir.intr' % ( self . _frame ) ) generic_intr_filename = os . path . join ( self . _path_to_images , '%s.intr' % ( self . _frame ) ) if os . path . exists ( color_intr_filename ) : self . _color_intr = CameraIntrinsics . load ( color_intr_filename ) else : self . _color_intr = CameraIntrinsics . load ( generic_intr_filename ) if os . path . exists ( ir_intr_filename ) : self . _ir_intr = CameraIntrinsics . load ( ir_intr_filename ) else : self . _ir_intr = CameraIntrinsics . load ( generic_intr_filename )
Create a new virtualized Primesense sensor.

        This requires a directory containing a specific set of files.

        First, the directory must contain a set of images, where each
        image has three files:
        - color_{#}.png
        - depth_{#}.npy
        - ir_{#}.npy
        In these, the {#} is replaced with the integer index for the
        image. These indices should start at zero and increase
        consecutively.

        Second, the directory must contain CameraIntrisnics files
        for the color and ir cameras:
        - {frame}_color.intr
        - {frame}_ir.intr
        In these, the {frame} is replaced with the reference frame
        name that is passed as a parameter to this function.

        Parameters
        ----------
        path_to_images : :obj:`str`
            The path to a directory containing images that the virtualized
            sensor will return.
        frame : :obj:`str`
            The name of the frame of reference in which the sensor resides.
            If None, this will be discovered from the files in the directory.
        loop : :obj:`str`
            Whether or not to loop back to the first image after running out