@@ -40,6 +40,7 @@ def __init__(self, serial_number):
4040 if ver < min_ver :
4141 raise RuntimeError (f"PyCapture2 version { ver } must be >= { min_ver } " )
4242
43+ print ('Connecting to SN:%d ...' % serial_number )
4344 bus = PyCapture2 .BusManager ()
4445 self .camera = PyCapture2 .Camera ()
4546 self .camera .connect (bus .getCameraFromSerialNumber (serial_number ))
@@ -56,42 +57,49 @@ def __init__(self, serial_number):
5657 self .pixel_formats = IntEnum ('pixel_formats' ,fmts )
5758
5859 self ._abort_acquisition = False
59-
60- # set standard device configuration
61- config = self .camera .getConfiguration ()
62- config .grabTimeout = 1000 # in ms
63- config .highPerformanceRetrieveBuffer = True
64- self .camera .setConfiguration (config )
6560
6661 # check if GigE camera. If so, ensure max packet size is used
6762 cam_info = self .camera .getCameraInfo ()
6863 if cam_info .interfaceType == PyCapture2 .INTERFACE_TYPE .GIGE :
69- # open second GigE interface to camera with GigE config functions
64+ # need to close generic camera first to avoid strange interactions
65+ print ('Checking Packet size for GigE Camera...' )
66+ self .camera .disconnect ()
7067 gige_camera = PyCapture2 .GigECamera ()
7168 gige_camera .connect (bus .getCameraFromSerialNumber (serial_number ))
7269 mtu = gige_camera .discoverGigEPacketSize ()
7370 if mtu <= 1500 :
74- msg = """Maximum Transmission Unit (MTU) for ethernet NIC
75- FlyCapture2_Camera '%s' is connected to is only %d. Reliable
76- operation not expected. Please enable Jumbo frames on NIC."""
77- print (dedent (msg % (self .device_name ,mtu )))
71+ msg = """WARNING: Maximum Transmission Unit (MTU) for ethernet
72+ NIC FlyCapture2_Camera SN:%d is connected to is only %d.
73+ Reliable operation not expected.
74+ Please enable Jumbo frames on NIC."""
75+ print (dedent (msg % (serial_number ,mtu )))
7876
7977 gige_pkt_size = gige_camera .getGigEProperty (PyCapture2 .GIGE_PROPERTY_TYPE .GIGE_PACKET_SIZE )
8078 # only set if not already at correct value
8179 if gige_pkt_size .value != mtu :
8280 gige_pkt_size .value = mtu
83- gige_camera .setGigEProperty (PyCapture2 .GIGE_PROPERTY_TYPE .GIGE_PACKET_SIZE )
84- print ('Packet size set to %d' % mtu )
81+ gige_camera .setGigEProperty (gige_pkt_size )
82+ print (' Packet size set to %d' % mtu )
83+ else :
84+ print (' GigE Packet size is %d' % gige_pkt_size .value )
8585
86- # close second handle to camera
86+ # close GigE handle to camera, re-open standard handle
8787 gige_camera .disconnect ()
88+ self .camera .connect (bus .getCameraFromSerialNumber (serial_number ))
89+
90+ # set standard device configuration
91+ config = self .camera .getConfiguration ()
92+ config .grabTimeout = 1000 # in ms
93+ config .highPerformanceRetrieveBuffer = True
94+ self .camera .setConfiguration (config )
8895
8996 # ensure camera is in Format7,Mode 0 custom image mode
9097 fmt7_info , supported = self .camera .getFormat7Info (0 )
9198 if supported :
9299 # to ensure Format7, must set custom image settings
93100 # defaults to full sensor size and 'MONO8' pixel format
94- fmt7_default = PyCapture2 .Format7ImageSettings (0 ,0 ,0 ,fmt7_info .maxWidth ,fmt7_info .maxHeight ,self .pixel_formats ['MONO8' ])
101+ print ('Initializing to default Format7, Mode 0 configuration...' )
102+ fmt7_default = PyCapture2 .Format7ImageSettings (0 ,0 ,0 ,fmt7_info .maxWidth ,fmt7_info .maxHeight ,self .pixel_formats ['MONO8' ].value )
95103 self ._send_format7_config (fmt7_default )
96104
97105 else :
0 commit comments