예제 #1
0
파일: pvcam.py 프로젝트: BoettigerLab/Hal2
    def __init__(self, camera_name = None, **kwds):
        super().__init__(**kwds)

        self.buffer_len = None
        self.data_buffer = None
        self.frame_bytes = None
        self.frame_x = None
        self.frame_y = None
        self.n_captured = pvc.uns32(0) # No more than 4 billion frames in a single capture..
        self.n_processed = 0

        # Open camera.
        c_name = ctypes.c_char_p(camera_name.encode())
        self.hcam = pvc.int16(0)
        check(pvcam.pl_cam_open(c_name,
                                ctypes.byref(self.hcam),
                                pvc.int16(0)),
              "pl_cam_open")

        # Register our EOF callback. This callback is supposed to increment
        # self.n_captured every time the camera acquires a new frame.
        #
        check(pvcam.pl_cam_register_callback_ex3(self.hcam,
                                                 pvc.int32(pvc.PL_CALLBACK_EOF),
                                                 eof_callback,
                                                 ctypes.byref(self.n_captured)),
              "pl_cam_register_callback_ex3")
예제 #2
0
파일: pvcam.py 프로젝트: BoettigerLab/Hal2
    def getParameterEnum(self, pname, pindex = None):
        """
        Returns value and description for an enumerated type.
        """
        pid = self.nameToID(pname)
        ptype = self.getParameterType(pid)
        pvalue = pvc.int32()

        # Verify that this is an enumerated type.
        if (ptype != pvc.TYPE_ENUM):
            raise PVCAMException("getParameterEnum: " + str(ptype) + " is not an enumerated type.")

        # Use current index if not specified.
        if pindex is None:
            cindex = pvc.uns32(pvc.ATTR_CURRENT)
        else:
            cindex = pvc.uns32(pindex)
            
        # Create string to store results.
        maxlen = 100
        cstring = ctypes.c_char_p((' ' * maxlen).encode())
        
        check(pvcam.pl_get_enum_param(self.hcam,
                                      pid,
                                      cindex,
                                      ctypes.byref(pvalue),
                                      cstring,
                                      pvc.uns32(maxlen)),
              "pl_get_enum_param")

        return [pvalue.value, cstring.value.decode()]
예제 #3
0
    def __init__(self, camera_name = None, **kwds):
        super().__init__(**kwds)

        self.buffer_len = None
        self.data_buffer = None
        self.frame_bytes = None
        self.frame_x = None
        self.frame_y = None
        self.n_captured = pvc.uns32(0) # No more than 4 billion frames in a single capture..
        self.n_processed = 0

        # Open camera.
        c_name = ctypes.c_char_p(camera_name.encode())
        self.hcam = pvc.int16(0)
        check(pvcam.pl_cam_open(c_name,
                                ctypes.byref(self.hcam),
                                pvc.int16(0)),
              "pl_cam_open")

        # Register our EOF callback. This callback is supposed to increment
        # self.n_captured every time the camera acquires a new frame.
        #
        check(pvcam.pl_cam_register_callback_ex3(self.hcam,
                                                 pvc.int32(pvc.PL_CALLBACK_EOF),
                                                 eof_callback,
                                                 ctypes.byref(self.n_captured)),
              "pl_cam_register_callback_ex3")
예제 #4
0
    def getParameterEnum(self, pname, pindex = None):
        """
        Returns value and description for an enumerated type.
        """
        pid = self.nameToID(pname)
        ptype = self.getParameterType(pid)
        pvalue = pvc.int32()

        # Verify that this is an enumerated type.
        if (ptype != pvc.TYPE_ENUM):
            raise PVCAMException("getParameterEnum: " + str(ptype) + " is not an enumerated type.")

        # Use current index if not specified.
        if pindex is None:
            cindex = pvc.uns32(pvc.ATTR_CURRENT)
        else:
            cindex = pvc.uns32(pindex)
            
        # Create string to store results.
        maxlen = 100
        cstring = ctypes.c_char_p((' ' * maxlen).encode())
        
        check(pvcam.pl_get_enum_param(self.hcam,
                                      pid,
                                      cindex,
                                      ctypes.byref(pvalue),
                                      cstring,
                                      pvc.uns32(maxlen)),
              "pl_get_enum_param")

        return [pvalue.value, cstring.value.decode()]
예제 #5
0
파일: pvcam.py 프로젝트: BoettigerLab/Hal2
 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()
예제 #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()
예제 #7
0
파일: pvcam.py 프로젝트: BoettigerLab/Hal2
 def shutdown(self):
     check(pvcam.pl_cam_deregister_callback(self.hcam,
                                            pvc.int32(pvc.PL_CALLBACK_EOF)),
           "pl_cam_deregister_callback")
     check(pvcam.pl_cam_close(self.hcam), "pl_cam_close")
예제 #8
0
 def shutdown(self):
     check(pvcam.pl_cam_deregister_callback(self.hcam,
                                            pvc.int32(pvc.PL_CALLBACK_EOF)),
           "pl_cam_deregister_callback")
     check(pvcam.pl_cam_close(self.hcam), "pl_cam_close")