Beispiel #1
0
    def captureSetup(self, x_start, x_end, x_bin, y_start, y_end, y_bin, exposure_time):
        """
        Configure for image capture (circular buffer).

        The camera is zero indexed.

        exposure_time is in milliseconds by default?

        How to determine the number of frames per second at a given exposure 
        time? HAL will need to know this in order to time other things properly.
        """        
        self.frame_x = int((x_end - x_start + 1)/x_bin)
        self.frame_y = int((y_end - y_start + 1)/y_bin)
        
        # Setup acquisition & determine how large a frame is (in pixels).
        frame_size = pvc.uns32(0)
        region = pvc.rgn_type(x_start, x_end, x_bin, y_start, y_end, y_bin)
        check(pvcam.pl_exp_setup_cont(self.hcam,
                                      pvc.uns16(1),
                                      ctypes.byref(region),
                                      pvc.int16(pvc.TIMED_MODE),
                                      pvc.uns32(exposure_time),
                                      ctypes.byref(frame_size),
                                      pvc.int16(pvc.CIRC_OVERWRITE)),
              "pl_exp_setup_cont")

        # Store frame size in bytes.
        #
        self.frame_bytes = frame_size.value

        # Allocate storage for the frames. Use PVCAM's recommendation for the size.
        #
        size = self.getParameterDefault("param_frame_buffer_size")
        self.data_buffer = numpy.ascontiguousarray(numpy.zeros(size, dtype = numpy.uint8))
        self.buffer_len = int(size/self.frame_bytes)
Beispiel #2
0
    def captureSetup(self, x_start, x_end, x_bin, y_start, y_end, y_bin, exposure_time):
        """
        Configure for image capture (circular buffer).

        The camera is zero indexed.

        exposure_time is in milliseconds by default?

        How to determine the number of frames per second at a given exposure 
        time? HAL will need to know this in order to time other things properly.
        """        
        self.frame_x = int((x_end - x_start + 1)/x_bin)
        self.frame_y = int((y_end - y_start + 1)/y_bin)
        
        # Setup acquisition & determine how large a frame is (in pixels).
        frame_size = pvc.uns32(0)
        region = pvc.rgn_type(x_start, x_end, x_bin, y_start, y_end, y_bin)
        check(pvcam.pl_exp_setup_cont(self.hcam,
                                      pvc.uns16(1),
                                      ctypes.byref(region),
                                      pvc.int16(pvc.TIMED_MODE),
                                      pvc.uns32(exposure_time),
                                      ctypes.byref(frame_size),
                                      pvc.int16(pvc.CIRC_OVERWRITE)),
              "pl_exp_setup_cont")

        # Store frame size in bytes.
        #
        self.frame_bytes = frame_size.value

        # Allocate storage for the frames. Use PVCAM's recommendation for the size.
        #
        size = self.getParameterDefault("param_frame_buffer_size")
        self.data_buffer = numpy.ascontiguousarray(numpy.zeros(size, dtype = numpy.uint8))
        self.buffer_len = int(size/self.frame_bytes)
Beispiel #3
0
    def getParam(self, pid, value, attrib):
        """
        Wrapper of pl_get_params, primarily for internal use.
        """

        # Overwrite whatever value is for some attributes.
        #
        if (attrib == pvc.ATTR_ACCESS):
            value = pvc.uns16()
        elif (attrib == pvc.ATTR_AVAIL):
            value = pvc.rs_bool()
        elif (attrib == pvc.ATTR_COUNT):
            value = pvc.uns32()
        elif (attrib == pvc.ATTR_TYPE):
            value = pvc.int16()

        check(
            pvcam.pl_get_param(self.hcam, pid, pvc.int16(attrib),
                               ctypes.byref(value)), "pl_get_param")
        return value.value
Beispiel #4
0
    def getParam(self, pid, value, attrib):
        """
        Wrapper of pl_get_params, primarily for internal use.
        """

        # Overwrite whatever value is for some attributes.
        #
        if (attrib == pvc.ATTR_ACCESS):
            value = pvc.uns16()
        elif (attrib == pvc.ATTR_AVAIL):
            value = pvc.rs_bool()
        elif (attrib == pvc.ATTR_COUNT):
            value = pvc.uns32()
        elif (attrib == pvc.ATTR_TYPE):
            value = pvc.int16()
            
        check(pvcam.pl_get_param(self.hcam,
                                 pid,
                                 pvc.int16(attrib),
                                 ctypes.byref(value)),
              "pl_get_param")
        return value.value
Beispiel #5
0
 def getTypeInstance(self, ptype):
     """
     Return a ctypes instance of ptype.
     """
     if (ptype == pvc.TYPE_INT16):
         return pvc.int16()
     elif (ptype == pvc.TYPE_INT32):
         return pvc.int32()
     elif (ptype == pvc.TYPE_FLT64):
         return pvc.flt64()
     elif (ptype == pvc.TYPE_UNS8):
         return pvc.uns8()
     elif (ptype == pvc.TYPE_UNS16):
         return pvc.uns16()
     elif (ptype == pvc.TYPE_UNS32):
         return pvc.uns32()
     elif (ptype == pvc.TYPE_UNS64):
         return pvc.ulong64()
     elif (ptype == pvc.TYPE_ENUM):
         return pvc.int32()
     elif (ptype == pvc.TYPE_BOOLEAN):
         return pvc.rs_bool()
     elif (ptype == pvc.TYPE_INT8):
         return pvc.int8()
Beispiel #6
0
 def getTypeInstance(self, ptype):
     """
     Return a ctypes instance of ptype.
     """
     if (ptype == pvc.TYPE_INT16):
         return pvc.int16()
     elif (ptype == pvc.TYPE_INT32):
         return pvc.int32()
     elif (ptype == pvc.TYPE_FLT64):
         return pvc.flt64()
     elif (ptype == pvc.TYPE_UNS8):
         return pvc.uns8()
     elif (ptype == pvc.TYPE_UNS16):
         return pvc.uns16()
     elif (ptype == pvc.TYPE_UNS32):
         return pvc.uns32()
     elif (ptype == pvc.TYPE_UNS64):
         return pvc.ulong64()
     elif (ptype == pvc.TYPE_ENUM):
         return pvc.int32()
     elif (ptype == pvc.TYPE_BOOLEAN):
         return pvc.rs_bool()
     elif (ptype == pvc.TYPE_INT8):
         return pvc.int8()