Example #1
0
    def bind(self, ret_form_id, bindings=None):
        self.CAMpayload = bindings[0]
        self.CAMwide = bindings[1]
        self.ret_form_id = ret_form_id
        self.info = []

        # Buttons
        self.butPayload = bs.add_button(self, self.CAMpayload.name,
                                        self.on_displayPayload)
        self.butWide = bs.add_button(self,
                                     self.CAMwide.name,
                                     self.on_displayWide,
                                     prevButton=self.butPayload)

        # Payload Camera Info
        self.camInfoPayload = bs.add_text_mult(self,
                                               "Camera Information",
                                               rows=8)
        self.on_displayPayload()

        # Py Capture version
        libVer = PyCapture2.getLibraryVersion()
        self.pyCaptureInfo = "PyCapture2 library version " + str(
            libVer[0]) + "." + str(libVer[1]) + "." + str(libVer[3])

        self.pyCaptureInfoDisp = bs.add_text(self,
                                             "Py Capture Information",
                                             value=self.pyCaptureInfo)
Example #2
0
    def __init__(self, serial_number):
        """Initialize FlyCapture2 API camera.
        
        Serial number should be of int type."""

        global PyCapture2
        import PyCapture2

        ver = PyCapture2.getLibraryVersion()
        min_ver = (2, 12, 3, 31)  # first release with python 3.6 support
        if ver < min_ver:
            raise RuntimeError(
                f"PyCapture2 version {ver} must be >= {min_ver}")

        bus = PyCapture2.BusManager()
        self.camera = PyCapture2.Camera()
        self.camera.connect(bus.getCameraFromSerialNumber(serial_number))

        config = self.camera.getConfiguration()
        config.grabTimeout = 1000  # in ms
        config.highPerformanceRetrieveBuffer = True
        self.camera.setConfiguration(config)
        # set which values of properties to return
        self.get_props = [
            'present', 'absControl', 'absValue', 'onOff', 'autoManualMode',
            'valueA', 'valueB'
        ]

        fmts = {
            prop: getattr(PyCapture2.PIXEL_FORMAT, prop)
            for prop in dir(PyCapture2.PIXEL_FORMAT)
            if not prop.startswith('_')
        }

        self.pixel_formats = IntEnum('pixel_formats', fmts)

        self._abort_acquisition = False
Example #3
0
def print_build_info():
    lib_ver = PyCapture2.getLibraryVersion()
    print 'PyCapture2 library version: %d %d %d %d' % (lib_ver[0], lib_ver[1],
                                                       lib_ver[2], lib_ver[3])
    print
    def __init__(self, serial_number):
        """Initialize FlyCapture2 API camera.
        
        Searches all cameras reachable by the host using the provided serial
        number. Fails with API error if camera not found.
        
        This function also does a significant amount of default configuration.
        
        * It defaults the grab timeout to 1 s
        * Ensures use of the API's HighPerformanceRetrieveBuffer
        * Ensures the camera is in Format 7, Mode 0 with full frame readout and MONO8 pixels
        * If using a GigE camera, automatically maximizes the packet size and warns if Jumbo packets are not enabled on the NIC
        
        Args:
            serial_number (int): serial number of camera to connect to
        """

        global PyCapture2
        import PyCapture2

        ver = PyCapture2.getLibraryVersion()
        min_ver = (2, 12, 3, 31)  # first release with python 3.6 support
        if ver < min_ver:
            raise RuntimeError(
                f"PyCapture2 version {ver} must be >= {min_ver}")

        print('Connecting to SN:%d ...' % serial_number)
        bus = PyCapture2.BusManager()
        self.camera = PyCapture2.Camera()
        self.camera.connect(bus.getCameraFromSerialNumber(serial_number))

        # set which values of properties to return
        self.get_props = [
            'present', 'absControl', 'absValue', 'onOff', 'autoManualMode',
            'valueA', 'valueB'
        ]

        fmts = {
            prop: getattr(PyCapture2.PIXEL_FORMAT, prop)
            for prop in dir(PyCapture2.PIXEL_FORMAT)
            if not prop.startswith('_')
        }

        self.pixel_formats = IntEnum('pixel_formats', fmts)

        self._abort_acquisition = False

        # check if GigE camera. If so, ensure max packet size is used
        cam_info = self.camera.getCameraInfo()
        if cam_info.interfaceType == PyCapture2.INTERFACE_TYPE.GIGE:
            # need to close generic camera first to avoid strange interactions
            print('Checking Packet size for GigE Camera...')
            self.camera.disconnect()
            gige_camera = PyCapture2.GigECamera()
            gige_camera.connect(bus.getCameraFromSerialNumber(serial_number))
            mtu = gige_camera.discoverGigEPacketSize()
            if mtu <= 1500:
                msg = """WARNING: Maximum Transmission Unit (MTU) for ethernet 
                NIC FlyCapture2_Camera SN:%d is connected to is only %d. 
                Reliable operation not expected. 
                Please enable Jumbo frames on NIC."""
                print(dedent(msg % (serial_number, mtu)))

            gige_pkt_size = gige_camera.getGigEProperty(
                PyCapture2.GIGE_PROPERTY_TYPE.GIGE_PACKET_SIZE)
            # only set if not already at correct value
            if gige_pkt_size.value != mtu:
                gige_pkt_size.value = mtu
                gige_camera.setGigEProperty(gige_pkt_size)
                print('  Packet size set to %d' % mtu)
            else:
                print('  GigE Packet size is %d' % gige_pkt_size.value)

            # close GigE handle to camera, re-open standard handle
            gige_camera.disconnect()
            self.camera.connect(bus.getCameraFromSerialNumber(serial_number))

        # set standard device configuration
        config = self.camera.getConfiguration()
        config.grabTimeout = 1000  # in ms
        config.highPerformanceRetrieveBuffer = True
        self.camera.setConfiguration(config)

        # ensure camera is in Format7,Mode 0 custom image mode
        fmt7_info, supported = self.camera.getFormat7Info(0)
        if supported:
            # to ensure Format7, must set custom image settings
            # defaults to full sensor size and 'MONO8' pixel format
            print('Initializing to default Format7, Mode 0 configuration...')
            fmt7_default = PyCapture2.Format7ImageSettings(
                0, 0, 0, fmt7_info.maxWidth, fmt7_info.maxHeight,
                self.pixel_formats['MONO8'].value)
            self._send_format7_config(fmt7_default)

        else:
            msg = """Camera does not support Format7, Mode 0 custom image
            configuration. This driver is therefore not compatible, as written."""
            raise RuntimeError(dedent(msg))
Example #5
0
def printBuildInfo():
    libVer = PyCapture2.getLibraryVersion()
    print("FlyCapture2 library version:", libVer[0], libVer[1], libVer[2],
          libVer[3])
Example #6
0
 def printBuildInfo(self):
     libVer = PyCapture2.getLibraryVersion()
     print "PyCapture2 library version: ", libVer[0], libVer[1], libVer[
         2], libVer[3]
     print
Example #7
0
 def print_build_info(self):
     libVer = PyCapture2.getLibraryVersion()
     print('FlyCapture2 library version: %d %d %d %d' %
           (libVer[0], libVer[1], libVer[2], libVer[3]))