diff --git a/Andor/__init__.py b/Andor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv1/__init__.py b/Andor/andorv1/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv1/andor.egg-info/PKG-INFO b/Andor/andorv1/andor.egg-info/PKG-INFO deleted file mode 100644 index 39a60ec..0000000 --- a/Andor/andorv1/andor.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: andor -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/Andor/andorv1/andor.egg-info/SOURCES.txt b/Andor/andorv1/andor.egg-info/SOURCES.txt deleted file mode 100644 index ac44296..0000000 --- a/Andor/andorv1/andor.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -setup.py -andor/__init__.py -andor/aqctl_andor.py -andor/atmcd.py -andor/driver.py -andor.egg-info/PKG-INFO -andor.egg-info/SOURCES.txt -andor.egg-info/dependency_links.txt -andor.egg-info/entry_points.txt -andor.egg-info/top_level.txt \ No newline at end of file diff --git a/Andor/andorv1/andor.egg-info/dependency_links.txt b/Andor/andorv1/andor.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Andor/andorv1/andor.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Andor/andorv1/andor.egg-info/entry_points.txt b/Andor/andorv1/andor.egg-info/entry_points.txt deleted file mode 100644 index 2e14652..0000000 --- a/Andor/andorv1/andor.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_andor = andor.aqctl_andor:main - diff --git a/Andor/andorv1/andor.egg-info/top_level.txt b/Andor/andorv1/andor.egg-info/top_level.txt deleted file mode 100644 index fe88de4..0000000 --- a/Andor/andorv1/andor.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -andor diff --git a/Andor/andorv1/andor/__init__.py b/Andor/andorv1/andor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv1/andor/andor_driver.py b/Andor/andorv1/andor/andor_driver.py deleted file mode 100644 index 5d89af0..0000000 --- a/Andor/andorv1/andor/andor_driver.py +++ /dev/null @@ -1,136 +0,0 @@ -from atmcd import * - -class andor: - def __init__(self): - print("Intialising Camera") - self.cam = atmcd() #load the atmcd library - - (ret) = self.cam.Initialize("/usr/local/etc/andor") #initialise camera - print("Initialize returned",ret) - - if atmcd.DRV_SUCCESS==ret: - self.Initialize() - else: - print("Cannot continue, could not initialise camera") - - - - def Initialize(self): - - #(ret, totalCameras) = self.cam.GetAvailableCameras() - - (ret, iSerialNumber) = self.cam.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = self.cam.CoolerON() - print("Function CoolerON returned",ret) - #(ret) = self.cam.CoolerOFF() - #(ret, iCoolerStatus) = IsCoolerOn() - - - #(ret, temperature) = GetTemperature() - - #(ret, gain) = self.cam.SetEMCCDGain() - #(ret, low, high) = self.cam.GetEMGainRange() - - #(ret, noGains) = self.cam.GetNumberPreAmpGains() - #(ret, gain) = GetPreAmpGain(index) - #ret = SetPreAmpGain(index) - #ret = SetShutter(typ, mode, closingtime, openingtime) - - (ret) = self.cam.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - # Inputs: - # mode - the acquisition mode.: - # 1 - Single Scan - # 2 - Accumulate - # 3 - Kinetics - # 4 - Fast Kinetics - # 5 - Run till abort - - #ret = SetCameraLinkMode(mode) # 1 enables, 0 disables - - #ret = SetCropMode(active, cropHeight, reserved) - - #ret = SetFanMode(mode) - - # ret = SetCountConvertMode(Mode) - # Mode - : - # 0 - Data in Counts - # 1 - Data in Electrons - # 2 - Data in Photons - - #ret = SetHorizontalSpeed(index) - - - (ret) = self.cam.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = self.cam.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - #ret = SetFastExtTrigger(mode) - - (ret, xpixels, ypixels) = self.cam.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = self.cam.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - # Inputs: - # hbin - number of pixels to bin horizontally. - # vbin - number of pixels to bin vertically. - # hstart - Start column (inclusive). - # hend - End column (inclusive). - # vstart - Start row (inclusive). - # vend - End row (inclusive). - # ret = SetFullImage(hbin, vbin) - - #ret = SetImageRotate(iRotate) - #ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - #SetPhotonCounting(self, state): - - (ret) = self.cam.SetExposureTime(0.01) # seconds - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = self.cam.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - def PrepareAcquisition(self): - (ret) = self.cam.PrepareAcquisition() # reads current acquisition setup and allocates memory. Is called automatically by StartAcuiqision if not run, but can take a while. - print("Function PrepareAcquisition returned",ret) - - - def StartAcquisition(self): - #Run after PrepareAcquisition to start waiting for trigger. - (ret) = self.cam.StartAcquisition() - print("Function StartAcquisition returned",ret) - #GetStatus() - - def WaitForAcquisition(self): - - (ret) = self.cam.WaitForAcquisition() # calling thread is put to sleep until Acquisition Event occurs. - print("Function WaitForAcquisition returned",ret) - #ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - # def CancelWait(self): - # (ret) = self.cam.CancelWait() - # print("Cancel wait",ret) - - def GetImage(self): - (ret, xpixels, ypixels) = self.cam.GetDetector() - imageSize = xpixels*ypixels - print(xpixels) - print(ypixels) - (ret, fullFrameBuffer) = self.cam.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #(ret, arr, validfirst, validlast) = self.cam.GetImages(first, last, size) - #(ret, first, last) = self.cam.GetNumberNewImages() - #(ret, index) = GetTotalNumberImagesAcquired() - return fullFrameBuffer - - def ShutDown(self): - #Clean up - (ret) = self.cam.ShutDown() - print("Shutdown returned",ret) \ No newline at end of file diff --git a/Andor/andorv1/andor/aqctl_andor.py b/Andor/andorv1/andor/aqctl_andor.py deleted file mode 100644 index 4c3a96e..0000000 --- a/Andor/andorv1/andor/aqctl_andor.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from andor.driver import andor -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the andor camera") - common_args.simple_network_args(parser, 3210) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = andor(args.device if not args.simulation else None) - dev = andor() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("andor server startup on port",args.port,"successful...") - simple_server_loop( - {"andor": dev}, common_args.bind_address_from_args(args), args.port) - truthcounter=1 - finally: - print("Closing server...") - #dev.close() - -if __name__ == "__main__": - main() diff --git a/Andor/andorv1/andor/atmcd.py b/Andor/andorv1/andor/atmcd.py deleted file mode 100644 index 03a3281..0000000 --- a/Andor/andorv1/andor/atmcd.py +++ /dev/null @@ -1,12230 +0,0 @@ -from ctypes import * -import time -import platform -import sys - -MAX_PATH = 256 - -class ColorDemosaicInfo(Structure) : - _fields_ = [("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iXPhase", c_int), - ("iYPhase", c_int), - ("iBackground", c_int)] -class AndorCapabilities(Structure) : - _fields_ = [("ulSize", c_ulong), - ("ulAcqModes", c_ulong), - ("ulReadModes", c_ulong), - ("ulTriggerModes", c_ulong), - ("ulCameraType", c_ulong), - ("ulPixelMode", c_ulong), - ("ulSetFunctions", c_ulong), - ("ulGetFunctions", c_ulong), - ("ulFeatures", c_ulong), - ("ulPCICard", c_ulong), - ("ulEMGainCapability", c_ulong), - ("ulFTReadModes", c_ulong)] -class WhiteBalanceInfo(Structure) : - _fields_ = [("iSize", c_int), - ("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iROI_left", c_int), - ("iROI_right", c_int), - ("iROI_top", c_int), - ("iROI_bottom", c_int), - ("iOperation", c_int)] -class SYSTEMTIME(Structure) : - _fields_ = [("wYear", c_short), - ("wMonth", c_short), - ("wDayOfWeek", c_short), - ("wDay", c_short), - ("wHour", c_short), - ("wMinute", c_short), - ("wSecond", c_short), - ("wMilliseconds", c_short)] - -class atmcd: - def __init__(self): - if sys.platform == "linux2": - dllname = "/usr/local/lib/libandor.so" - self.dll = cdll.LoadLibrary(dllname) - elif sys.platform == "win32": - if platform.architecture()[0] == "64bit" : - dllname = "C:\\Program Files\\Andor SDK\\atmcd64d.dll" - else: - dllname = "C:\\Program Files\\Andor SDK\\atmcd32d.dll" - self.dll = windll.LoadLibrary(dllname) - else: - print("Cannot detect operating system, will now stop") - raise - - # Error Code Returns and Definitions - DRV_ERROR_CODES = 20001 - DRV_SUCCESS = 20002 - DRV_VXDNOTINSTALLED = 20003 - DRV_ERROR_SCAN = 20004 - DRV_ERROR_CHECK_SUM = 20005 - DRV_ERROR_FILELOAD = 20006 - DRV_UNKNOWN_FUNCTION = 20007 - DRV_ERROR_VXD_INIT = 20008 - DRV_ERROR_ADDRESS = 20009 - DRV_ERROR_PAGELOCK = 20010 - DRV_ERROR_PAGEUNLOCK = 20011 - DRV_ERROR_BOARDTEST = 20012 - DRV_ERROR_ACK = 20013 - DRV_ERROR_UP_FIFO = 20014 - DRV_ERROR_PATTERN = 20015 - DRV_ACQUISITION_ERRORS = 20017 - DRV_ACQ_BUFFER = 20018 - DRV_ACQ_DOWNFIFO_FULL = 20019 - DRV_PROC_UNKONWN_INSTRUCTION = 20020 - DRV_ILLEGAL_OP_CODE = 20021 - DRV_KINETIC_TIME_NOT_MET = 20022 - DRV_ACCUM_TIME_NOT_MET = 20023 - DRV_NO_NEW_DATA = 20024 - DRV_PCI_DMA_FAIL = 20025 - DRV_SPOOLERROR = 20026 - DRV_SPOOLSETUPERROR = 20027 - DRV_FILESIZELIMITERROR = 20028 - DRV_ERROR_FILESAVE = 20029 - DRV_TEMPERATURE_CODES = 20033 - DRV_TEMPERATURE_OFF = 20034 - DRV_TEMPERATURE_NOT_STABILIZED = 20035 - DRV_TEMPERATURE_STABILIZED = 20036 - DRV_TEMPERATURE_NOT_REACHED = 20037 - DRV_TEMPERATURE_OUT_RANGE = 20038 - DRV_TEMPERATURE_NOT_SUPPORTED = 20039 - DRV_TEMPERATURE_DRIFT = 20040 - DRV_TEMP_CODES = 20033 - DRV_TEMP_OFF = 20034 - DRV_TEMP_NOT_STABILIZED = 20035 - DRV_TEMP_STABILIZED = 20036 - DRV_TEMP_NOT_REACHED = 20037 - DRV_TEMP_OUT_RANGE = 20038 - DRV_TEMP_NOT_SUPPORTED = 20039 - DRV_TEMP_DRIFT = 20040 - DRV_GENERAL_ERRORS = 20049 - DRV_INVALID_AUX = 20050 - DRV_COF_NOTLOADED = 20051 - DRV_FPGAPROG = 20052 - DRV_FLEXERROR = 20053 - DRV_GPIBERROR = 20054 - DRV_EEPROMVERSIONERROR = 20055 - DRV_DATATYPE = 20064 - DRV_DRIVER_ERRORS = 20065 - DRV_P1INVALID = 20066 - DRV_P2INVALID = 20067 - DRV_P3INVALID = 20068 - DRV_P4INVALID = 20069 - DRV_INIERROR = 20070 - DRV_COFERROR = 20071 - DRV_ACQUIRING = 20072 - DRV_IDLE = 20073 - DRV_TEMPCYCLE = 20074 - DRV_NOT_INITIALIZED = 20075 - DRV_P5INVALID = 20076 - DRV_P6INVALID = 20077 - DRV_INVALID_MODE = 20078 - DRV_INVALID_FILTER = 20079 - DRV_I2CERRORS = 20080 - DRV_I2CDEVNOTFOUND = 20081 - DRV_I2CTIMEOUT = 20082 - DRV_P7INVALID = 20083 - DRV_P8INVALID = 20084 - DRV_P9INVALID = 20085 - DRV_P10INVALID = 20086 - DRV_P11INVALID = 20087 - DRV_USBERROR = 20089 - DRV_IOCERROR = 20090 - DRV_VRMVERSIONERROR = 20091 - DRV_GATESTEPERROR = 20092 - DRV_USB_INTERRUPT_ENDPOINT_ERROR = 20093 - DRV_RANDOM_TRACK_ERROR = 20094 - DRV_INVALID_TRIGGER_MODE = 20095 - DRV_LOAD_FIRMWARE_ERROR = 20096 - DRV_DIVIDE_BY_ZERO_ERROR = 20097 - DRV_INVALID_RINGEXPOSURES = 20098 - DRV_BINNING_ERROR = 20099 - DRV_INVALID_AMPLIFIER = 20100 - DRV_INVALID_COUNTCONVERT_MODE = 20101 - DRV_ERROR_NOCAMERA = 20990 - DRV_NOT_SUPPORTED = 20991 - DRV_NOT_AVAILABLE = 20992 - DRV_ERROR_MAP = 20115 - DRV_ERROR_UNMAP = 20116 - DRV_ERROR_MDL = 20117 - DRV_ERROR_UNMDL = 20118 - DRV_ERROR_BUFFSIZE = 20119 - DRV_ERROR_NOHANDLE = 20121 - DRV_GATING_NOT_AVAILABLE = 20130 - DRV_FPGA_VOLTAGE_ERROR = 20131 - DRV_OW_CMD_FAIL = 20150 - DRV_OWMEMORY_BAD_ADDR = 20151 - DRV_OWCMD_NOT_AVAILABLE = 20152 - DRV_OW_NO_SLAVES = 20153 - DRV_OW_NOT_INITIALIZED = 20154 - DRV_OW_ERROR_SLAVE_NUM = 20155 - DRV_MSTIMINGS_ERROR = 20156 - DRV_OA_NULL_ERROR = 20173 - DRV_OA_PARSE_DTD_ERROR = 20174 - DRV_OA_DTD_VALIDATE_ERROR = 20175 - DRV_OA_FILE_ACCESS_ERROR = 20176 - DRV_OA_FILE_DOES_NOT_EXIST = 20177 - DRV_OA_XML_INVALID_OR_NOT_FOUND_ERROR = 20178 - DRV_OA_PRESET_FILE_NOT_LOADED = 20179 - DRV_OA_USER_FILE_NOT_LOADED = 20180 - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED = 20181 - DRV_OA_INVALID_FILE = 20182 - DRV_OA_FILE_HAS_BEEN_MODIFIED = 20183 - DRV_OA_BUFFER_FULL = 20184 - DRV_OA_INVALID_STRING_LENGTH = 20185 - DRV_OA_INVALID_CHARS_IN_NAME = 20186 - DRV_OA_INVALID_NAMING = 20187 - DRV_OA_GET_CAMERA_ERROR = 20188 - DRV_OA_MODE_ALREADY_EXISTS = 20189 - DRV_OA_STRINGS_NOT_EQUAL = 20190 - DRV_OA_NO_USER_DATA = 20191 - DRV_OA_VALUE_NOT_SUPPORTED = 20192 - DRV_OA_MODE_DOES_NOT_EXIST = 20193 - DRV_OA_CAMERA_NOT_SUPPORTED = 20194 - DRV_OA_FAILED_TO_GET_MODE = 20195 - DRV_PROCESSING_FAILED = 20211 - AT_NoOfVersionInfoIds = 2 - AT_VERSION_INFO_LEN = 80 - AT_CONTROLLER_CARD_MODEL_LEN = 80 - AT_DDGLite_ControlBit_GlobalEnable = 0x01 - AT_DDGLite_ControlBit_ChannelEnable = 0x01 - AT_DDGLite_ControlBit_FreeRun = 0x02 - AT_DDGLite_ControlBit_DisableOnFrame = 0x04 - AT_DDGLite_ControlBit_RestartOnFire = 0x08 - AT_DDGLite_ControlBit_Invert = 0x10 - AT_DDGLite_ControlBit_EnableOnFire = 0x20 - AT_DDG_POLARITY_POSITIVE = 0 - AT_DDG_POLARITY_NEGATIVE = 1 - AT_DDG_TERMINATION_50OHMS = 0 - AT_DDG_TERMINATION_HIGHZ = 1 - AT_STEPMODE_CONSTANT = 0 - AT_STEPMODE_EXPONENTIAL = 1 - AT_STEPMODE_LOGARITHMIC = 2 - AT_STEPMODE_LINEAR = 3 - AT_STEPMODE_OFF = 100 - AT_GATEMODE_FIRE_AND_GATE = 0 - AT_GATEMODE_FIRE_ONLY = 1 - AT_GATEMODE_GATE_ONLY = 2 - AT_GATEMODE_CW_ON = 3 - AT_GATEMODE_CW_OFF = 4 - AT_GATEMODE_DDG = 5 - AC_ACQMODE_SINGLE = 1 - AC_ACQMODE_VIDEO = 2 - AC_ACQMODE_ACCUMULATE = 4 - AC_ACQMODE_KINETIC = 8 - AC_ACQMODE_FRAMETRANSFER = 16 - AC_ACQMODE_FASTKINETICS = 32 - AC_ACQMODE_OVERLAP = 64 - AC_READMODE_FULLIMAGE = 1 - AC_READMODE_SUBIMAGE = 2 - AC_READMODE_SINGLETRACK = 4 - AC_READMODE_FVB = 8 - AC_READMODE_MULTITRACK = 16 - AC_READMODE_RANDOMTRACK = 32 - AC_READMODE_MULTITRACKSCAN = 64 - AC_TRIGGERMODE_INTERNAL = 1 - AC_TRIGGERMODE_EXTERNAL = 2 - AC_TRIGGERMODE_EXTERNAL_FVB_EM = 4 - AC_TRIGGERMODE_CONTINUOUS = 8 - AC_TRIGGERMODE_EXTERNALSTART = 16 - AC_TRIGGERMODE_EXTERNALEXPOSURE = 32 - AC_TRIGGERMODE_INVERTED = 0x40 - AC_TRIGGERMODE_EXTERNAL_CHARGESHIFTING = 0x80 - AC_TRIGGERMODE_BULB = 32 - AC_CAMERATYPE_PDA = 0 - AC_CAMERATYPE_IXON = 1 - AC_CAMERATYPE_ICCD = 2 - AC_CAMERATYPE_EMCCD = 3 - AC_CAMERATYPE_CCD = 4 - AC_CAMERATYPE_ISTAR = 5 - AC_CAMERATYPE_VIDEO = 6 - AC_CAMERATYPE_IDUS = 7 - AC_CAMERATYPE_NEWTON = 8 - AC_CAMERATYPE_SURCAM = 9 - AC_CAMERATYPE_USBICCD = 10 - AC_CAMERATYPE_LUCA = 11 - AC_CAMERATYPE_RESERVED = 12 - AC_CAMERATYPE_IKON = 13 - AC_CAMERATYPE_INGAAS = 14 - AC_CAMERATYPE_IVAC = 15 - AC_CAMERATYPE_UNPROGRAMMED = 16 - AC_CAMERATYPE_CLARA = 17 - AC_CAMERATYPE_USBISTAR = 18 - AC_CAMERATYPE_SIMCAM = 19 - AC_CAMERATYPE_NEO = 20 - AC_CAMERATYPE_IXONULTRA = 21 - AC_CAMERATYPE_VOLMOS = 22 - AC_PIXELMODE_8BIT = 1 - AC_PIXELMODE_14BIT = 2 - AC_PIXELMODE_16BIT = 4 - AC_PIXELMODE_32BIT = 8 - AC_PIXELMODE_MONO = 0x000000 - AC_PIXELMODE_RGB = 0x010000 - AC_PIXELMODE_CMY = 0x020000 - AC_SETFUNCTION_VREADOUT = 0x01 - AC_SETFUNCTION_HREADOUT = 0x02 - AC_SETFUNCTION_TEMPERATURE = 0x04 - AC_SETFUNCTION_MCPGAIN = 0x08 - AC_SETFUNCTION_EMCCDGAIN = 0x10 - AC_SETFUNCTION_BASELINECLAMP = 0x20 - AC_SETFUNCTION_VSAMPLITUDE = 0x40 - AC_SETFUNCTION_HIGHCAPACITY = 0x80 - AC_SETFUNCTION_BASELINEOFFSET = 0x0100 - AC_SETFUNCTION_PREAMPGAIN = 0x0200 - AC_SETFUNCTION_CROPMODE = 0x0400 - AC_SETFUNCTION_DMAPARAMETERS = 0x0800 - AC_SETFUNCTION_HORIZONTALBIN = 0x1000 - AC_SETFUNCTION_MULTITRACKHRANGE = 0x2000 - AC_SETFUNCTION_RANDOMTRACKNOGAPS = 0x4000 - AC_SETFUNCTION_EMADVANCED = 0x8000 - AC_SETFUNCTION_GATEMODE = 0x010000 - AC_SETFUNCTION_DDGTIMES = 0x020000 - AC_SETFUNCTION_IOC = 0x040000 - AC_SETFUNCTION_INTELLIGATE = 0x080000 - AC_SETFUNCTION_INSERTION_DELAY = 0x100000 - AC_SETFUNCTION_GATESTEP = 0x200000 - AC_SETFUNCTION_GATEDELAYSTEP = 0x200000 - AC_SETFUNCTION_TRIGGERTERMINATION = 0x400000 - AC_SETFUNCTION_EXTENDEDNIR = 0x800000 - AC_SETFUNCTION_SPOOLTHREADCOUNT = 0x1000000 - AC_SETFUNCTION_REGISTERPACK = 0x2000000 - AC_SETFUNCTION_PRESCANS = 0x4000000 - AC_SETFUNCTION_GATEWIDTHSTEP = 0x8000000 - AC_SETFUNCTION_GAIN = 8 - AC_SETFUNCTION_ICCDGAIN = 8 - AC_GETFUNCTION_TEMPERATURE = 0x01 - AC_GETFUNCTION_TARGETTEMPERATURE = 0x02 - AC_GETFUNCTION_TEMPERATURERANGE = 0x04 - AC_GETFUNCTION_DETECTORSIZE = 0x08 - AC_GETFUNCTION_MCPGAIN = 0x10 - AC_GETFUNCTION_EMCCDGAIN = 0x20 - AC_GETFUNCTION_HVFLAG = 0x40 - AC_GETFUNCTION_GATEMODE = 0x80 - AC_GETFUNCTION_DDGTIMES = 0x0100 - AC_GETFUNCTION_IOC = 0x0200 - AC_GETFUNCTION_INTELLIGATE = 0x0400 - AC_GETFUNCTION_INSERTION_DELAY = 0x0800 - AC_GETFUNCTION_GATESTEP = 0x1000 - AC_GETFUNCTION_GATEDELAYSTEP = 0x1000 - AC_GETFUNCTION_PHOSPHORSTATUS = 0x2000 - AC_GETFUNCTION_MCPGAINTABLE = 0x4000 - AC_GETFUNCTION_BASELINECLAMP = 0x8000 - AC_GETFUNCTION_GATEWIDTHSTEP = 0x10000 - AC_GETFUNCTION_GAIN = 0x10 - AC_GETFUNCTION_ICCDGAIN = 0x10 - AC_FEATURES_POLLING = 1 - AC_FEATURES_EVENTS = 2 - AC_FEATURES_SPOOLING = 4 - AC_FEATURES_SHUTTER = 8 - AC_FEATURES_SHUTTEREX = 16 - AC_FEATURES_EXTERNAL_I2C = 32 - AC_FEATURES_SATURATIONEVENT = 64 - AC_FEATURES_FANCONTROL = 128 - AC_FEATURES_MIDFANCONTROL = 256 - AC_FEATURES_TEMPERATUREDURINGACQUISITION = 512 - AC_FEATURES_KEEPCLEANCONTROL = 1024 - AC_FEATURES_DDGLITE = 0x0800 - AC_FEATURES_FTEXTERNALEXPOSURE = 0x1000 - AC_FEATURES_KINETICEXTERNALEXPOSURE = 0x2000 - AC_FEATURES_DACCONTROL = 0x4000 - AC_FEATURES_METADATA = 0x8000 - AC_FEATURES_IOCONTROL = 0x10000 - AC_FEATURES_PHOTONCOUNTING = 0x20000 - AC_FEATURES_COUNTCONVERT = 0x40000 - AC_FEATURES_DUALMODE = 0x80000 - AC_FEATURES_OPTACQUIRE = 0x100000 - AC_FEATURES_REALTIMESPURIOUSNOISEFILTER = 0x200000 - AC_FEATURES_POSTPROCESSSPURIOUSNOISEFILTER = 0x400000 - AC_FEATURES_DUALPREAMPGAIN = 0x800000 - AC_FEATURES_DEFECT_CORRECTION = 0x1000000 - AC_FEATURES_STARTOFEXPOSURE_EVENT = 0x2000000 - AC_FEATURES_ENDOFEXPOSURE_EVENT = 0x4000000 - AC_FEATURES_CAMERALINK = 0x8000000 - AC_EMGAIN_8BIT = 1 - AC_EMGAIN_12BIT = 2 - AC_EMGAIN_LINEAR12 = 4 - AC_EMGAIN_REAL12 = 8 - def AbortAcquisition(self): - ''' - Description: - This function aborts the current acquisition if one is active. - - Synopsis: - ret = AbortAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition aborted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_IDLE - The system is not currently acquiring. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int AbortAcquisition(void); - - See Also: - GetStatus StartAcquisition - - ''' - ret = self.dll.AbortAcquisition() - return (ret) - - def CancelWait(self): - ''' - Description: - This function restarts a thread which is sleeping within the WaitForAcquisitionWaitForAcquisition function. The sleeping thread will return from WaitForAcquisition with a value not equal to DRV_SUCCESS. - - Synopsis: - ret = CancelWait() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread restarted successfully. - - C++ Equiv: - unsigned int CancelWait(void); - - See Also: - WaitForAcquisition - - ''' - ret = self.dll.CancelWait() - return (ret) - - def CoolerOFF(self): - ''' - Description: - Switches OFF the cooling. The rate of temperature change is controlled in some models until the temperature reaches 0C. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerOFF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched OFF. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support switching cooler off. - - C++ Equiv: - unsigned int CoolerOFF(void); - - See Also: - CoolerON SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: Not available on Luca R cameras - always cooled to -20C. - - NOTE: (Classic & ICCD only) 1. When the temperature control is switched off the temperature of the sensor is gradually raised to 0C to ensure no thermal stresses are set up in the sensor. 2. When closing down the program via ShutDown you must ensure that the temperature of the detector is above -20C, otherwise calling ShutDown while the detector is still cooled will cause the temperature to rise faster than certified. - - - ''' - ret = self.dll.CoolerOFF() - return (ret) - - def CoolerON(self): - ''' - Description: - Switches ON the cooling. On some systems the rate of temperature change is controlled until the temperature is within 3C of the set value. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerON() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched ON. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int CoolerON(void); - - See Also: - CoolerOFF SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: The temperature to which the detector will be cooled is set via SetTemperatureSetTemperature. The temperature stabilization is controlled via hardware, and the current temperature can be obtained via GetTemperatureGetTemperature. The temperature of the sensor is gradually brought to the desired temperature to ensure no thermal stresses are set up in the sensor. - - Can be called for certain systems during an acquisition. This can be tested for using GetCapabilities. - - - ''' - ret = self.dll.CoolerON() - return (ret) - - def DemosaicImage(self, grey, info): - ''' - Description: - For colour sensors only - Demosaics an image taken with a CYMG CCD into RGB using the parameters stored in info. Below is the ColorDemosaicInfo structure definition and a description of its members: - struct COLORDEMOSAICINFO { - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to demosaic image. - int iXPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iYPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iBackground; // Background to remove from raw data when demosaicing. - ColorDemosaicInfo; - * iX and iY are the image dimensions. The number of elements in the input red, green and blue arrays is iX x iY. - * iAlgorithm sets the algorithm to use: 0 for a 2x2 matrix demosaic algorithm or 1 for a 3x3 one. - The CYMG CCD pattern can be broken into cells of 2x4 pixels, e.g.: - * iXPhase and iYPhase store what colour is the bottom-left pixel. - * iBackground sets the numerical value to be removed from every pixel in the input image before demosaicing is done. - - Synopsis: - (ret, red, green, blue) = DemosaicImage(grey, info) - - Inputs: - grey - pointer to image to demosaic - info - pointer to demosaic information structure. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image demosaiced - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - One or more parameters in info is out of range - red - pointer to the red plane storage allocated by the user. - green - pointer to the green plane storage allocated by the user. - blue - pointer to the blue plane storage allocated by the user. - - C++ Equiv: - unsigned int DemosaicImage(WORD * grey, WORD * red, WORD * green, WORD * blue, ColorDemosaicInfo * info); - - See Also: - GetMostRecentColorImage16 WhiteBalance - - ''' - cgrey = (c_short * info.iX * info.iY)(grey) - cred = (c_short * info.iX * info.iY)() - cgreen = (c_short * info.iX * info.iY)() - cblue = (c_short * info.iX * info.iY)() - cinfo = ColorDemosaicInfo(info) - ret = self.dll.DemosaicImage(cgrey, cred, cgreen, cblue, byref(cinfo)) - return (ret, cred, cgreen, cblue) - - def EnableKeepCleans(self, mode): - ''' - Description: - This function is only available on certain cameras operating in FVB external trigger mode. It determines if the camera keep clean cycle will run between acquisitions. - When keep cleans are disabled in this way the exposure time is effectively the exposure time between triggers. - The Keep Clean cycle is enabled by default. - The feature capability AC_FEATURES_KEEPCLEANCONTROL determines if this function can be called for the camera. - - Synopsis: - ret = EnableKeepCleans(mode) - - Inputs: - mode - The keep clean mode.: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Keep clean cycle mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int EnableKeepCleans(int mode); - - See Also: - GetCapabilities - - Note: Currently only available on Newton and iKon cameras operating in FVB external trigger mode. - - ''' - cmode = c_int(mode) - ret = self.dll.EnableKeepCleans(cmode) - return (ret) - - def Filter_GetAveragingFactor(self): - ''' - Description: - Returns the current averaging factor value. - - Synopsis: - (ret, averagingFactor) = Filter_GetAveragingFactor() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid averagingFactor (i.e. NULL pointer). - averagingFactor - The current averaging factor value. - - C++ Equiv: - unsigned int Filter_GetAveragingFactor(int * averagingFactor); - - See Also: - Filter_SetAveragingFactor - - ''' - caveragingFactor = c_int() - ret = self.dll.Filter_GetAveragingFactor(byref(caveragingFactor)) - return (ret, caveragingFactor.value) - - def Filter_GetAveragingFrameCount(self): - ''' - Description: - Returns the current frame count value. - - Synopsis: - (ret, frames) = Filter_GetAveragingFrameCount() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count (i.e. NULL pointer). - frames - The current frame count value. - - C++ Equiv: - unsigned int Filter_GetAveragingFrameCount(int * frames); - - See Also: - Filter_SetAveragingFrameCount - - ''' - cframes = c_int() - ret = self.dll.Filter_GetAveragingFrameCount(byref(cframes)) - return (ret, cframes.value) - - def Filter_GetDataAveragingMode(self): - ''' - Description: - Returns the current averaging mode. - - Synopsis: - (ret, mode) = Filter_GetDataAveragingMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - mode - The current averaging mode. - - C++ Equiv: - unsigned int Filter_GetDataAveragingMode(int * mode); - - See Also: - Filter_SetDataAveragingMode - - ''' - cmode = c_int() - ret = self.dll.Filter_GetDataAveragingMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetMode(self): - ''' - Description: - Returns the current Noise Filter mode. - - Synopsis: - (ret, mode) = Filter_GetMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode (i.e. NULL pointer) - mode - Noise Filter mode. - - C++ Equiv: - unsigned int Filter_GetMode(unsigned int * mode); - - See Also: - Filter_SetMode - - ''' - cmode = c_uint() - ret = self.dll.Filter_GetMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetThreshold(self): - ''' - Description: - Returns the current Noise Filter threshold value. - - Synopsis: - (ret, threshold) = Filter_GetThreshold() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - threshold - The current threshold value. - - C++ Equiv: - unsigned int Filter_GetThreshold(float * threshold); - - See Also: - Filter_SetThreshold - - ''' - cthreshold = c_float() - ret = self.dll.Filter_GetThreshold(byref(cthreshold)) - return (ret, cthreshold.value) - - def Filter_SetAveragingFactor(self, averagingFactor): - ''' - Description: - Sets the averaging factor. - - Synopsis: - ret = Filter_SetAveragingFactor(averagingFactor) - - Inputs: - averagingFactor - The averaging factor to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging factor set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - - C++ Equiv: - unsigned int Filter_SetAveragingFactor(int averagingFactor); - - See Also: - Filter_GetAveragingFactor - - ''' - caveragingFactor = c_int(averagingFactor) - ret = self.dll.Filter_SetAveragingFactor(caveragingFactor) - return (ret) - - def Filter_SetAveragingFrameCount(self, frames): - ''' - Description: - Sets the averaging frame count. - - Synopsis: - ret = Filter_SetAveragingFrameCount(frames) - - Inputs: - frames - The averaging frame count to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging frame count set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count. - - C++ Equiv: - unsigned int Filter_SetAveragingFrameCount(int frames); - - See Also: - Filter_GetAveragingFrameCount - - ''' - cframes = c_int(frames) - ret = self.dll.Filter_SetAveragingFrameCount(cframes) - return (ret) - - def Filter_SetDataAveragingMode(self, mode): - ''' - Description: - Sets the current data averaging mode. - - Synopsis: - ret = Filter_SetDataAveragingMode(mode) - - Inputs: - mode - The averaging factor mode to use.: - 0 - No Averaging Filter - 5 - Recursive Averaging Filter - 6 - Frame Averaging Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetDataAveragingMode(int mode); - - See Also: - Filter_GetDataAveragingMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetDataAveragingMode(cmode) - return (ret) - - def Filter_SetMode(self, mode): - ''' - Description: - Set the Noise Filter to use. - - Synopsis: - ret = Filter_SetMode(mode) - - Inputs: - mode - Filter mode to use.: - 0 - No Filter - 1 - Median Filter - 2 - Level Above Filter - 3 - interquartile Range Filter - 4 - Noise Threshold Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetMode(int mode); - - See Also: - Filter_GetMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetMode(cmode) - return (ret) - - def Filter_SetThreshold(self, threshold): - ''' - Description: - Sets the threshold value for the Noise Filter. - - Synopsis: - ret = Filter_SetThreshold(threshold) - - Inputs: - threshold - Threshold value used to process image.: - 0 - 65535 for Level Above filter. - 0 - 10 for all other filters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold. - - C++ Equiv: - unsigned int Filter_SetThreshold(float threshold); - - See Also: - Filter_GetThreshold - - ''' - cthreshold = c_float(threshold) - ret = self.dll.Filter_SetThreshold(cthreshold) - return (ret) - - def FreeInternalMemory(self): - ''' - Description: - The FreeinternalMemory function will deallocate any memory used internally to store the previously acquired data. Note that once this function has been called, data from last acquisition cannot be retrieved. - - Synopsis: - ret = FreeInternalMemory() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Memory freed. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int FreeInternalMemory(void); - - See Also: - GetImages PrepareAcquisition - - ''' - ret = self.dll.FreeInternalMemory() - return (ret) - - def GetAcquiredData(self, size): - ''' - Description: - This function will return the data from the last acquisition. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData(at_32 * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData16 - - ''' - carr = c_int() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredData16(self, size): - ''' - Description: - 16-bit version of the GetAcquiredDataGetAcquiredData function. The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size isincorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData16(WORD * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData - - ''' - carr = c_short() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData16(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAcquiredFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAcquiredFloatData(float * arr, unsigned long size); - - ''' - carr = c_float() - csize = c_ulong(size) - ret = self.dll.GetAcquiredFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquisitionProgress(self): - ''' - Description: - This function will return information on the progress of the current acquisition. It can be called at any time but is best used in conjunction with SetDriverEventSetDriverEvent. - The values returned show the number of completed scans in the current acquisition. - If 0 is returned for both accum and series then either:- - * No acquisition is currently running - * The acquisition has just completed - * The very first scan of an acquisition has just started and not yet completed - GetStatus can be used to confirm if the first scan has just started, returning - DRV_ACQUIRING, otherwise it will return DRV_IDLE. - For example, if [i]accum[/i]=2 and [i]series[/i]=3 then the acquisition has completed 3 in the series and 2 accumulations in the 4 scan of the series. - - Synopsis: - (ret, acc, series) = GetAcquisitionProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of accumulation and series scans completed. - DRV_NOT_INITIALIZED - System not initialized. - acc - returns the number of accumulations completed in the current kinetic scan. - series - series the number of kinetic scans completed - - C++ Equiv: - unsigned int GetAcquisitionProgress(long * acc, long * series); - - See Also: - SetAcquisitionMode SetNumberAccumulations SetNumberKinetics SetDriverEvent - - ''' - cacc = c_int() - cseries = c_int() - ret = self.dll.GetAcquisitionProgress(byref(cacc), byref(cseries)) - return (ret, cacc.value, cseries.value) - - def GetAcquisitionTimings(self): - ''' - Description: - This function will return the current "valid" acquisition timing information. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The values returned are the actual times used in subsequent acquisitions. - This function is required as it is possible to set the exposure time to 20ms, accumulate cycle time to 30ms and then set the readout mode to full image. As it can take 250ms to read out an image it is not possible to have a cycle time of 30ms. - - Synopsis: - (ret, exposure, accumulate, kinetic) = GetAcquisitionTimings() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Acquisition or readout mode is not available. - exposure - valid exposure time in seconds - accumulate - valid accumulate cycle time in seconds - kinetic - valid kinetic cycle time in seconds - - C++ Equiv: - unsigned int GetAcquisitionTimings(float * exposure, float * accumulate, float * kinetic); - - See Also: - SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - cexposure = c_float() - caccumulate = c_float() - ckinetic = c_float() - ret = self.dll.GetAcquisitionTimings(byref(cexposure), byref(caccumulate), byref(ckinetic)) - return (ret, cexposure.value, caccumulate.value, ckinetic.value) - - def GetAdjustedRingExposureTimes(self, inumTimes): - ''' - Description: - This function will return the actual exposure times that the camera will use. There may be differences between requested exposures and the actual exposures. - - Synopsis: - (ret, fptimes) = GetAdjustedRingExposureTimes(inumTimes) - - Inputs: - inumTimes - inumTimesNumbers of times requested. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number of exposures requested - fptimes - fptimesPointer to an array large enough to hold _inumTimes floats. - - C++ Equiv: - unsigned int GetAdjustedRingExposureTimes(int inumTimes, float * fptimes); - - See Also: - GetNumberRingExposureTimes SetRingExposureTimes - - ''' - cinumTimes = c_int(inumTimes) - cfptimes = c_float() - ret = self.dll.GetAdjustedRingExposureTimes(cinumTimes, byref(cfptimes)) - return (ret, cfptimes.value) - - def GetAllDMAData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAllDMAData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAllDMAData(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetAllDMAData(byref(carr), csize) - return (ret, carr.value) - - def GetAmpDesc(self, index, length): - ''' - Description: - This function will return a string with an amplifier description. The amplifier is selected using the index. The SDK has a string associated with each of its amplifiers. The maximum number of characters needed to store the amplifier descriptions is 21. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetAmpDesc(index, length) - - Inputs: - index - The amplifier index. - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid. - DRV_P2INVALID - The desc pointer is null. - DRV_P3INVALID - The length parameter is invalid (less than 1) - name - A user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetAmpDesc(int index, char * name, int length); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetAmpDesc(cindex, cname, clength) - return (ret, cname) - - def GetAmpMaxSpeed(self, index): - ''' - Description: - This function will return the maximum available horizontal shift speed for the amplifier selected by the index parameter. - - Synopsis: - (ret, speed) = GetAmpMaxSpeed(index) - - Inputs: - index - amplifier index - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid - speed - horizontal shift speed - - C++ Equiv: - unsigned int GetAmpMaxSpeed(int index, float * speed); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetAmpMaxSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetAvailableCameras(self): - ''' - Description: - This function returns the total number of Andor cameras currently installed. It is possible to call this function before any of the cameras are initialized. - - Synopsis: - (ret, totalCameras) = GetAvailableCameras() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of available cameras returned. - DRV_GENERAL_ERRORS - An error occurred while obtaining the number of available cameras. - totalCameras - the number of cameras currently installed - - C++ Equiv: - unsigned int GetAvailableCameras(long * totalCameras); - - See Also: - SetCurrentCamera GetCurrentCamera GetCameraHandle - - ''' - ctotalCameras = c_int() - ret = self.dll.GetAvailableCameras(byref(ctotalCameras)) - return (ret, ctotalCameras.value) - - def GetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetBackground(byref(carr), csize) - return (ret, carr.value) - - def GetBaselineClamp(self): - ''' - Description: - This function returns the status of the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - (ret, state) = GetBaselineClamp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - state - Baseline clamp functionality Enabled/Disabled: - 1 - Baseline Clamp Enabled - 0 - Baseline Clamp Disabled - - C++ Equiv: - unsigned int GetBaselineClamp(int * state); - - See Also: - SetBaselineClamp SetBaselineOffset - - ''' - cstate = c_int() - ret = self.dll.GetBaselineClamp(byref(cstate)) - return (ret, cstate.value) - - def GetBitDepth(self, channel): - ''' - Description: - This function will retrieve the size in bits of the dynamic range for any available AD channel. - - Synopsis: - (ret, depth) = GetBitDepth(channel) - - Inputs: - channel - the AD channel. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Depth returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel - depth - dynamic range in bits - - C++ Equiv: - unsigned int GetBitDepth(int channel, int * depth); - - See Also: - GetNumberADChannels SetADChannel - - ''' - cchannel = c_int(channel) - cdepth = c_int() - ret = self.dll.GetBitDepth(cchannel, byref(cdepth)) - return (ret, cdepth.value) - - def GetCameraEventStatus(self): - ''' - Description: - This function will return if the system is exposing or not. - - Synopsis: - (ret, camStatus) = GetCameraEventStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - camStatus - The status of the firepulse will be returned that the firepulse is low: - 0 - Fire pulse low - 1 - Fire pulse high - - C++ Equiv: - unsigned int GetCameraEventStatus(DWORD * camStatus); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: This is only supported by the CCI23 card. - - ''' - ccamStatus = () - ret = self.dll.GetCameraEventStatus(byref(ccamStatus)) - return (ret, ccamStatus.value) - - def GetCameraHandle(self, cameraIndex): - ''' - Description: - This function returns the handle for the camera specified by cameraIndex. When multiple Andor cameras are installed the handle of each camera must be retrieved in order to select a camera using the SetCurrentCamera function. - The number of cameras can be obtained using the GetAvailableCameras function. - - Synopsis: - (ret, cameraHandle) = GetCameraHandle(cameraIndex) - - Inputs: - cameraIndex - index of any of the installed cameras. 0 to NumberCameras-1 where NumberCameras is the value returned by the GetAvailableCamerasGetAvailableCameras functionGetAvailableCamerasGetNumberVerticalSpeedsGetNumberHSSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - DRV_P1INVALID - Invalid camera index. - cameraHandle - handle of the camera. - - C++ Equiv: - unsigned int GetCameraHandle(long cameraIndex, long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCurrentCamera - - ''' - ccameraIndex = c_int(cameraIndex) - ccameraHandle = c_int() - ret = self.dll.GetCameraHandle(ccameraIndex, byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCameraInformation(self, index): - ''' - Description: - This function will return information on a particular camera denoted by the index. - - Synopsis: - (ret, information) = GetCameraInformation(index) - - Inputs: - index - (reserved) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Driver status return - DRV_VXDNOTINSTALLED - Driver not installed - DRV_USBERROR - USB device error - information - current state of camera: - Bit:1 - USB camera present - Bit:2 - All dlls loaded properly - Bit:3 - Camera Initialized correctly - - C++ Equiv: - unsigned int GetCameraInformation(int index, long * information); - - See Also: - GetCameraHandle GetHeadModel GetCameraSerialNumber GetCapabilities - - Note: Only available in iDus. The index parameter is not used at present so should be set to 0. For any camera except the iDus The value of information following a call to this function will be zero. - - ''' - cindex = c_int(index) - cinformation = c_int() - ret = self.dll.GetCameraInformation(cindex, byref(cinformation)) - return (ret, cinformation.value) - - def GetCameraSerialNumber(self): - ''' - Description: - This function will retrieve camera's serial number. - - Synopsis: - (ret, number) = GetCameraSerialNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Serial Number returned. - DRV_NOT_INITIALIZED - System not initialized. - number - Serial Number. - - C++ Equiv: - unsigned int GetCameraSerialNumber(int * number); - - See Also: - GetCameraHandle GetHeadModel GetCameraInformation GetCapabilities - - ''' - cnumber = c_int() - ret = self.dll.GetCameraSerialNumber(byref(cnumber)) - return (ret, cnumber.value) - - def GetCapabilities(self): - ''' - Description: - This function will fill in an AndorCapabilities structure with the capabilities associated with the connected camera. Before passing the address of an AndorCapabilites structure to the function the ulSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - caps->ulSize = sizeof(AndorCapabilities); - Individual capabilities are determined by examining certain bits and combinations of bits in the member variables of the AndorCapabilites structure. - - Synopsis: - (ret, caps) = GetCapabilities() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized - DRV_SUCCESS - Capabilities returned. - DRV_P1INVALID - Invalid caps parameter (i.e. NULL). - caps - the capabilities structure to be filled in. - - C++ Equiv: - unsigned int GetCapabilities(AndorCapabilities * caps); - - See Also: - GetCameraHandle GetCameraSerialNumber GetHeadModel GetCameraInformation - - ''' - caps = AndorCapabilities() - caps.ulSize = sizeof(caps) - ret = self.dll.GetCapabilities(byref(caps)) - return (ret, caps) - - def GetControllerCardModel(self): - ''' - Description: - This function will retrieve the type of PCI controller card included in your system. This function is not applicable for USB systems. The maximum number of characters that can be returned from this function is 10. - - Synopsis: - (ret, controllerCardModel) = GetControllerCardModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized - controllerCardModel - A user allocated array of characters for storage of the controller card model. - - C++ Equiv: - unsigned int GetControllerCardModel(char * controllerCardModel); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - ccontrollerCardModel = create_string_buffer(10) - ret = self.dll.GetControllerCardModel(ccontrollerCardModel) - return (ret, ccontrollerCardModel) - - def GetCountConvertWavelengthRange(self): - ''' - Description: - This function returns the valid wavelength range available in Count Convert mode. - - Synopsis: - (ret, minval, maxval) = GetCountConvertWavelengthRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - minval - minimum wavelength permited. - maxval - maximum wavelength permited. - - C++ Equiv: - unsigned int GetCountConvertWavelengthRange(float * minval, float * maxval); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cminval = c_float() - cmaxval = c_float() - ret = self.dll.GetCountConvertWavelengthRange(byref(cminval), byref(cmaxval)) - return (ret, cminval.value, cmaxval.value) - - def GetCurrentCamera(self): - ''' - Description: - When multiple Andor cameras are installed this function returns the handle of the currently selected one. - - Synopsis: - (ret, cameraHandle) = GetCurrentCamera() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - cameraHandle - handle of the currently selected camera - - C++ Equiv: - unsigned int GetCurrentCamera(long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int() - ret = self.dll.GetCurrentCamera(byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCYMGShift(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, iXshift, iYShift) = GetCYMGShift() - - Inputs: - None - - Outputs: - ret - Function Return Code - iXshift - - iYShift - - - C++ Equiv: - unsigned int GetCYMGShift(int * iXshift, int * iYShift); - - ''' - ciXshift = c_int() - ciYShift = c_int() - ret = self.dll.GetCYMGShift(byref(ciXshift), byref(ciYShift)) - return (ret, ciXshift.value, ciYShift.value) - - def GetDDGExternalOutputEnabled(self, uiIndex): - ''' - Description: - This function gets the current state of a selected external output. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputPolarity(self, uiIndex): - ''' - Description: - This function gets the current polarity of a selected external output. - - Synopsis: - (ret, puiPolarity) = GetDDGExternalOutputPolarity(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiPolarity - current polarity of external output (0 - Positive, 1 - Negative). - - C++ Equiv: - unsigned int GetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 * puiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputPolarity SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiPolarity = c_uint() - ret = self.dll.GetDDGExternalOutputPolarity(cuiIndex, byref(cpuiPolarity)) - return (ret, cpuiPolarity.value) - - def GetDDGExternalOutputStepEnabled(self, uiIndex): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to determine if this option is currently active. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputStepEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output track step (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputStepEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputStepEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputTime(self, uiIndex): - ''' - Description: - This function can be used to find the actual timings for a particular external output. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGExternalOutputTime(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Delay has invalid memory address. - puiDelay - actual external output delay time in picoseconds. - puiWidth - actual external output width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGExternalOutputTime(at_u32 uiIndex, at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputTime SetDDGGateStep - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGExternalOutputTime(cuiIndex, byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGGateTime(self): - ''' - Description: - This function can be used to get the actual gate timings for a USB iStar. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGGateTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Delay has invalid memory address. - puiDelay - gate delay time in picoseconds. - puiWidth - gate width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGGateTime(at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities SetDDGGateTimeSetDDGGateStep - - ''' - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGGateTime(byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGInsertionDelay(self): - ''' - Description: - This function gets the current state of the insertion delay. - - Synopsis: - (ret, piState) = GetDDGInsertionDelay() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Insertion delay state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Insertion delay not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the insertion delay option (0 - Normal, 1 - Ultra Fast). - - C++ Equiv: - unsigned int GetDDGInsertionDelay(int * piState); - - See Also: - GetCapabilities SetDDGInsertionDelay SetDDGIntelligate - - ''' - cpiState = c_int() - ret = self.dll.GetDDGInsertionDelay(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIntelligate(self): - ''' - Description: - This function gets the current state of intelligate. - - Synopsis: - (ret, piState) = GetDDGIntelligate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - intelligate not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the intelligate option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIntelligate(int * piState); - - See Also: - GetCapabilities SetDDGIntelligate SetDDGInsertionDelay - - ''' - cpiState = c_int() - ret = self.dll.GetDDGIntelligate(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIOC(self): - ''' - Description: - This function gets the current state of the integrate on chip (IOC) option. - - Synopsis: - (ret, state) = GetDDGIOC() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - state has invalid memory address. - state - current state of the IOC option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIOC(int * state); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency - - ''' - cstate = c_int() - ret = self.dll.GetDDGIOC(byref(cstate)) - return (ret, cstate.value) - - def GetDDGIOCFrequency(self): - ''' - Description: - This function can be used to return the actual IOC frequency that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, frequency) = GetDDGIOCFrequency() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - frequency - the frequency of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCFrequency(double * frequency); - - See Also: - GetCapabilities SetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cfrequency = c_double() - ret = self.dll.GetDDGIOCFrequency(byref(cfrequency)) - return (ret, cfrequency.value) - - def GetDDGIOCNumber(self): - ''' - Description: - This function can be used to return the actual number of pulses that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, numberPulses) = GetDDGIOCNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCNumber(unsigned long * numberPulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cnumberPulses = c_ulong() - ret = self.dll.GetDDGIOCNumber(byref(cnumberPulses)) - return (ret, cnumberPulses.value) - - def GetDDGIOCNumberRequested(self): - ''' - Description: - This function can be used to return the number of pulses that were requested by the user. - - Synopsis: - (ret, pulses) = GetDDGIOCNumberRequested() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - pulses has invalid memory address. - pulses - the number of integrate on chip pulses requested. - - C++ Equiv: - unsigned int GetDDGIOCNumberRequested(at_u32 * pulses); - - See Also: - GetCapabilities SetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_uint() - ret = self.dll.GetDDGIOCNumberRequested(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCPeriod(self): - ''' - Description: - This function can be used to return the actual IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, period) = GetDDGIOCPeriod() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - period has invalid memory address. - period - the period of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPeriod(at_u64 * period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCPeriod SetDDGIOCFrequency - - ''' - cperiod = c_ulonglong() - ret = self.dll.GetDDGIOCPeriod(byref(cperiod)) - return (ret, cperiod.value) - - def GetDDGIOCPulses(self): - ''' - Description: - This function can be used to calculate the number of pulses that will be triggered with the given exposure time, readout mode, acquisition mode and integrate on chip frequency. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, pulses) = GetDDGIOCPulses() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - pulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPulses(int * pulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_int() - ret = self.dll.GetDDGIOCPulses(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCTrigger(self): - ''' - Description: - function can be used to retrieve the active IOC trigger. - at_u32* trigger: active IOC trigger (0 - Fire pulse, 1 - External trigger). - at_u32 int - DRV_SUCCESS - DRV_NOT_INITIALIZED - DRV_NOT_SUPPORTED - DRV_ACQUIRING - DRV_ERROR_ACK - DRV_P1INVALID - IOC trigger returned. - System not initialized. - IOC not supported. - Acquisition in progress. - Unable to communicate with system. - Invalid trigger. - See also - GetCapabilities SetDDGIOC SetDDGIOCFrequency SetDDGIOCTrigger SetTriggerMode - GetDDGLiteControlByte - GetDDGLiteControlByte int WINAPI GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control) - Description - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, trigger) = GetDDGIOCTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code - trigger - - - C++ Equiv: - unsigned int GetDDGIOCTrigger(at_u32 * trigger); - - ''' - ctrigger = c_uint() - ret = self.dll.GetDDGIOCTrigger(byref(ctrigger)) - return (ret, ctrigger.value) - - def GetDDGLiteControlByte(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, control) = GetDDGLiteControlByte(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control); - - ''' - cchannel = (channel) - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteControlByte(cchannel, byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteGlobalControlByte(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, control) = GetDDGLiteGlobalControlByte() - - Inputs: - None - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteGlobalControlByte(unsigned char * control); - - ''' - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteGlobalControlByte(byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteInitialDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInitialDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInitialDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLiteInterPulseDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInterPulseDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInterPulseDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLitePulsesPerExposure(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, ui32Pulses) = GetDDGLitePulsesPerExposure(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - ui32Pulses - - - C++ Equiv: - unsigned int GetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 * ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint() - ret = self.dll.GetDDGLitePulsesPerExposure(cchannel, byref(cui32Pulses)) - return (ret, cui32Pulses.value) - - def GetDDGLitePulseWidth(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fWidth) = GetDDGLitePulseWidth(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fWidth - - - C++ Equiv: - unsigned int GetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float * fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float() - ret = self.dll.GetDDGLitePulseWidth(cchannel, byref(cfWidth)) - return (ret, cfWidth.value) - - def GetDDGOpticalWidthEnabled(self): - ''' - Description: - This function can be used to check whether optical gate widths are being used. - - Synopsis: - (ret, puiEnabled) = GetDDGOpticalWidthEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiEnabled - optical gate width option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGOpticalWidthEnabled(at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth - - ''' - cpuiEnabled = c_uint() - ret = self.dll.GetDDGOpticalWidthEnabled(byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGPulse(self, wid, resolution): - ''' - Description: - This function attempts to find a laser pulse in a user-defined region with a given resolution. The values returned will provide an estimation of the location of the pulse. - - Synopsis: - (ret, Delay, Width) = GetDDGPulse(wid, resolution) - - Inputs: - wid - the time in picoseconds of the region to be searched. - resolution - the minimum gate pulse used to locate the laser. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Location returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - Delay - the approximate start of the laser pulse. - Width - the pulse width, which encapsulated the laser pulse. - - C++ Equiv: - unsigned int GetDDGPulse(double wid, double resolution, double * Delay, double * Width); - - Note: Available in iStar. - - ''' - cwid = c_double(wid) - cresolution = c_double(resolution) - cDelay = c_double() - cWidth = c_double() - ret = self.dll.GetDDGPulse(cwid, cresolution, byref(cDelay), byref(cWidth)) - return (ret, cDelay.value, cWidth.value) - - def GetDDGStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate step mode. - - Synopsis: - (ret, p1, p2) = GetDDGStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - First coefficient - p2 - Second coefficient - - C++ Equiv: - unsigned int GetDDGStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGStepMode(self): - ''' - Description: - This function will return the current gate step mode. - - Synopsis: - (ret, mode) = GetDDGStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGStepMode(at_u32 * mode); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint() - ret = self.dll.GetDDGStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDDGTTLGateWidth(self, opticalWidth): - ''' - Description: - This function can be used to get the TTL gate width which corresponds to a particular optical gate width. - - Synopsis: - (ret, ttlWidth) = GetDDGTTLGateWidth(opticalWidth) - - Inputs: - opticalWidth - optical gate width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P2_INVALID - Unable to communicate with system. - ttlWidth - TTL gate width in picoseconds. - - C++ Equiv: - unsigned int GetDDGTTLGateWidth(at_u64 opticalWidth, at_u64 * ttlWidth); - - See Also: - GetCapabilities SetDDGOpticalWidthEnabled SetDDGGateStep - - ''' - copticalWidth = c_ulonglong(opticalWidth) - cttlWidth = c_ulonglong() - ret = self.dll.GetDDGTTLGateWidth(copticalWidth, byref(cttlWidth)) - return (ret, cttlWidth.value) - - def GetDDGWidthStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate width step mode. - - Synopsis: - (ret, p1, p2) = GetDDGWidthStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - The first coefficient. - p2 - The second coefficient. - - C++ Equiv: - unsigned int GetDDGWidthStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepMode - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGWidthStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGWidthStepMode(self): - ''' - Description: - This function will return the current gate width step mode. - - Synopsis: - (ret, mode) = GetDDGWidthStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGWidthStepMode(at_u32 * mode); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepCoefficients StartAcquisition - - ''' - cmode = c_uint() - ret = self.dll.GetDDGWidthStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDetector(self): - ''' - Description: - This function returns the size of the detector in pixels. The horizontal axis is taken to be the axis parallel to the readout register. - - Synopsis: - (ret, xpixels, ypixels) = GetDetector() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Detector size returned. - DRV_NOT_INITIALIZED - System not initialized. - xpixels - number of horizontal pixels. - ypixels - number of vertical pixels. - - C++ Equiv: - unsigned int GetDetector(int * xpixels, int * ypixels); - - ''' - cxpixels = c_int() - cypixels = c_int() - ret = self.dll.GetDetector(byref(cxpixels), byref(cypixels)) - return (ret, cxpixels.value, cypixels.value) - - def GetDICameraInfo(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, info) = GetDICameraInfo() - - Inputs: - None - - Outputs: - ret - Function Return Code - info - - - C++ Equiv: - unsigned int GetDICameraInfo(void * info); - - ''' - cinfo = c_void() - ret = self.dll.GetDICameraInfo(byref(cinfo)) - return (ret, cinfo.value) - - def GetDualExposureTimes(self): - ''' - Description: - This function will return the current valid acquisition timing information for dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - (ret, exposure1, exposure2) = GetDualExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. . - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_NOT_AVAILABLE - Dual exposure mode not configured correctly. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - exposure1 has invalid memory address. - DRV_P2INVALID - exposure2 has invalid memory address. - exposure1 - valid exposure time in seconds for each odd numbered frame. - exposure2 - valid exposure time in seconds for each even numbered frame. - - C++ Equiv: - unsigned int GetDualExposureTimes(float * exposure1, float * exposure2); - - See Also: - GetCapabilities SetDualExposureMode SetDualExposureTimes - - ''' - cexposure1 = c_float() - cexposure2 = c_float() - ret = self.dll.GetDualExposureTimes(byref(cexposure1), byref(cexposure2)) - return (ret, cexposure1.value, cexposure2.value) - - def GetEMAdvanced(self): - ''' - Description: - Returns the current Advanced gain setting. - - Synopsis: - (ret, state) = GetEMAdvanced() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Advanced state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - state has invalid memory address. - state - current EM advanced gain setting - - C++ Equiv: - unsigned int GetEMAdvanced(int * state); - - ''' - cstate = c_int() - ret = self.dll.GetEMAdvanced(byref(cstate)) - return (ret, cstate.value) - - def GetEMCCDGain(self): - ''' - Description: - Returns the current gain setting. The meaning of the value returned depends on the EM Gain mode. - - Synopsis: - (ret, gain) = GetEMCCDGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - gain - current EM gain setting - - C++ Equiv: - unsigned int GetEMCCDGain(int * gain); - - ''' - cgain = c_int() - ret = self.dll.GetEMCCDGain(byref(cgain)) - return (ret, cgain.value) - - def GetEMGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the current selected EM Gain mode and temperature of the sensor. - - Synopsis: - (ret, low, high) = GetEMGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - low - lowest gain setting - high - highest gain setting - - C++ Equiv: - unsigned int GetEMGainRange(int * low, int * high); - - ''' - clow = c_int() - chigh = c_int() - ret = self.dll.GetEMGainRange(byref(clow), byref(chigh)) - return (ret, clow.value, chigh.value) - - def GetExternalTriggerTermination(self): - ''' - Description: - This function can be used to get the current external trigger termination mode. - - Synopsis: - (ret, puiTermination) = GetExternalTriggerTermination() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - C++ Equiv: - unsigned int GetExternalTriggerTermination(at_u32 * puiTermination); - - See Also: - GetCapabilities SetExternalTriggerTermination - - ''' - cpuiTermination = c_uint() - ret = self.dll.GetExternalTriggerTermination(byref(cpuiTermination)) - return (ret, cpuiTermination.value) - - def GetFastestRecommendedVSSpeed(self): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the fastest recommended speed available. The very high readout speeds, may require an increase in the amplitude of the Vertical Clock Voltage using SetVSAmplitudeSetVSAmplitude. This function returns the fastest speed which does not require the Vertical Clock Voltage to be adjusted. The values returned are the vertical shift speed index and the actual speed in microseconds per pixel shift. - - Synopsis: - (ret, index, speed) = GetFastestRecommendedVSSpeed() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - index - index of the fastest recommended vertical shift speed - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetFastestRecommendedVSSpeed(int * index, float * speed); - - See Also: - GetVSSpeed GetNumberVSSpeeds SetVSSpeed - - ''' - cindex = c_int() - cspeed = c_float() - ret = self.dll.GetFastestRecommendedVSSpeed(byref(cindex), byref(cspeed)) - return (ret, cindex.value, cspeed.value) - - def GetFIFOUsage(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, FIFOusage) = GetFIFOUsage() - - Inputs: - None - - Outputs: - ret - Function Return Code - FIFOusage - - - C++ Equiv: - unsigned int GetFIFOUsage(int * FIFOusage); - - ''' - cFIFOusage = c_int() - ret = self.dll.GetFIFOUsage(byref(cFIFOusage)) - return (ret, cFIFOusage.value) - - def GetFilterMode(self): - ''' - Description: - This function returns the current state of the cosmic ray filtering mode. - - Synopsis: - (ret, mode) = GetFilterMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mode - current state of filter: - 0 - OFF - 2 - ON - - C++ Equiv: - unsigned int GetFilterMode(int * mode); - - See Also: - SetFilterMode - - ''' - cmode = c_int() - ret = self.dll.GetFilterMode(byref(cmode)) - return (ret, cmode.value) - - def GetFKExposureTime(self): - ''' - Description: - This function will return the current "valid" exposure time for a fast kinetics acquisition. This function should be used after all the acquisitions settings have been set, i.e. SetFastKineticsSetFastKinetics and SetFKVShiftSpeedSetFKVShiftSpeed. The value returned is the actual time used in subsequent acquisitions. - - Synopsis: - (ret, time) = GetFKExposureTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Fast kinetics is not available. - time - valid exposure time in seconds - - C++ Equiv: - unsigned int GetFKExposureTime(float * time); - - See Also: - SetFastKinetics SetFKVShiftSpeed - - ''' - ctime = c_float() - ret = self.dll.GetFKExposureTime(byref(ctime)) - return (ret, ctime.value) - - def GetFKVShiftSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Deprecated by GetFKVShiftSpeedFGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetFKVShiftSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFKVShiftSpeedF(self, index): - ''' - Description: - As your Andor system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeedF(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeedF(int index, float * speed); - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetFKVShiftSpeedF(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFrontEndStatus(self): - ''' - Description: - This function will return if the Front End cooler has overheated. - - Synopsis: - (ret, piFlag) = GetFrontEndStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Front End cooler not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the front end cooler: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetFrontEndStatus(int * piFlag); - - See Also: - SetFrontEndEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetFrontEndStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetGateMode(self): - ''' - Description: - Allows the user to get the current photocathode gating mode. - - Synopsis: - (ret, piGatemode) = GetGateMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - gatemode has invalid memory address. - piGatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - C++ Equiv: - unsigned int GetGateMode(int * piGatemode); - - See Also: - GetCapabilities SetGateMode - - ''' - cpiGatemode = c_int() - ret = self.dll.GetGateMode(byref(cpiGatemode)) - return (ret, cpiGatemode.value) - - def GetHardwareVersion(self): - ''' - Description: - This function returns the Hardware version information. - - Synopsis: - (ret, PCB, Decode, dummy1, dummy2, CameraFirmwareVersion, CameraFirmwareBuild) = GetHardwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - PCB - Plug-in card version - Decode - Flex 10K file version - dummy1 - - dummy2 - - CameraFirmwareVersion - Version number of camera firmware - CameraFirmwareBuild - Build number of camera firmware - - C++ Equiv: - unsigned int GetHardwareVersion(unsigned int * PCB, unsigned int * Decode, unsigned int * dummy1, unsigned int * dummy2, unsigned int * CameraFirmwareVersion, unsigned int * CameraFirmwareBuild); - - ''' - cPCB = c_uint() - cDecode = c_uint() - cdummy1 = c_uint() - cdummy2 = c_uint() - cCameraFirmwareVersion = c_uint() - cCameraFirmwareBuild = c_uint() - ret = self.dll.GetHardwareVersion(byref(cPCB), byref(cDecode), byref(cdummy1), byref(cdummy2), byref(cCameraFirmwareVersion), byref(cCameraFirmwareBuild)) - return (ret, cPCB.value, cDecode.value, cdummy1.value, cdummy2.value, cCameraFirmwareVersion.value, cCameraFirmwareBuild.value) - - def GetHeadModel(self): - ''' - Description: - This function will retrieve the type of CCD attached to your system. - - Synopsis: - (ret, name) = GetHeadModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized. - name - A user allocated array of characters for storage of the Head Model. This should be declared as size MAX_PATH. - - C++ Equiv: - unsigned int GetHeadModel(char * name); - - ''' - cname = create_string_buffer(MAX_PATH) - ret = self.dll.GetHeadModel(cname) - return (ret, cname.value) - - def GetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetHorizontalSpeed(index) - - Inputs: - index - speed required, 0 to NumberSpeeds-1, where NumberSpeeds is the parameter returned by GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetHorizontalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberHorizontalSpeeds SetHorizontalSpeed - - Note: Deprecated by GetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetHorizontalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHSSpeed(self, channel, typ, index): - ''' - Description: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in MHz. - - Synopsis: - (ret, speed) = GetHSSpeed(channel, typ, index) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR Mode(clara). - index - speed required Valid values: 0 to NumberSpeeds-1, where NumberSpeeds is value returned in first parameter after a call to GetNumberHSSpeedsGetNumberHSSpeeds(). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - DRV_P3INVALID - Invalid index - speed - speed in in MHz. - - C++ Equiv: - unsigned int GetHSSpeed(int channel, int typ, int index, float * speed); - - See Also: - GetNumberHSSpeeds SetHSSpeed - - Note: The speed is returned in microseconds per pixel shift for iStar and Classic systems. - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetHSSpeed(cchannel, ctyp, cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHVflag(self): - ''' - Description: - This function will retrieve the High Voltage flag from your USB iStar intensifier. A 0 value indicates that the high voltage is abnormal. - - Synopsis: - (ret, bFlag) = GetHVflag() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - HV flag returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - bFlag - pointer to High Voltage flag. - - C++ Equiv: - unsigned int GetHVflag(int * bFlag); - - Note: Available only on USB iStar. - - ''' - cbFlag = c_int() - ret = self.dll.GetHVflag(byref(cbFlag)) - return (ret, cbFlag.value) - - def GetID(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, id) = GetID(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - id - - - C++ Equiv: - unsigned int GetID(int devNum, int * id); - - ''' - cdevNum = c_int(devNum) - cid = c_int() - ret = self.dll.GetID(cdevNum, byref(cid)) - return (ret, cid.value) - - def GetImageFlip(self): - ''' - Description: - This function will obtain whether the acquired data output is flipped in either the horizontal or vertical direction. - - Synopsis: - (ret, iHFlip, iVFlip) = GetImageFlip() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - iHFlip - Gets horizontal flipping. - iVFlip - Gets vertical flipping.: - 1 - Flipping Enabled - 0 - Flipping Disabled - - C++ Equiv: - unsigned int GetImageFlip(int * iHFlip, int * iVFlip); - - See Also: - SetImageRotate SetImageFlip - - ''' - ciHFlip = c_int() - ciVFlip = c_int() - ret = self.dll.GetImageFlip(byref(ciHFlip), byref(ciVFlip)) - return (ret, ciHFlip.value, ciVFlip.value) - - def GetImageRotate(self): - ''' - Description: - This function will obtain whether the acquired data output is rotated in any direction. - - Synopsis: - (ret, iRotate) = GetImageRotate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - iRotate - Rotation setting: - 0 - - No rotation - 1 - - Rotate 90 degrees clockwise - 2 - - Rotate 90 degrees anti-clockwise - - C++ Equiv: - unsigned int GetImageRotate(int * iRotate); - - See Also: - SetImageFlip SetImageRotate SetReadMode - - ''' - ciRotate = c_int() - ret = self.dll.GetImageRotate(byref(ciRotate)) - return (ret, ciRotate.value) - - def GetImages(self, first, last, size): - ''' - Description: - This function will update the data array with the specified series of images from the circular buffer. If the specified series is out of range (i.e. the images have been overwritten or have not yet been acquired then an error will be returned. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages(long first, long last, at_32 * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages16 GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_int * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImages16(self, first, last, size): - ''' - Description: - 16-bit version of the GetImagesGetImages function. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages16(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages16(long first, long last, WORD * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_short * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages16(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImagesPerDMA(self): - ''' - Description: - This function will return the maximum number of images that can be transferred during a single DMA transaction. - - Synopsis: - (ret, images) = GetImagesPerDMA() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of images per DMA returned. - images - The maximum number of images that can be transferred during a single DMA transaction - - C++ Equiv: - unsigned int GetImagesPerDMA(unsigned long * images); - - ''' - cimages = c_ulong() - ret = self.dll.GetImagesPerDMA(byref(cimages)) - return (ret, cimages.value) - - def GetIODirection(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iDirection) = GetIODirection(index) - - Inputs: - index - IO index. Valid values: 0 to GetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iDirection - current direction for this index.: - 0 - 0 Output - 1 - 1 Input - - C++ Equiv: - unsigned int GetIODirection(int index, int * iDirection); - - See Also: - GetNumberIO GetIOLevel SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int() - ret = self.dll.GetIODirection(cindex, byref(ciDirection)) - return (ret, ciDirection.value) - - def GetIOLevel(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iLevel) = GetIOLevel(index) - - Inputs: - index - IO index: - 0 - toGetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - C++ Equiv: - unsigned int GetIOLevel(int index, int * iLevel); - - See Also: - GetNumberIO GetIODirection SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciLevel = c_int() - ret = self.dll.GetIOLevel(cindex, byref(ciLevel)) - return (ret, ciLevel.value) - - def GetIRQ(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, IRQ) = GetIRQ() - - Inputs: - None - - Outputs: - ret - Function Return Code - IRQ - - - C++ Equiv: - unsigned int GetIRQ(int * IRQ); - - ''' - cIRQ = c_int() - ret = self.dll.GetIRQ(byref(cIRQ)) - return (ret, cIRQ.value) - - def GetKeepCleanTime(self): - ''' - Description: - This function will return the time to perform a keep clean cycle. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, KeepCleanTime) = GetKeepCleanTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - KeepCleanTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetKeepCleanTime(float * KeepCleanTime); - - See Also: - GetAcquisitionTimings GetReadOutTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cKeepCleanTime = c_float() - ret = self.dll.GetKeepCleanTime(byref(cKeepCleanTime)) - return (ret, cKeepCleanTime.value) - - def GetMaximumBinning(self, ReadMode, HorzVert): - ''' - Description: - This function will return the maximum binning allowable in either the vertical or horizontal dimension for a particular readout mode. - - Synopsis: - (ret, MaxBinning) = GetMaximumBinning(ReadMode, HorzVert) - - Inputs: - ReadMode - The readout mode for which to retrieve the maximum binning (see SetReadMode for possible values). - HorzVert - 0 to retrieve horizontal binning limit, 1 to retreive limit in the vertical. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Binning returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid Readmode - DRV_P2INVALID - HorzVert not equal to 0 or 1 - DRV_P3INVALID - Invalid MaxBinning address (i.e. NULL) - MaxBinning - Will contain the Maximum binning value on return. - - C++ Equiv: - unsigned int GetMaximumBinning(int ReadMode, int HorzVert, int * MaxBinning); - - See Also: - GetMinimumImageLength SetReadMode - - ''' - cReadMode = c_int(ReadMode) - cHorzVert = c_int(HorzVert) - cMaxBinning = c_int() - ret = self.dll.GetMaximumBinning(cReadMode, cHorzVert, byref(cMaxBinning)) - return (ret, cMaxBinning.value) - - def GetMaximumExposure(self): - ''' - Description: - This function will return the maximum Exposure Time in seconds that is settable by the SetExposureTime function. - - Synopsis: - (ret, MaxExp) = GetMaximumExposure() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Exposure returned. - DRV_P1INVALID - Invalid MaxExp value (i.e. NULL) - MaxExp - Will contain the Maximum exposure value on return. - - C++ Equiv: - unsigned int GetMaximumExposure(float * MaxExp); - - See Also: - SetExposureTime - - ''' - cMaxExp = c_float() - ret = self.dll.GetMaximumExposure(byref(cMaxExp)) - return (ret, cMaxExp.value) - - def GetMaximumNumberRingExposureTimes(self): - ''' - Description: - This function will return the maximum number of exposures that can be configured in the SetRingExposureTimes SDK function. - - Synopsis: - (ret, number) = GetMaximumNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number value (ie NULL) - DRV_NOTAVAILABLE - System does not support this option - number - Will contain the maximum number of exposures on return. - - C++ Equiv: - unsigned int GetMaximumNumberRingExposureTimes(int * number); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable SetRingExposureTimes - - ''' - cnumber = c_int() - ret = self.dll.GetMaximumNumberRingExposureTimes(byref(cnumber)) - return (ret, cnumber.value) - - def GetMCPGain(self): - ''' - Description: - This function will retrieve the set value for the MCP Gain. - - Synopsis: - (ret, gain) = GetMCPGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Table returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Invalid pointer (i.e. NULL) - DRV_NOT_AVAILABLE - Not a USB iStar - gain - Returned gain value. - - C++ Equiv: - unsigned int GetMCPGain(int * gain); - - See Also: - SetMCPGain - - Note: Available only on USB iStar. - - ''' - cgain = c_int() - ret = self.dll.GetMCPGain(byref(cgain)) - return (ret, cgain.value) - - def GetMCPGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the SetMCPGain function. - - Synopsis: - (ret, iLow, iHigh) = GetMCPGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - iLow - lowest gain setting - iHigh - highest gain setting - - C++ Equiv: - unsigned int GetMCPGainRange(int * iLow, int * iHigh); - - See Also: - SetMCPGain - - Note: Available only iStar. - - ''' - ciLow = c_int() - ciHigh = c_int() - ret = self.dll.GetMCPGainRange(byref(ciLow), byref(ciHigh)) - return (ret, ciLow.value, ciHigh.value) - - def GetMCPGainTable(self, iNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, piGain, pfPhotoepc) = GetMCPGainTable(iNum) - - Inputs: - iNum - - - Outputs: - ret - Function Return Code - piGain - - pfPhotoepc - - - C++ Equiv: - unsigned int GetMCPGainTable(int iNum, int * piGain, float * pfPhotoepc); - - ''' - ciNum = c_int(iNum) - cpiGain = c_int() - cpfPhotoepc = c_float() - ret = self.dll.GetMCPGainTable(ciNum, byref(cpiGain), byref(cpfPhotoepc)) - return (ret, cpiGain.value, cpfPhotoepc.value) - - def GetMCPVoltage(self): - ''' - Description: - This function will retrieve the current Micro Channel Plate voltage. - - Synopsis: - (ret, iVoltage) = GetMCPVoltage() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Voltage returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - DRV_GENERAL_ERRORS - EEPROM not valid - iVoltage - Will contain voltage on return. The unit is in Volts and should be between the range 600 - 1100 Volts. - - C++ Equiv: - unsigned int GetMCPVoltage(int * iVoltage); - - See Also: - GetMCPGain - - Note: Available only on USB iStar. - - ''' - ciVoltage = c_int() - ret = self.dll.GetMCPVoltage(byref(ciVoltage)) - return (ret, ciVoltage.value) - - def GetMetaDataInfo(self, index): - ''' - Description: - This function will return the time of the initial frame and the time in milliseconds of further frames from this point. - - Synopsis: - (ret, TimeOfStart, pfTimeFromStart) = GetMetaDataInfo(index) - - Inputs: - index - frame for which time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - TimeOfStart - Structure with start time details. - pfTimeFromStart - time in milliseconds for a particular frame from time of start. - - C++ Equiv: - unsigned int GetMetaDataInfo(SYSTEMTIME * TimeOfStart, float * pfTimeFromStart, int index); - - See Also: - SetMetaData - - ''' - cTimeOfStart = SYSTEMTIME() - cpfTimeFromStart = c_float() - cindex = c_int(index) - ret = self.dll.GetMetaDataInfo(byref(cTimeOfStart), byref(cpfTimeFromStart), cindex) - return (ret, cTimeOfStart, cpfTimeFromStart.value) - - def GetMinimumImageLength(self): - ''' - Description: - This function will return the minimum number of pixels that can be read out from the chip at each exposure. This minimum value arises due the way in which the chip is read out and will limit the possible sub image dimensions and binning sizes that can be applied. - - Synopsis: - (ret, MinImageLength) = GetMinimumImageLength() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum Number of Pixels returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid MinImageLength value (i.e. NULL) - MinImageLength - Will contain the minimum number of super pixels on return. - - C++ Equiv: - unsigned int GetMinimumImageLength(int * MinImageLength); - - See Also: - SetImage - - ''' - cMinImageLength = c_int() - ret = self.dll.GetMinimumImageLength(byref(cMinImageLength)) - return (ret, cMinImageLength.value) - - def GetMinimumNumberInSeries(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, number) = GetMinimumNumberInSeries() - - Inputs: - None - - Outputs: - ret - Function Return Code - number - - - C++ Equiv: - unsigned int GetMinimumNumberInSeries(int * number); - - ''' - cnumber = c_int() - ret = self.dll.GetMinimumNumberInSeries(byref(cnumber)) - return (ret, cnumber.value) - - def GetMostRecentColorImage16(self, size, algorithm): - ''' - Description: - For colour sensors only. - Color version of the GetMostRecentImage16 function. The CCD is sensitive to Cyan, Yellow, Magenta and Green (CYMG). The Red, Green and Blue (RGB) are calculated and Data is stored in 3 planes/images, one for each basic color. - - Synopsis: - (ret, red, green, blue) = GetMostRecentColorImage16(size, algorithm) - - Inputs: - size - total number of pixels. - algorithm - algorithm used to extract the RGB from the original CYMG CCD.: - 0 - 0 basic algorithm combining Cyan, Yellow and Magenta. - 1 - 1 algorithm combining Cyan, Yellow, Magenta and Green. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image RGB has been copied into arrays. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Arrays size is incorrect. - DRV_P2INVALID - Invalid algorithm. - DRV_P3INVALID - Invalid red pointer (i.e. NULL).. - DRV_P4INVALID - Invalid green pointer (i.e. NULL).. - DRV_P5INVALID - Invalid bluepointer (i.e. NULL).. - DRV_NO_NEW_DATA - There is no new data yet. - red - pointer to red data storage allocated by the user. - green - pointer to red data storage allocated by the user. - blue - pointer to red data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentColorImage16(unsigned long size, int algorithm, WORD * red, WORD * green, WORD * blue); - - See Also: - GetMostRecentImage16 DemosaicImage WhiteBalance - - ''' - csize = c_ulong(size) - calgorithm = c_int(algorithm) - cred = (c_short * size)() - cgreen = (c_short * size)() - cblue = (c_short * size)() - ret = self.dll.GetMostRecentColorImage16(csize, calgorithm, cred, cgreen, cblue) - return (ret, cred, cgreen, cblue) - - def GetMostRecentImage(self, size): - ''' - Description: - This function will update the data array with the most recently acquired image in any acquisition mode. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the complete image. - - Synopsis: - (ret, arr) = GetMostRecentImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage(at_32 * arr, unsigned long size); - - See Also: - GetMostRecentImage16 GetOldestImage GetOldestImage16 GetImages - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetMostRecentImage(carr, csize) - return (ret, carr) - - def GetMostRecentImage16(self, size): - ''' - Description: - 16-bit version of the GetMostRecentImageGetMostRecentImage function. - - Synopsis: - (ret, arr) = GetMostRecentImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage16(WORD * arr, long size); - - See Also: - GetMostRecentImage GetOldestImage16 GetOldestImage GetImages - - ''' - carr = (c_short * size)() - csize = c_int(size) - ret = self.dll.GetMostRecentImage16(carr, csize) - return (ret, carr) - - def GetMSTimingsData(self, inoOfImages): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, TimeOfStart, pfDifferences) = GetMSTimingsData(inoOfImages) - - Inputs: - inoOfImages - - - Outputs: - ret - Function Return Code - TimeOfStart - - pfDifferences - - - C++ Equiv: - unsigned int GetMSTimingsData(SYSTEMTIME * TimeOfStart, float * pfDifferences, int inoOfImages); - - ''' - cTimeOfStart = SYSTEMTIME() - cpfDifferences = c_float() - cinoOfImages = c_int(inoOfImages) - ret = self.dll.GetMSTimingsData(byref(cTimeOfStart), byref(cpfDifferences), cinoOfImages) - return (ret, cTimeOfStart, cpfDifferences.value) - - def GetMSTimingsEnabled(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = GetMSTimingsEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int GetMSTimingsEnabled(void); - - ''' - ret = self.dll.GetMSTimingsEnabled() - return (ret) - - def GetNewData(self, size): - ''' - Description: - Deprecated see Note: - This function will update the data array to hold data acquired so far. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. When used in conjunction with the SetDriverEventSetDriverEvent and GetAcquisitonProgressGetAcquisitionProgress functions, the data from each scan in a kinetic series can be processed while the acquisition is taking place. - - Synopsis: - (ret, arr) = GetNewData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData(at_32 * arr, long size); // deprecated - - See Also: - SetDriverEvent GetAcquisitionProgress SetAcquisitionMode SetAcGetNewData8 GetNewData16 - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetNewData(byref(carr), csize) - return (ret, carr.value) - - def GetNewData16(self, size): - ''' - Description: - Deprecated see Note: - 16-bit version of the GetNewDataGetNewData function. - - Synopsis: - (ret, arr) = GetNewData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData16(WORD * arr, long size); // deprecated - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_short() - csize = c_int(size) - ret = self.dll.GetNewData16(byref(carr), csize) - return (ret, carr.value) - - def GetNewData8(self, size): - ''' - Description: - Deprecated see Note: - 8-bit version of the GetNewDataGetNewData function. This function will return the data in the lower 8 bits of the acquired data. - - Synopsis: - (ret, arr) = GetNewData8(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData8(unsigned char * arr, long size); - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = (c_ubyte * size)() - csize = c_int(size) - ret = self.dll.GetNewData8(carr, csize) - return (ret, carr) - - def GetNewFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetNewFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetNewFloatData(float * arr, long size); - - ''' - carr = c_float() - csize = c_int(size) - ret = self.dll.GetNewFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetNumberADChannels(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one A-D converter, this function will tell you the number available. - - Synopsis: - (ret, channels) = GetNumberADChannels() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of channels returned. - channels - number of allowed channels - - C++ Equiv: - unsigned int GetNumberADChannels(int * channels); - - See Also: - SetADChannel - - ''' - cchannels = c_int() - ret = self.dll.GetNumberADChannels(byref(cchannels)) - return (ret, cchannels.value) - - def GetNumberAmp(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one output amplifier, this function will tell you the number available. - - Synopsis: - (ret, amp) = GetNumberAmp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of output amplifiers returned. - amp - number of allowed channels - - C++ Equiv: - unsigned int GetNumberAmp(int * amp); - - See Also: - SetOutputAmplifier - - ''' - camp = c_int() - ret = self.dll.GetNumberAmp(byref(camp)) - return (ret, camp.value) - - def GetNumberAvailableImages(self): - ''' - Description: - This function will return information on the number of available images in the circular buffer. This information can be used with GetImages to retrieve a series of images. If any images are overwritten in the circular buffer they no longer can be retrieved and the information returned will treat overwritten images as not available. - - Synopsis: - (ret, first, last) = GetNumberAvailableImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - DRV_NO_NEW_DATA - There is no new data yet - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberAvailableImages(at_32 * first, at_32 * last); - - See Also: - GetImages GetImages16 GetNumberNewImages - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberAvailableImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberDDGExternalOutputs(self): - ''' - Description: - This function gets the number of available external outputs. - - Synopsis: - (ret, puiCount) = GetNumberDDGExternalOutputs() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiCount - number of available external outputs. - - C++ Equiv: - unsigned int GetNumberDDGExternalOutputs(at_u32 * puiCount); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cpuiCount = c_uint() - ret = self.dll.GetNumberDDGExternalOutputs(byref(cpuiCount)) - return (ret, cpuiCount.value) - - def GetNumberDevices(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, numDevs) = GetNumberDevices() - - Inputs: - None - - Outputs: - ret - Function Return Code - numDevs - - - C++ Equiv: - unsigned int GetNumberDevices(int * numDevs); - - ''' - cnumDevs = c_int() - ret = self.dll.GetNumberDevices(byref(cnumDevs)) - return (ret, cnumDevs.value) - - def GetNumberFKVShiftSpeeds(self): - ''' - Description: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberFKVShiftSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed speeds - - C++ Equiv: - unsigned int GetNumberFKVShiftSpeeds(int * number); - - See Also: - GetFKVShiftSpeedF SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cnumber = c_int() - ret = self.dll.GetNumberFKVShiftSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHorizontalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberHorizontalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHorizontalSpeeds(int * number); // deprecated - - See Also: - GetHorizontalSpeed SetHorizontalSpeed - - Note: Deprecated by GetNumberHSSpeedsGetNumberHSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberHorizontalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHSSpeeds(self, channel, typ): - ''' - Description: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, speeds) = GetNumberHSSpeeds(channel, typ) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication. - 1 - conventional. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - speeds - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHSSpeeds(int channel, int typ, int * speeds); - - See Also: - GetHSSpeed SetHSSpeed GetNumberADChannel - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cspeeds = c_int() - ret = self.dll.GetNumberHSSpeeds(cchannel, ctyp, byref(cspeeds)) - return (ret, cspeeds.value) - - def GetNumberIO(self): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the number of these IOs available. The functions GetIODirection, GetIOLevel, SetIODirection and SetIOLevel can be used to specify the configuration. - - Synopsis: - (ret, iNumber) = GetNumberIO() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of IOs returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iNumber - number of allowed IOs - - C++ Equiv: - unsigned int GetNumberIO(int * iNumber); - - See Also: - GetIOLevel GetIODirection SetIODirection SetIOLevel - - ''' - ciNumber = c_int() - ret = self.dll.GetNumberIO(byref(ciNumber)) - return (ret, ciNumber.value) - - def GetNumberNewImages(self): - ''' - Description: - This function will return information on the number of new images (i.e. images which have not yet been retrieved) in the circular buffer. This information can be used with GetImages to retrieve a series of the latest images. If any images are overwritten in the circular buffer they can no longer be retrieved and the information returned will treat overwritten images as having been retrieved. - - Synopsis: - (ret, first, last) = GetNumberNewImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NO_NEW_DATA - There is no new data yet. - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberNewImages(long * first, long * last); - - See Also: - GetImages GetImages16 GetNumberAvailableImages - - Note: This index will increment as soon as a single accumulation has been completed within the current acquisition. - - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberNewImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberPhotonCountingDivisions(self): - ''' - Description: - Available in some systems is photon counting mode. This function gets the number of photon counting divisions available. The functions SetPhotonCounting and SetPhotonCountingThreshold can be used to specify which of these divisions is to be used. - - Synopsis: - (ret, noOfDivisions) = GetNumberPhotonCountingDivisions() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of photon counting divisions returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Photon Counting not available - noOfDivisions - number of allowed photon counting divisions - - C++ Equiv: - unsigned int GetNumberPhotonCountingDivisions(at_u32 * noOfDivisions); - - See Also: - SetPhotonCounting IsPreAmpGainAvailable SetPhotonCountingThresholdGetPreAmpGain GetCapabilities - - ''' - cnoOfDivisions = c_uint() - ret = self.dll.GetNumberPhotonCountingDivisions(byref(cnoOfDivisions)) - return (ret, cnoOfDivisions.value) - - def GetNumberPreAmpGains(self): - ''' - Description: - Available in some systems are a number of pre amp gains that can be applied to the data as it is read out. This function gets the number of these pre amp gains available. The functions GetPreAmpGain and SetPreAmpGain can be used to specify which of these gains is to be used. - - Synopsis: - (ret, noGains) = GetNumberPreAmpGains() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of pre amp gains returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - noGains - number of allowed pre amp gains - - C++ Equiv: - unsigned int GetNumberPreAmpGains(int * noGains); - - See Also: - IsPreAmpGainAvailable GetPreAmpGain SetPreAmpGain GetCapabilities - - ''' - cnoGains = c_int() - ret = self.dll.GetNumberPreAmpGains(byref(cnoGains)) - return (ret, cnoGains.value) - - def GetNumberRingExposureTimes(self): - ''' - Description: - Gets the number of exposures in the ring at this moment. - - Synopsis: - (ret, ipnumTimes) = GetNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - ipnumTimes - Numberof exposure times. - - C++ Equiv: - unsigned int GetNumberRingExposureTimes(int * ipnumTimes); - - See Also: - SetRingExposureTimes - - ''' - cipnumTimes = c_int() - ret = self.dll.GetNumberRingExposureTimes(byref(cipnumTimes)) - return (ret, cipnumTimes.value) - - def GetNumberVerticalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberVerticalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed vertical speeds - - C++ Equiv: - unsigned int GetNumberVerticalSpeeds(int * number); // deprecated - - See Also: - GetVerticalSpeed SetVerticalSpeed - - Note: Deprecated by GetNumberVSSpeedsGetNumberVSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVerticalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSAmplitudes(self): - ''' - Description: - This function will normally return the number of vertical clock voltage amplitues that the camera has. - - Synopsis: - (ret, number) = GetNumberVSAmplitudes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters - DRV_NOT_INITIALIZED - int* speeds: number of allowed vertical speeds - DRV_NOT_AVAILABLE - Return - Number returned - Return int - System not initialized - DRV_SUCCESS - Your system does not support this feature - DRV_NOT_INITIALIZED - GetNumberVSSpeeds - DRV_ACQUIRING - GetNumberVSSpeeds int WINAPI GetNumberVSSpeeds(int* speeds) - Number of speeds returned. - Description - System not initialized. - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - Acquisition in progress. - number - Number of vertical clock voltages. - - C++ Equiv: - unsigned int GetNumberVSAmplitudes(int * number); - - See Also: - GetVSSpeed SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVSAmplitudes(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSSpeeds(self): - ''' - Description: - - - Synopsis: - (ret, speeds) = GetNumberVSSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code - speeds - - - C++ Equiv: - unsigned int GetNumberVSSpeeds(int * speeds); - - ''' - cspeeds = c_int() - ret = self.dll.GetNumberVSSpeeds(byref(cspeeds)) - return (ret, cspeeds.value) - - def GetOldestImage(self, size): - ''' - Description: - This function will update the data array with the oldest image in the circular buffer. Once the oldest image has been retrieved it no longer is available. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the full image. - - Synopsis: - (ret, arr) = GetOldestImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage(at_32 * arr, unsigned long size); - - See Also: - GetOldestImage16 GetMostRecentImage GetMostRecentImage16 - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage(carr, csize) - return (ret, carr) - - def GetOldestImage16(self, size): - ''' - Description: - 16-bit version of the GetOldestImageGetOldestImage function. - - Synopsis: - (ret, arr) = GetOldestImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage16(WORD * arr, unsigned long size); - - See Also: - GetOldestImage GetMostRecentImage16 GetMostRecentImage - - ''' - carr = (c_short * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage16(carr, csize) - return (ret, carr) - - def GetPhosphorStatus(self): - ''' - Description: - This function will return if the phosphor has saturated. - - Synopsis: - (ret, flag) = GetPhosphorStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Phosphor status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - flag - The status of the phosphor: - 0 - Normal - 1 - Saturated - - C++ Equiv: - unsigned int GetPhosphorStatus(int * flag); - - ''' - cflag = c_int() - ret = self.dll.GetPhosphorStatus(byref(cflag)) - return (ret, cflag.value) - - def GetPhysicalDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetPhysicalDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetPhysicalDMAAddress(unsigned long * Address1, unsigned long * Address2); - - ''' - cAddress1 = c_ulong() - cAddress2 = c_ulong() - ret = self.dll.GetPhysicalDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetPixelSize(self): - ''' - Description: - This function returns the dimension of the pixels in the detector in microns. - - Synopsis: - (ret, xSize, ySize) = GetPixelSize() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pixel size returned. - xSize - width of pixel. - ySize - height of pixel. - - C++ Equiv: - unsigned int GetPixelSize(float * xSize, float * ySize); - - ''' - cxSize = c_float() - cySize = c_float() - ret = self.dll.GetPixelSize(byref(cxSize), byref(cySize)) - return (ret, cxSize.value, cySize.value) - - def GetPreAmpGain(self, index): - ''' - Description: - For those systems that provide a number of pre amp gains to apply to the data as it is read out; this function retrieves the amount of gain that is stored for a particular index. The number of gains available can be obtained by calling the GetNumberPreAmpGainsGetNumberPreAmpGains function and a specific Gain can be selected using the function SetPreAmpGainSetPreAmpGain. - - Synopsis: - (ret, gain) = GetPreAmpGain(index) - - Inputs: - index - gain index: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - gain - gain factor for this index. - - C++ Equiv: - unsigned int GetPreAmpGain(int index, float * gain); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cgain = c_float() - ret = self.dll.GetPreAmpGain(cindex, byref(cgain)) - return (ret, cgain.value) - - def GetPreAmpGainText(self, index, length): - ''' - Description: - This function will return a string with a pre amp gain description. The pre amp gain is selected using the index. The SDK has a string associated with each of its pre amp gains. The maximum number of characters needed to store the pre amp gain descriptions is 30. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetPreAmpGainText(index, length) - - Inputs: - index - gain index 0 to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Array size is incorrect - DRV_NOT_SUPPORTED - Function not supported with this camera - name - nameA user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetPreAmpGainText(int index, char * name, int length); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetPreAmpGainText(cindex, cname, clength) - return (ret, cname) - - def GetQE(self, sensor, wavelength, mode): - ''' - Description: - Returns the percentage QE for a particular head model at a user specified wavelengthSetPreAmpGain. - - Synopsis: - (ret, QE) = GetQE(sensor, wavelength, mode) - - Inputs: - sensor - head model - wavelength - wavelength at which QE is required - mode - Clara mode (Normal (0) or Extended NIR (1)). 0 for all other systems - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - QE returned. - DRV_NOT_INITIALIZED - System not initialized. - QE - requested QE - - C++ Equiv: - unsigned int GetQE(char * sensor, float wavelength, int mode, float * QE); - - See Also: - GetHeadModel IsPreAmpGainAvailable SetPreAmpGain GetCapabilities - - ''' - csensor = sensor - cwavelength = c_float(wavelength) - cmode = c_int(mode) - cQE = c_float() - ret = self.dll.GetQE(csensor, cwavelength, cmode, byref(cQE)) - return (ret, cQE.value) - - def GetReadOutTime(self): - ''' - Description: - This function will return the time to readout data from a sensor. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, ReadOutTime) = GetReadOutTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - ReadOutTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetReadOutTime(float * ReadOutTime); - - See Also: - GetAcquisitionTimings GetKeepCleanTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cReadOutTime = c_float() - ret = self.dll.GetReadOutTime(byref(cReadOutTime)) - return (ret, cReadOutTime.value) - - def GetRegisterDump(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, mode) = GetRegisterDump() - - Inputs: - None - - Outputs: - ret - Function Return Code - mode - - - C++ Equiv: - unsigned int GetRegisterDump(int * mode); - - ''' - cmode = c_int() - ret = self.dll.GetRegisterDump(byref(cmode)) - return (ret, cmode.value) - - def GetRelativeImageTimes(self, first, last, size): - ''' - Description: - This function will return an array of the start times in nanoseconds of a user defined number of frames relative to the initial frame. - - Synopsis: - (ret, arr) = GetRelativeImageTimes(first, last, size) - - Inputs: - first - Index of first frame in array. - last - Index of last frame in array. - size - number of frames for which start time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - arr - array of times in nanoseconds for each frame from time of start. - - C++ Equiv: - unsigned int GetRelativeImageTimes(int first, int last, at_u64 * arr, int size); - - See Also: - GetCapabilities SetMetaData - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = c_ulonglong() - csize = c_int(size) - ret = self.dll.GetRelativeImageTimes(cfirst, clast, byref(carr), csize) - return (ret, carr.value) - - def GetRingExposureRange(self): - ''' - Description: - With the Ring Of Exposure feature there may be a case when not all exposures can be met. The ring of exposure feature will guarantee that the highest exposure will be met but this may mean that the lower exposures may not be. If the lower exposures are too low they will be increased to the lowest value possible. This function will return these upper and lower values. - - Synopsis: - (ret, fpMin, fpMax) = GetRingExposureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Min and max returned - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Trigger mode is not available - fpMin - Minimum exposure - fpMax - Maximum exposure. - - C++ Equiv: - unsigned int GetRingExposureRange(float * fpMin, float * fpMax); - - See Also: - GetCapabilities GetNumberRingExposureTimes IsTriggerModeAvailable SetRingExposureTimes - - ''' - cfpMin = c_float() - cfpMax = c_float() - ret = self.dll.GetRingExposureRange(byref(cfpMin), byref(cfpMax)) - return (ret, cfpMin.value, cfpMax.value) - - def GetSDK3Handle(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Handle) = GetSDK3Handle() - - Inputs: - None - - Outputs: - ret - Function Return Code - Handle - - - C++ Equiv: - unsigned int GetSDK3Handle(int * Handle); - - ''' - cHandle = c_int() - ret = self.dll.GetSDK3Handle(byref(cHandle)) - return (ret, cHandle.value) - - def GetSensitivity(self, channel, horzShift, amplifier, pa): - ''' - Description: - This function returns the sensitivity for a particular speed. - - Synopsis: - (ret, sensitivity) = GetSensitivity(channel, horzShift, amplifier, pa) - - Inputs: - channel - AD channel index. - horzShift - Type of output amplifier. - amplifier - Channel speed index. - pa - PreAmp gain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sensitivity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - sensitivity - requested sensitivity. - - C++ Equiv: - unsigned int GetSensitivity(int channel, int horzShift, int amplifier, int pa, float * sensitivity); - - See Also: - GetCapabilities - - Note: Available only on iXon+ and Clara. - - ''' - cchannel = c_int(channel) - chorzShift = c_int(horzShift) - camplifier = c_int(amplifier) - cpa = c_int(pa) - csensitivity = c_float() - ret = self.dll.GetSensitivity(cchannel, chorzShift, camplifier, cpa, byref(csensitivity)) - return (ret, csensitivity.value) - - def GetShutterMinTimes(self): - ''' - Description: - This function will return the minimum opening and closing times in milliseconds for the shutter on the current camera. - - Synopsis: - (ret, minclosingtime, minopeningtime) = GetShutterMinTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum times successfully returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Parameter is NULL. - DRV_P2INVALID - Parameter is NULL - minclosingtime - returns the minimum closing time in milliseconds that the shutter of the camera supports. - minopeningtime - returns the minimum opening time in milliseconds that the shutter of the camera supports. - - C++ Equiv: - unsigned int GetShutterMinTimes(int * minclosingtime, int * minopeningtime); - - ''' - cminclosingtime = c_int() - cminopeningtime = c_int() - ret = self.dll.GetShutterMinTimes(byref(cminclosingtime), byref(cminopeningtime)) - return (ret, cminclosingtime.value, cminopeningtime.value) - - def GetSizeOfCircularBuffer(self): - ''' - Description: - This function will return the maximum number of images the circular buffer can store based on the current acquisition settings. - - Synopsis: - (ret, index) = GetSizeOfCircularBuffer() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum number of images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the maximum number of images the circular buffer can store. - - C++ Equiv: - unsigned int GetSizeOfCircularBuffer(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetSizeOfCircularBuffer(byref(cindex)) - return (ret, cindex.value) - - def GetSlotBusDeviceFunction(self): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, dwslot, dwBus, dwDevice, dwFunction) = GetSlotBusDeviceFunction() - - Inputs: - None - - Outputs: - ret - Function Return Code - dwslot - - dwBus - - dwDevice - - dwFunction - - - C++ Equiv: - unsigned int GetSlotBusDeviceFunction(DWORD * dwslot, DWORD * dwBus, DWORD * dwDevice, DWORD * dwFunction); - - ''' - cdwslot = () - cdwBus = () - cdwDevice = () - cdwFunction = () - ret = self.dll.GetSlotBusDeviceFunction(byref(cdwslot), byref(cdwBus), byref(cdwDevice), byref(cdwFunction)) - return (ret, cdwslot.value, cdwBus.value, cdwDevice.value, cdwFunction.value) - - def GetSoftwareVersion(self): - ''' - Description: - This function returns the Software version information for the microprocessor code and the driver. - - Synopsis: - (ret, eprom, coffile, vxdrev, vxdver, dllrev, dllver) = GetSoftwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - eprom - EPROM version - coffile - COF file version - vxdrev - Driver revision number - vxdver - Driver version number - dllrev - DLL revision number - dllver - DLL version number - - C++ Equiv: - unsigned int GetSoftwareVersion(unsigned int * eprom, unsigned int * coffile, unsigned int * vxdrev, unsigned int * vxdver, unsigned int * dllrev, unsigned int * dllver); - - ''' - ceprom = c_uint() - ccoffile = c_uint() - cvxdrev = c_uint() - cvxdver = c_uint() - cdllrev = c_uint() - cdllver = c_uint() - ret = self.dll.GetSoftwareVersion(byref(ceprom), byref(ccoffile), byref(cvxdrev), byref(cvxdver), byref(cdllrev), byref(cdllver)) - return (ret, ceprom.value, ccoffile.value, cvxdrev.value, cvxdver.value, cdllrev.value, cdllver.value) - - def GetSpoolProgress(self): - ''' - Description: - Deprecated see Note: - This function will return information on the progress of the current spool operation. The value returned is the number of images that have been saved to disk during the current kinetic scan. - - Synopsis: - (ret, index) = GetSpoolProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Spool progress returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the number of files saved to disk in the current kinetic scan. - - C++ Equiv: - unsigned int GetSpoolProgress(long * index); // deprecated - - See Also: - SetSpool - - Note: Deprecated by GetTotalNumberImagesAcquiredGetNumberHSSpeeds - - ''' - cindex = c_int() - ret = self.dll.GetSpoolProgress(byref(cindex)) - return (ret, cindex.value) - - def GetStartUpTime(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, time) = GetStartUpTime() - - Inputs: - None - - Outputs: - ret - Function Return Code - time - - - C++ Equiv: - unsigned int GetStartUpTime(float * time); - - ''' - ctime = c_float() - ret = self.dll.GetStartUpTime(byref(ctime)) - return (ret, ctime.value) - - def GetStatus(self): - ''' - Description: - This function will return the current status of the Andor SDK system. This function should be called before an acquisition is started to ensure that it is IDLE and during an acquisition to monitor the process. - - Synopsis: - (ret, status) = GetStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - status - current status: - DRV_IDLE - waiting on instructions. - DRV_TEMPCYCLE - Executing temperature cycle. - DRV_ACQUIRING - Acquisition in progress. - DRV_ACCUM_TIME_NOT_MET - Unable to meet Accumulate cycle time. - DRV_KINETIC_TIME_NOT_MET - Unable to meet Kinetic cycle time. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQ_BUFFER - Computer unable to read the data via the ISA slot at the required rate. - DRV_SPOOLERROR - Overflow of the spool buffer. - - C++ Equiv: - unsigned int GetStatus(int * status); - - See Also: - SetTemperature StartAcquisition - - Note: If the status is one of the following: - - ''' - cstatus = c_int() - ret = self.dll.GetStatus(byref(cstatus)) - return (ret, cstatus.value) - - def GetTECStatus(self): - ''' - Description: - This function will return if the TEC has overheated. - - Synopsis: - (ret, piFlag) = GetTECStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - TEC status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the TEC: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetTECStatus(int * piFlag); - - See Also: - SetTECEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetTECStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetTemperature(self): - ''' - Description: - This function returns the temperature of the detector to the nearest degree. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperature() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilized but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperature(int * temperature); - - See Also: - GetTemperatureF SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_int() - ret = self.dll.GetTemperature(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureF(self): - ''' - Description: - This function returns the temperature in degrees of the detector. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperatureF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilised but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperatureF(float * temperature); - - See Also: - GetTemperature SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_float() - ret = self.dll.GetTemperatureF(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureRange(self): - ''' - Description: - This function returns the valid range of temperatures in centigrade to which the detector can be cooled. - - Synopsis: - (ret, mintemp, maxtemp) = GetTemperatureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature range returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mintemp - minimum temperature - maxtemp - maximum temperature - - C++ Equiv: - unsigned int GetTemperatureRange(int * mintemp, int * maxtemp); - - See Also: - GetTemperature GetTemperatureF SetTemperature CoolerON CoolerOFF - - ''' - cmintemp = c_int() - cmaxtemp = c_int() - ret = self.dll.GetTemperatureRange(byref(cmintemp), byref(cmaxtemp)) - return (ret, cmintemp.value, cmaxtemp.value) - - def GetTemperatureStatus(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, SensorTemp, TargetTemp, AmbientTemp, CoolerVolts) = GetTemperatureStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code - SensorTemp - - TargetTemp - - AmbientTemp - - CoolerVolts - - - C++ Equiv: - unsigned int GetTemperatureStatus(float * SensorTemp, float * TargetTemp, float * AmbientTemp, float * CoolerVolts); - - ''' - cSensorTemp = c_float() - cTargetTemp = c_float() - cAmbientTemp = c_float() - cCoolerVolts = c_float() - ret = self.dll.GetTemperatureStatus(byref(cSensorTemp), byref(cTargetTemp), byref(cAmbientTemp), byref(cCoolerVolts)) - return (ret, cSensorTemp.value, cTargetTemp.value, cAmbientTemp.value, cCoolerVolts.value) - - def GetTotalNumberImagesAcquired(self): - ''' - Description: - This function will return the total number of images acquired since the current acquisition started. If the camera is idle the value returned is the number of images acquired during the last acquisition. - - Synopsis: - (ret, index) = GetTotalNumberImagesAcquired() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the total number of images acquired since the acquisition started. - - C++ Equiv: - unsigned int GetTotalNumberImagesAcquired(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetTotalNumberImagesAcquired(byref(cindex)) - return (ret, cindex.value) - - def GetTriggerLevelRange(self): - ''' - Description: - This function returns the valid range of triggers in volts which the system can use. - - Synopsis: - (ret, minimum, maximum) = GetTriggerLevelRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Levels returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - minimum has invalid memory address. - minimum - minimum trigger voltage - maximum - maximum trigger voltage - - C++ Equiv: - unsigned int GetTriggerLevelRange(float * minimum, float * maximum); - - See Also: - GetCapabilities SetTriggerLevel - - ''' - cminimum = c_float() - cmaximum = c_float() - ret = self.dll.GetTriggerLevelRange(byref(cminimum), byref(cmaximum)) - return (ret, cminimum.value, cmaximum.value) - - def GetVersionInfo(self, arr, ui32BufferLen): - ''' - Description: - This function retrieves version information about different aspects of the Andor system. The information is copied into a passed string buffer. Currently, the version of the SDK and the Device Driver (USB or PCI) is supported. - - Synopsis: - (ret, szVersionInfo) = GetVersionInfo(arr, ui32BufferLen) - - Inputs: - arr - : - AT_SDKVersion - requests the SDK version information - AT_DeviceDriverVersion - requests the device driver version - ui32BufferLen - The size of the passed character array, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS Information returned - Information returned - DRV_NOT_INITIALIZED System not initialized - System not initialized - DRV_P1INVALID - Invalid information type requested - DRV_P2INVALID - Storage array pointer is NULL - DRV_P3INVALID - Size of the storage array is zero - szVersionInfo - A user allocated array of characters for storage of the information - - C++ Equiv: - unsigned int GetVersionInfo(AT_VersionInfoId arr, char * szVersionInfo, at_u32 ui32BufferLen); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - carr = (arr) - cszVersionInfo = create_string_buffer(ui32BufferLen) - cui32BufferLen = c_uint(ui32BufferLen) - ret = self.dll.GetVersionInfo(carr, cszVersionInfo, cui32BufferLen) - return (ret, cszVersionInfo) - - def GetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetVerticalSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING DRV_P1INVALID - Acquisition in progress. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVerticalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberVerticalSpeeds SetVerticalSpeed - - Note: Deprecated by GetVSSpeedGetVSSpeed. - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetVerticalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetVirtualDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetVirtualDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetVirtualDMAAddress(void * Address1, void * Address2); - - ''' - cAddress1 = c_void() - cAddress2 = c_void() - ret = self.dll.GetVirtualDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetVSAmplitudeFromString(self, text): - ''' - Description: - This Function is used to get the index of the Vertical Clock Amplitude that corresponds to the string passed in. - - Synopsis: - (ret, index) = GetVSAmplitudeFromString(text) - - Inputs: - text - String to test "Normal" , "+1" , "+2" , "+3" , "+4" - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string Index returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid text. - DRV_P2INVALID - Invalid index pointer. - index - Returns the Index of the VSAmplitude that matches string passed in - - C++ Equiv: - unsigned int GetVSAmplitudeFromString(char * text, int * index); - - See Also: - GetVSAmplitudeString GetVSAmplitudeValue - - ''' - ctext = text - cindex = c_int() - ret = self.dll.GetVSAmplitudeFromString(ctext, byref(cindex)) - return (ret, cindex.value) - - def GetVSAmplitudeString(self, index): - ''' - Description: - This Function is used to get the Vertical Clock Amplitude string that corresponds to the index passed in. - - Synopsis: - (ret, text) = GetVSAmplitudeString(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid text pointer. - text - Returns string value of the VS Amplitude found at the index supplied - - C++ Equiv: - unsigned int GetVSAmplitudeString(int index, char * text); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeValue - - ''' - cindex = c_int(index) - ctext = create_string_buffer(64) - ret = self.dll.GetVSAmplitudeString(cindex, ctext) - return (ret, ctext) - - def GetVSAmplitudeValue(self, index): - ''' - Description: - This Function is used to get the value of the Vertical Clock Amplitude found at the index passed in. - - Synopsis: - (ret, value) = GetVSAmplitudeValue(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude value returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid value pointer. - value - Returns Value of Vertical Clock Amplitude that matches index passed in - - C++ Equiv: - unsigned int GetVSAmplitudeValue(int index, int * value); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeString - - ''' - cindex = c_int(index) - cvalue = c_int() - ret = self.dll.GetVSAmplitudeValue(cindex, byref(cvalue)) - return (ret, cvalue.value) - - def GetVSSpeed(self, index): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds. - - Synopsis: - (ret, speed) = GetVSSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVSSpeed(int index, float * speed); - - See Also: - GetNumberVSSpeeds SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetVSSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GPIBReceive(self, id, address, size): - ''' - Description: - This function reads data from a device until a byte is received with the EOI line asserted or until size bytes have been read. - - Synopsis: - (ret, text) = GPIBReceive(id, address, size) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The address to send the data to - size - Number of characters to read - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data received. - DRV_P3INVALID - Invalid pointer (e.g. NULL). .Other errors may be returned by the GPIB device. Consult the help documentation supplied with these devices. - text - The data to be sent - - C++ Equiv: - unsigned int GPIBReceive(int id, short address, char * text, int size); - - See Also: - GPIBSend - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = create_string_buffer(size) - csize = c_int(size) - ret = self.dll.GPIBReceive(cid, caddress, ctext, csize) - return (ret, ctext) - - def GPIBSend(self, id, address, text): - ''' - Description: - This function initializes the GPIB by sending interface clear. Then the device described by address is put in a listen-active state. Finally the string of characters, text, is sent to the device with a newline character and with the EOI line asserted after the final character. - - Synopsis: - ret = GPIBSend(id, address, text) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The GPIB address to send data to - text - The data to send - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data sent. - DRV_P3INVALID - Invalid pointer (e.g. NULL). The GPIB device may return other errors. Consult the help documentation supplied with these devices. - - C++ Equiv: - unsigned int GPIBSend(int id, short address, char * text); - - See Also: - GPIBReceive - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = text - ret = self.dll.GPIBSend(cid, caddress, ctext) - return (ret) - - def I2CBurstRead(self, i2cAddress, nBytes): - ''' - Description: - This function will read a specified number of bytes from a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstRead(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to read from. - nBytes - The number of bytes to read from the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data read from the device. - - C++ Equiv: - unsigned int I2CBurstRead(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstWrite I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstRead(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CBurstWrite(self, i2cAddress, nBytes): - ''' - Description: - This function will write a specified number of bytes to a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstWrite(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to write to. - nBytes - The number of bytes to write to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data to write to the device. - - C++ Equiv: - unsigned int I2CBurstWrite(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstRead I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstWrite(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CRead(self, deviceID, intAddress): - ''' - Description: - This function will read a single byte from the chosen device. - - Synopsis: - (ret, pdata) = I2CRead(deviceID, intAddress) - - Inputs: - deviceID - The device to read from. - intAddress - The internal address of the device to be read from. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - pdata - The byte read from the device. - - C++ Equiv: - unsigned int I2CRead(BYTE deviceID, BYTE intAddress, BYTE * pdata); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cpdata = c_ubyte() - ret = self.dll.I2CRead(cdeviceID, cintAddress, byref(cpdata)) - return (ret, cpdata.value) - - def I2CReset(self): - ''' - Description: - This function will reset the I2C data bus. - - Synopsis: - ret = I2CReset() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Reset successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CReset(void); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite - - ''' - ret = self.dll.I2CReset() - return (ret) - - def I2CWrite(self, deviceID, intAddress, data): - ''' - Description: - This function will write a single byte to the chosen device. - - Synopsis: - ret = I2CWrite(deviceID, intAddress, data) - - Inputs: - deviceID - The device to write to. - intAddress - The internal address of the device to write to. - data - The byte to be written to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CWrite(BYTE deviceID, BYTE intAddress, BYTE data); - - See Also: - I2CBurstWrite I2CBurstRead I2CRead I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cdata = c_ubyte(data) - ret = self.dll.I2CWrite(cdeviceID, cintAddress, cdata) - return (ret) - - def IdAndorDll(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = IdAndorDll() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int IdAndorDll(void); - - ''' - ret = self.dll.IdAndorDll() - return (ret) - - def InAuxPort(self, port): - ''' - Description: - This function returns the state of the TTL Auxiliary Input Port on the Andor plug-in card. - - Synopsis: - (ret, state) = InAuxPort(port) - - Inputs: - port - Number of AUX in port on Andor card. Valid Values: 1 to 4 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX read. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - state - current state of port: - 0 - OFF/LOW - all others - ON/HIGH - - C++ Equiv: - unsigned int InAuxPort(int port, int * state); - - See Also: - OutAuxPort - - ''' - cport = c_int(port) - cstate = c_int() - ret = self.dll.InAuxPort(cport, byref(cstate)) - return (ret, cstate.value) - - def Initialize(self, dir): - ''' - Description: - This function will initialize the Andor SDK System. As part of the initialization procedure on some cameras (i.e. Classic, iStar and earlier iXion) the DLL will need access to a DETECTOR.INI which contains information relating to the detector head, number pixels, readout speeds etc. If your system has multiple cameras then see the section Controlling multiple cameras - - Synopsis: - ret = Initialize(dir) - - Inputs: - dir - Path to the directory containing the files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_VXDNOTINSTALLED - Initialisation successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ERROR_FILELOAD - Unable to load *.COF or *.RBF files. - DRV_ERROR_PAGELOCK - Unable to acquire lock on requested memory. - DRV_USBERROR - Unable to detect USB device or not USB2.0. - DRV_ERROR_NOCAMERA - No camera found - - C++ Equiv: - unsigned int Initialize(char * dir); - - See Also: - GetAvailableCameras SetCurrentCamera GetCurrentCamera - - ''' - cdir = dir - ret = self.dll.Initialize(cdir) - return (ret) - - def InitializeDevice(self, dir): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = InitializeDevice(dir) - - Inputs: - dir - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int InitializeDevice(char * dir); - - ''' - cdir = dir - ret = self.dll.InitializeDevice(cdir) - return (ret) - - def IsAmplifierAvailable(self, iamp): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified amplifier. - - Synopsis: - ret = IsAmplifierAvailable(iamp) - - Inputs: - iamp - amplifier to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplifier available - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_AMPLIFIER - Not a valid amplifier - - C++ Equiv: - unsigned int IsAmplifierAvailable(int iamp); - - See Also: - SetHSSpeed - - ''' - ciamp = c_int(iamp) - ret = self.dll.IsAmplifierAvailable(ciamp) - return (ret) - - def IsCoolerOn(self): - ''' - Description: - This function checks the status of the cooler. - - Synopsis: - (ret, iCoolerStatus) = IsCoolerOn() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Parameter is NULL - iCoolerStatus - iCoolerStatus0: Cooler is OFF.: - 1 - 1 Cooler is ON. - - C++ Equiv: - unsigned int IsCoolerOn(int * iCoolerStatus); - - See Also: - CoolerON CoolerOFF - - ''' - ciCoolerStatus = c_int() - ret = self.dll.IsCoolerOn(byref(ciCoolerStatus)) - return (ret, ciCoolerStatus.value) - - def IsCountConvertModeAvailable(self, mode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified Count Convert mode. - - Synopsis: - ret = IsCountConvertModeAvailable(mode) - - Inputs: - mode - Count Convert mode to be checked - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode available. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - DRV_INVALID_COUNTCONVERT_MODE - Count Convert mode not available with current acquisition settings - - C++ Equiv: - unsigned int IsCountConvertModeAvailable(int mode); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cmode = c_int(mode) - ret = self.dll.IsCountConvertModeAvailable(cmode) - return (ret) - - def IsInternalMechanicalShutter(self): - ''' - Description: - This function checks if an iXon camera has a mechanical shutter installed. - - - Synopsis: - (ret, internalShutter) = IsInternalMechanicalShutter() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Internal shutter state returned - DRV_NOT_AVAILABLE - Not an iXon Camera - DRV_P1INVALID - Parameter is NULL - internalShutter - Status of internal shutter: - 0 - Mechanical shutter not installed. - 1 - Mechanical shutter installed. - - C++ Equiv: - unsigned int IsInternalMechanicalShutter(int * internalShutter); - - Note: Available only on iXon - - ''' - cinternalShutter = c_int() - ret = self.dll.IsInternalMechanicalShutter(byref(cinternalShutter)) - return (ret, cinternalShutter.value) - - def IsPreAmpGainAvailable(self, channel, amplifier, index, pa): - ''' - Description: - This function checks that the AD channel exists, and that the amplifier, speed and gain are available for the AD channel. - - Synopsis: - (ret, status) = IsPreAmpGainAvailable(channel, amplifier, index, pa) - - Inputs: - channel - AD channel index. - amplifier - Type of output amplifier. - index - Channel speed index. - pa - PreAmpGain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - PreAmpGain status returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - status - PreAmpGain Status: - 0 - PreAmpGain not available. - 1 - PreAmpGain available. - - C++ Equiv: - unsigned int IsPreAmpGainAvailable(int channel, int amplifier, int index, int pa, int * status); - - See Also: - GetNumberPreAmpGains GetPreAmpGain SetPreAmpGain - - Note: Available only on iXon. - - ''' - cchannel = c_int(channel) - camplifier = c_int(amplifier) - cindex = c_int(index) - cpa = c_int(pa) - cstatus = c_int() - ret = self.dll.IsPreAmpGainAvailable(cchannel, camplifier, cindex, cpa, byref(cstatus)) - return (ret, cstatus.value) - - def IsTriggerModeAvailable(self, iTriggerMode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified trigger mode. - - Synopsis: - ret = IsTriggerModeAvailable(iTriggerMode) - - Inputs: - iTriggerMode - Trigger mode to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode available - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Not a valid mode - - C++ Equiv: - unsigned int IsTriggerModeAvailable(int iTriggerMode); - - See Also: - SetTriggerMode - - ''' - ciTriggerMode = c_int(iTriggerMode) - ret = self.dll.IsTriggerModeAvailable(ciTriggerMode) - return (ret) - - def Merge(self, nOrder, nPoint, nPixel, fit, hbin): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr, coeff, output, start, step_Renamed) = Merge(nOrder, nPoint, nPixel, fit, hbin) - - Inputs: - nOrder - - nPoint - - nPixel - - fit - - hbin - - - Outputs: - ret - Function Return Code - arr - - coeff - - output - - start - - step_Renamed - - - C++ Equiv: - unsigned int Merge(const at_32 * arr, long nOrder, long nPoint, long nPixel, float * coeff, long fit, long hbin, at_32 * output, float * start, float * step_Renamed); - - ''' - carr = c_int() - cnOrder = c_int(nOrder) - cnPoint = c_int(nPoint) - cnPixel = c_int(nPixel) - ccoeff = c_float() - cfit = c_int(fit) - chbin = c_int(hbin) - coutput = c_int() - cstart = c_float() - cstep_Renamed = c_float() - ret = self.dll.Merge(byref(carr), cnOrder, cnPoint, cnPixel, byref(ccoeff), cfit, chbin, byref(coutput), byref(cstart), byref(cstep_Renamed)) - return (ret, carr.value, ccoeff.value, coutput.value, cstart.value, cstep_Renamed.value) - - def OA_AddMode(self, uiModeNameLen, pcModeDescription, uiModeDescriptionLen): - ''' - Description: - This function will add a mode name and description to memory. Note that this will not add the mode to file, a subsequent call to OA_WriteToFile must be made. - - Synopsis: - (ret, pcModeName) = OA_AddMode(uiModeNameLen, pcModeDescription, uiModeDescriptionLen) - - Inputs: - uiModeNameLen - Mode name string length. - pcModeDescription - A description of the user defined mode. - uiModeDescriptionLen - Mode Description string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_P1INVALID DRV_P3INVALID DRV_OA_INVALID_STRING_LENGTH - All parameters accepted Null mode name. Null mode description. One or more parameters have an invalid length, i.e. > 255. - DRV_OA_INVALID_NAMING - Mode and description have the same name, this is not valid. - DRV_OA_MODE_BUFFER_FULL DRV_OA_INVALID_CHARS_IN_NAME - Number of modes exceeds limit. Mode name and/or description contain invalid characters. - DRV_OA_MODE_ALREADY_EXISTS - Mode name already exists in the file. - DRV_OA_INVALID_CHARS_IN_NAME - Invalid charcters in Mode Name or Mode Description - pcModeName - A name for the mode to be defined. - - C++ Equiv: - unsigned int OA_AddMode(char * pcModeName, int uiModeNameLen, char * pcModeDescription, int uiModeDescriptionLen); - - See Also: - OA_DeleteMode OA_WriteToFile - - ''' - cpcModeName = create_string_buffer(uiModeNameLen) - cuiModeNameLen = c_int(uiModeNameLen) - cpcModeDescription = pcModeDescription - cuiModeDescriptionLen = c_int(uiModeDescriptionLen) - ret = self.dll.OA_AddMode(cpcModeName, cuiModeNameLen, cpcModeDescription, cuiModeDescriptionLen) - return (ret, cpcModeName) - - def OA_DeleteMode(self, pcModeName, uiModeNameLen): - ''' - Description: - This function will remove a mode from memory. To permanently remove a mode from file, call OA_WriteToFile after OA_DeleteMode. The Preset file will not be affected. - - Synopsis: - ret = OA_DeleteMode(pcModeName, uiModeNameLen) - - Inputs: - pcModeName - The name of the mode to be removed. - uiModeNameLen - Mode name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DRV_OA_MODE_DOES_NOT_EXIST - DRV_P1INVALID - All parameters accepted Null mode name. - DRV_OA_INVALID_STRING_LENGTH - The mode name parameter has an invalid length, i.e. > 256. - - C++ Equiv: - unsigned int OA_DeleteMode(const char * pcModeName, int uiModeNameLen); - - See Also: - OA_AddMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cuiModeNameLen = c_int(uiModeNameLen) - ret = self.dll.OA_DeleteMode(cpcModeName, cuiModeNameLen) - return (ret) - - def OA_EnableMode(self, pcModeName): - ''' - Description: - This function will set all the parameters associated with the specified mode to be used for all subsequent acquisitions. The mode specified by the user must be in either the Preset file or the User defined file. - - Synopsis: - ret = OA_EnableMode(pcModeName) - - Inputs: - pcModeName - The mode to be used for all subsequent acquisitions. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode name. - DRV_OA_MODE_DOES_NOT_EXIST - Mode name does not exist. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - - C++ Equiv: - unsigned int OA_EnableMode(const char * pcModeName); - - See Also: - OA_AddMode - - ''' - cpcModeName = pcModeName - ret = self.dll.OA_EnableMode(cpcModeName) - return (ret) - - def OA_GetFloat(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for floating point type acquisition parameters. - Values are retrieved from memory for the specified mode name. - - Synopsis: - (ret, fFloatValue) = OA_GetFloat(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode parameter. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null float value. - fFloatValue - The value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetFloat(const char * pcModeName, const char * pcModeParam, float * fFloatValue); - - See Also: - OA_SetFloat - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float() - ret = self.dll.OA_GetFloat(cpcModeName, cpcModeParam, byref(cfFloatValue)) - return (ret, cfFloatValue.value) - - def OA_GetInt(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for integer type acquisition parameters. Values are retrieved from memory for the specified mode name. - - - Synopsis: - (ret, iintValue) = OA_GetInt(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter - pcModeParam - The name of the acquisition parameter for which a value - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null integer value. - iintValue - The buffer to return the value of the acquisition. - - C++ Equiv: - unsigned int OA_GetInt(const char * pcModeName, const char * pcModeParam, int * iintValue); - - See Also: - OA_SetInt - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int() - ret = self.dll.OA_GetInt(cpcModeName, cpcModeParam, byref(ciintValue)) - return (ret, ciintValue.value) - - def OA_GetModeAcqParams(self, pcModeName): - ''' - Description: - This function will return all acquisition parameters associated with the specified mode. The mode specified by the user must be in either the Preset file or the User defined file. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfParams) = OA_GetModeAcqParams(pcModeName) - - Inputs: - pcModeName - The mode for which all acquisition parameters must be returned. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_NO_USER_DATA - No data for selected mode. - pcListOfParams - A user allocated array of characters for storage of the acquisition parameters. Parameters will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetModeAcqParams(const char * pcModeName, char * pcListOfParams); - - See Also: - OA_GetNumberOfAcqParams - - ''' - cpcModeName = pcModeName - cpcListOfParams = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetModeAcqParams(cpcModeName, cpcListOfParams) - return (ret, cpcListOfParams) - - def OA_GetNumberOfAcqParams(self, pcModeName): - ''' - Description: - This function will return the parameters associated with a specified mode. The mode must be present in either the Preset file or the User defined file. - - Synopsis: - (ret, puiNumberOfParams) = OA_GetNumberOfAcqParams(pcModeName) - - Inputs: - pcModeName - The mode to search for a list of acquisition parameters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null number of parameters. - DRV_OA_NULL_ERROR - Invalid pointer. - puiNumberOfParams - The number of acquisition parameters for the specified mode. - - C++ Equiv: - unsigned int OA_GetNumberOfAcqParams(const char * pcModeName, unsigned int * puiNumberOfParams); - - See Also: - OA_GetModeAcqParams - - ''' - cpcModeName = pcModeName - cpuiNumberOfParams = c_uint() - ret = self.dll.OA_GetNumberOfAcqParams(cpcModeName, byref(cpuiNumberOfParams)) - return (ret, cpuiNumberOfParams.value) - - def OA_GetNumberOfPreSetModes(self): - ''' - Description: - This function will return the number of modes defined in the Preset file. The Preset file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfPreSetModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the Andor file. - - C++ Equiv: - unsigned int OA_GetNumberOfPreSetModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetPreSetModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfPreSetModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetNumberOfUserModes(self): - ''' - Description: - This function will return the number of modes defined in the User file. The user defined file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfUserModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the user file. - - C++ Equiv: - unsigned int OA_GetNumberOfUserModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetUserModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfUserModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetPreSetModeNames(self): - ''' - Description: - This function will return the available mode names from the Preset file. The mode and the Preset file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetPreSetModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetPreSetModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfPreSetModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetPreSetModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_GetString(self, pcModeName, pcModeParam, uiStringLen): - ''' - Description: - This function is used to get the values for string type acquisition parameters. Values - are retrieved from memory for the specified mode name. - - Synopsis: - (ret, pcStringValue) = OA_GetString(pcModeName, pcModeParam, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - uiStringLen - The length of the buffer. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - pcStringValue - The buffer to return the value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_SetString - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = create_string_buffer(uiStringLen) - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_GetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret, cpcStringValue) - - def OA_GetUserModeNames(self): - ''' - Description: - This function will return the available mode names from a User defined file. The mode and the User defined file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetUserModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetUserModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfUserModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetUserModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_Initialize(self, pcFilename, uiFileNameLen): - ''' - Description: - This function will initialise the OptAcquire settings from a Preset file and a User defined file if it exists. - - Synopsis: - ret = OA_Initialize(pcFilename, uiFileNameLen) - - Inputs: - pcFilename - The name of a user xml file. If the file exists then data will be read from the file. If the file does not exist the file name may be used when the user calls WriteToFile(). - uiFileNameLen - The length of the filename. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - DRV_OA_GET_CAMERA_ERROR - Unable to retrieve information about the - DRV_OA_INVALID_STRING_LENGTH - model of the Camera. - DRV_OA_ANDOR_FILE_NOT_LOADED - The parameter has an invalid length, i.e. > 255. - DRV_OA_USER_FILE_NOT_LOADED - Preset Andor file failed to load. - DRV_OA_FILE_ACCESS_ERROR - Supplied User file failed to load. - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED - Failed to determine status of file. - - C++ Equiv: - unsigned int OA_Initialize(const char * pcFilename, int uiFileNameLen); - - See Also: - OA_WriteToFile - - ''' - cpcFilename = pcFilename - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_Initialize(cpcFilename, cuiFileNameLen) - return (ret) - - def OA_SetFloat(self, pcModeName, pcModeParam, fFloatValue): - ''' - Description: - This function is used to set values for floating point type acquisition parameters where - the new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetFloat(pcModeName, pcModeParam, fFloatValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - fFloatValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetFloat(const char * pcModeName, const char * pcModeParam, const float fFloatValue); - - See Also: - OA_GetFloat OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float(fFloatValue) - ret = self.dll.OA_SetFloat(cpcModeName, cpcModeParam, cfFloatValue) - return (ret) - - def OA_SetInt(self, pcModeName, pcModeParam, iintValue): - ''' - Description: - This function is used to set values for integer type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetInt(pcModeName, pcModeParam, iintValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - iintValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetInt(const char * pcModeName, const char * pcModeParam, const int iintValue); - - See Also: - OA_GetInt OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int(iintValue) - ret = self.dll.OA_SetInt(cpcModeName, cpcModeParam, ciintValue) - return (ret) - - def OA_SetString(self, pcModeName, pcModeParam, pcStringValue, uiStringLen): - ''' - Description: - This function is used to set values for string type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetString(pcModeName, pcModeParam, pcStringValue, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter is to be edited. - pcModeParam - The name of the acquisition parameter to be edited. - pcStringValue - The value to assign to the acquisition parameter. - uiStringLen - The length of the input string. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_GetString OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = pcStringValue - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_SetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret) - - def OA_WriteToFile(self, pcFileName, uiFileNameLen): - ''' - Description: - This function will write a User defined list of modes to the User file. The Preset file will not be affected. - - Synopsis: - ret = OA_WriteToFile(pcFileName, uiFileNameLen) - - Inputs: - pcFileName - The name of the file to be written to. - uiFileNameLen - File name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_INVALID_FILE - Data cannot be written to the Preset Andor file. - DRV_ERROR_FILESAVE - Failed to save data to file. - DRV_OA_FILE_HAS_BEEN_MODIFIED - File to be written to has been modified since last write, local copy of file may not be the same. - DRV_OA_INVALID_CHARS_IN_NAME - File name contains invalid characters. - - C++ Equiv: - unsigned int OA_WriteToFile(const char * pcFileName, int uiFileNameLen); - - See Also: - OA_AddMode OA_DeleteMode - - ''' - cpcFileName = pcFileName - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_WriteToFile(cpcFileName, cuiFileNameLen) - return (ret) - - def OutAuxPort(self, port, state): - ''' - Description: - This function sets the TTL Auxiliary Output port (P) on the Andor plug-in card to either ON/HIGH or OFF/LOW. - - Synopsis: - ret = OutAuxPort(port, state) - - Inputs: - port - Number of AUX out port on Andor card: - 1 - to 4 - state - state to put port in: - 0 - OFF/LOW - all - others ON/HIGH - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX port set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - - C++ Equiv: - unsigned int OutAuxPort(int port, int state); - - See Also: - InAuxPort - - ''' - cport = c_int(port) - cstate = c_int(state) - ret = self.dll.OutAuxPort(cport, cstate) - return (ret) - - def PostProcessCountConvert(self, iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to either Photons or Electrons based on the mode selected by the user. The input data should be in counts. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessCountConvert(iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The size of the output buffer.: - data - data - iNumImages - The number of images if a kinetic series is supplied as the input - iBaseline - The baseline associated with the image.: - 1 - - Convert to Electrons - 2 - - Convert to Photons - iMode - The mode to use to process the data. - iEmGain - The gain level of the input image. - fQE - The Quantum Efficiency of the sensor. - fSensitivity - The Sensitivity value used to acquire the image. - iHeight - The height of the image. - iWidth - The width of the image. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Number of images less than zero. - DRV_P5INVALID - Baseline less than zero. - DRV_P6INVALID - Invalid count convert mode. - DRV_P7INVALID - EMGain less than zero. - DRV_P8INVALID DRV_P9INVALID - QE less than zero. - DRV_P10INVALID - Sensitivity less than zero. - DRV_P11INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The output buffer to return the processed image. - - C++ Equiv: - unsigned int PostProcessCountConvert(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iBaseline, int iMode, int iEmGain, float fQE, float fSensitivity, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - ciEmGain = c_int(iEmGain) - cfQE = c_float(fQE) - cfSensitivity = c_float(fSensitivity) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessCountConvert(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciBaseline, ciMode, ciEmGain, cfQE, cfSensitivity, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessDataAveraging(self, iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessDataAveraging(iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor) - - Inputs: - iOutputBufferSize - - iNumImages - - iAveragingFilterMode - - iHeight - - iWidth - - iFrameCount - - iAveragingFactor - - - Outputs: - ret - Function Return Code - pInputImage - - pOutputImage - - - C++ Equiv: - unsigned int PostProcessDataAveraging(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iAveragingFilterMode, int iHeight, int iWidth, int iFrameCount, int iAveragingFactor); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciAveragingFilterMode = c_int(iAveragingFilterMode) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ciFrameCount = c_int(iFrameCount) - ciAveragingFactor = c_int(iAveragingFactor) - ret = self.dll.PostProcessDataAveraging(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciAveragingFilterMode, ciHeight, ciWidth, ciFrameCount, ciAveragingFactor) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessNoiseFilter(self, iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth): - ''' - Description: - This function will apply a filter to the input image and return the processed image in the output buffer. The filter applied is chosen by the user by setting Mode to a permitted value. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessNoiseFilter(iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The baseline associated with the image. - iBaseline - The mode to use to process the data.: - 1 - Use Median Filter. - 2 - Use Level Above Filter. - 3 - Use interquartile Range Filter. - 4 - Use Noise Threshold Filter. - iMode - This is the Threshold multiplier for the Median, interquartile: - and - Noise Threshold filters. For the Level Above filter this is - Threshold - count above the baseline. - fThreshold - The height of the image. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_SUPPORTED DRV_NOT_INITIALIZED - Camera does not support Noise filter processing. System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Baseline less than zero. - DRV_P5INVALID - Invalid Filter mode. - DRV_P6INVALID - Threshold value not valid for selected mode. - DRV_P7INVALID - Height less than zero. - DRV_P8INVALID DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - - C++ Equiv: - unsigned int PostProcessNoiseFilter(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iBaseline, int iMode, float fThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - cfThreshold = c_float(fThreshold) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessNoiseFilter(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciBaseline, ciMode, cfThreshold, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessPhotonCounting(self, iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to photons and return the processed image in the output buffer. - - Synopsis: - (ret, pInputImage, pOutputImage, pfThreshold) = PostProcessPhotonCounting(iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The number of images if a kinetic series is supplied as the input: - data - data - iNumImages - The number of frames per output image. - iNumframes - The number of thresholds provided by the user. - iNumberOfThresholds - The Thresholds used to define a photon. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_NOT_INITIALIZED - Acquisition prepared. - DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Number of images less than zero. - DRV_P6INVALID - Invalid Number of Frames requested. - DRV_P7INVALID - Invalid number of thresholds. - DRV_P8INVALID - Invalid pointer (i.e. NULL). - DRV_P9INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - pfThreshold - The height of the image. - - C++ Equiv: - unsigned int PostProcessPhotonCounting(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iNumframes, int iNumberOfThresholds, float * pfThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciNumframes = c_int(iNumframes) - ciNumberOfThresholds = c_int(iNumberOfThresholds) - cpfThreshold = c_float() - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessPhotonCounting(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciNumframes, ciNumberOfThresholds, byref(cpfThreshold), ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value, cpfThreshold.value) - - def PrepareAcquisition(self): - ''' - Description: - This function reads the current acquisition setup and allocates and configures any memory that will be used during the acquisition. The function call is not required as it will be called automatically by the StartAcquisition function if it has not already been called externally. - However for long kinetic series acquisitions the time to allocate and configure any memory can be quite long which can result in a long delay between calling StartAcquisition and the acquisition actually commencing. For iDus, there is an additional delay caused by the camera being set-up with any new acquisition parameters. Calling PrepareAcquisition first will reduce this delay in the StartAcquisition call. - - Synopsis: - ret = PrepareAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_IOCERROR - integrate On Chip setup error. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int PrepareAcquisition(void); - - See Also: - StartAcquisition FreeInternalMemory - - ''' - ret = self.dll.PrepareAcquisition() - return (ret) - - def SaveAsBmp(self, path, palette, ymin, ymax): - ''' - Description: - This function saves the last acquisition as a bitmap file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the bitmap. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The ymin and ymax parameters indicate which data values will map to the first and last colors in the palette: - * All data values below or equal to ymin will be colored with the first color. - * All values above or equal to ymax will be colored with the last color - * All other palette colors will be scaled across values between these limits. - - Synopsis: - ret = SaveAsBmp(path, palette, ymin, ymax) - - Inputs: - path - The filename of the bitmap. - palette - The filename of a palette file (.PAL) for applying color to the bitmap. - ymin - Min data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - ymax - Max data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as bitmap. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsBmp(const char * path, const char * palette, long ymin, long ymax); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff - - Note: If the last acquisition was in Kinetic Series mode, each image will be saved in a separate Bitmap file. The filename specified will have an index number appended to it, indicating the position in the series. - - ''' - cpath = path - cpalette = palette - cymin = c_int(ymin) - cymax = c_int(ymax) - ret = self.dll.SaveAsBmp(cpath, cpalette, cymin, cymax) - return (ret) - - def SaveAsCommentedSif(self, path, comment): - ''' - Description: - This function will save the data from the last acquisition into a file. The comment text will be added to the user text portion of the Sif file. - - Synopsis: - ret = SaveAsCommentedSif(path, comment) - - Inputs: - path - pointer to a filename specified by the user. - comment - comment text to add to the sif file - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - - C++ Equiv: - unsigned int SaveAsCommentedSif(char * path, char * comment); - - See Also: - SetSifComment SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment - - Note: The comment used in SIF files created with this function is discarded once the call completes, i.e. future calls to SaveAsSif will not use this comment. To set a persistent comment use the SetSifComment function. - - ''' - cpath = path - ccomment = comment - ret = self.dll.SaveAsCommentedSif(cpath, ccomment) - return (ret) - - def SaveAsEDF(self, szPath, iMode): - ''' - Description: - This function saves the last acquisition in the European Synchotron Radiation Facility Data Format (*.edf). - - Synopsis: - ret = SaveAsEDF(szPath, iMode) - - Inputs: - szPath - the filename to save to. - iMode - option to save to multiple files.: - 0 - Save to 1 file - 1 - Save kinetic series to multiple files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsEDF(char * szPath, int iMode); - - See Also: - SaveAsSif SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszPath = szPath - ciMode = c_int(iMode) - ret = self.dll.SaveAsEDF(cszPath, ciMode) - return (ret) - - def SaveAsFITS(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition in the FITS (Flexible Image Transport System) Data Format (*.fits) endorsed by NASA. - - Synopsis: - ret = SaveAsFITS(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 0 - Unsigned 16 - 1 - Unsigned 32 - 2 - Signed 16 - 3 - Signed 32 - 4 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsFITS(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsFITS(cszFileTitle, ctyp) - return (ret) - - def SaveAsRaw(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition as a raw data file. - - Synopsis: - ret = SaveAsRaw(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 1 - Signed 16 - 2 - Signed 32 - 3 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsRaw(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsRaw(cszFileTitle, ctyp) - return (ret) - - def SaveAsSif(self, path): - ''' - Description: - This function will save the data from the last acquisition into a file, which can be read in by the main application. User text can be added to sif files using the SaveAsCommentedSif and SetSifComment functions. - - Synopsis: - ret = SaveAsSif(path) - - Inputs: - path - pointer to a filename specified by the user. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSif(char * path); - - See Also: - SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment SaveAsCommentedSif - - ''' - cpath = path - ret = self.dll.SaveAsSif(cpath) - return (ret) - - def SaveAsSPC(self, path): - ''' - Description: - This function saves the last acquisition in the GRAMS .spc file format - - Synopsis: - ret = SaveAsSPC(path) - - Inputs: - path - the filename to save too. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSPC(char * path); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsTiff SaveAsBmp - - ''' - cpath = path - ret = self.dll.SaveAsSPC(cpath) - return (ret) - - def SaveAsTiff(self, path, palette, position, typ): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively - - Synopsis: - ret = SaveAsTiff(path, palette, position, typ) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsTiff(char * path, char * palette, int position, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsBmp SaveAsTiffEx SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - ret = self.dll.SaveAsTiff(cpath, cpalette, cposition, ctyp) - return (ret) - - def SaveAsTiffEx(self, path, palette, position, typ, mode): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. This is an extended version of the SaveAsTiff function. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively. The mode parameter specifies the mode of output. Data can be output scaled from the min and max count values across the entire range of values (mode 0) or can remain unchanged (mode 1).Of course if the count value is higher or lower than the output data range then even in mode 1 data will be scaled. - - Synopsis: - ret = SaveAsTiffEx(path, palette, position, typ, mode) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - mode - The output mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_P5INVALID - mode not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsTiffEx(char * path, char * palette, int position, int typ, int mode); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - cmode = c_int(mode) - ret = self.dll.SaveAsTiffEx(cpath, cpalette, cposition, ctyp, cmode) - return (ret) - - def SaveEEPROMToFile(self, cFileName): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveEEPROMToFile(cFileName) - - Inputs: - cFileName - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveEEPROMToFile(char * cFileName); - - ''' - ccFileName = cFileName - ret = self.dll.SaveEEPROMToFile(ccFileName) - return (ret) - - def SaveToClipBoard(self, palette): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveToClipBoard(palette) - - Inputs: - palette - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveToClipBoard(char * palette); - - ''' - cpalette = palette - ret = self.dll.SaveToClipBoard(cpalette) - return (ret) - - def SelectDevice(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SelectDevice(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SelectDevice(int devNum); - - ''' - cdevNum = c_int(devNum) - ret = self.dll.SelectDevice(cdevNum) - return (ret) - - def SendSoftwareTrigger(self): - ''' - Description: - This function sends an event to the camera to take an acquisition when in Software Trigger mode. Not all cameras have this mode available to them. To check if your camera can operate in this mode check the GetCapabilities function for the Trigger Mode AC_TRIGGERMODE_CONTINUOUS. If this mode is physically possible and other settings are suitable (IsTriggerModeAvailable) and the camera is acquiring then this command will take an acquisition. - - Synopsis: - ret = SendSoftwareTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger sent - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - Not in SoftwareTrigger mode - DRV_IDLE - Not Acquiring - DRV_ERROR_CODES - Error communicating with camera - DRV_ERROR_ACK - Previous acquisition not complete - - C++ Equiv: - unsigned int SendSoftwareTrigger(void); - - See Also: - GetCapabilities IsTriggerModeAvailable SetAcquisitionMode SetReadMode SetTriggerMode - - Note: The settings of the camera must be as follows: - ReadOut mode is full image - RunMode is Run Till Abort - TriggerMode is 10 - - - - - ''' - ret = self.dll.SendSoftwareTrigger() - return (ret) - - def SetAccumulationCycleTime(self, time): - ''' - Description: - This function will set the accumulation cycle time to the nearest valid value not less than the given value. The actual cycle time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetAccumulationCycleTime(time) - - Inputs: - time - the accumulation cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure time invalid. - - C++ Equiv: - unsigned int SetAccumulationCycleTime(float time); - - See Also: - SetNumberAccumulations GetAcquisitionTimings - - ''' - ctime = c_float(time) - ret = self.dll.SetAccumulationCycleTime(ctime) - return (ret) - - def SetAcqStatusEvent(self, statusEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the camera has started exposing or that the camera has finished exposing. To determine what event has actually occurred call the GetCameraEventStatus funtion. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. The SetPCIMode function must be called to enable/disable the events from the driver. - - Synopsis: - ret = SetAcqStatusEvent(statusEvent) - - Inputs: - statusEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetAcqStatusEvent(at_32 statusEvent); - - See Also: - GetCameraEventStatus SetPCIMode - - Note: This is only available with the CCI23 PCI card. - - ''' - cstatusEvent = c_int(statusEvent) - ret = self.dll.SetAcqStatusEvent(cstatusEvent) - return (ret) - - def SetAcquisitionMode(self, mode): - ''' - Description: - This function will set the acquisition mode to be used on the next StartAcquisitionStartAcquisition. - - Synopsis: - ret = SetAcquisitionMode(mode) - - Inputs: - mode - the acquisition mode.: - 1 - Single Scan - 2 - Accumulate - 3 - Kinetics - 4 - Fast Kinetics - 5 - Run till abort - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid. - - C++ Equiv: - unsigned int SetAcquisitionMode(int mode); - - See Also: - StartAcquisition - - Note: In Mode 5 the system uses a Run Till Abort acquisition mode. In Mode 5 only, the camera continually acquires data until the AbortAcquisitionAbortAcquisition function is called. By using the SetDriverEventSetDriverEvent function you will be notified as each acquisition is completed. - - ''' - cmode = c_int(mode) - ret = self.dll.SetAcquisitionMode(cmode) - return (ret) - - def SetAcquisitionType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetAcquisitionType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetAcquisitionType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetAcquisitionType(ctyp) - return (ret) - - def SetADChannel(self, channel): - ''' - Description: - This function will set the AD channel to one of the possible A-Ds of the system. This AD channel will be used for all subsequent operations performed by the system. - - Synopsis: - ret = SetADChannel(channel) - - Inputs: - channel - the channel to be used 0 to GetNumberADChannelsGetNumberADChannels-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AD channel set. - DRV_P1INVALID - Index is out of range. - - C++ Equiv: - unsigned int SetADChannel(int channel); - - See Also: - GetNumberADChannels - - ''' - cchannel = c_int(channel) - ret = self.dll.SetADChannel(cchannel) - return (ret) - - def SetAdvancedTriggerModeState(self, iState): - ''' - Description: - This function will set the state for the iCam functionality that some cameras are capable of. There may be some cases where we wish to prevent the software using the new functionality and just do it the way it was previously done. - - Synopsis: - ret = SetAdvancedTriggerModeState(iState) - - Inputs: - iState - 0: turn off iCam: - 1 - 1 Enable iCam. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - state invalid - - C++ Equiv: - unsigned int SetAdvancedTriggerModeState(int iState); - - See Also: - iCam - - Note: By default the advanced trigger functionality is enabled. - - ''' - ciState = c_int(iState) - ret = self.dll.SetAdvancedTriggerModeState(ciState) - return (ret) - - def SetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = SetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int SetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.SetBackground(byref(carr), csize) - return (ret, carr.value) - - def SetBaselineClamp(self, state): - ''' - Description: - This function turns on and off the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - ret = SetBaselineClamp(state) - - Inputs: - state - Enables/Disables Baseline clamp functionality: - 1 - Enable Baseline Clamp - 0 - Disable Baseline Clamp - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetBaselineClamp(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetBaselineClamp(cstate) - return (ret) - - def SetBaselineOffset(self, offset): - ''' - Description: - This function allows the user to move the baseline level by the amount selected. For example +100 will add approximately 100 counts to the default baseline value. The value entered should be a multiple of 100 between -1000 and +1000 inclusively. - - Synopsis: - ret = SetBaselineOffset(offset) - - Inputs: - offset - Amount to offset baseline by - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Baseline Clamp not available for this camera - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Offset out of range - - C++ Equiv: - unsigned int SetBaselineOffset(int offset); - - Note: Only available on iXon range - - ''' - coffset = c_int(offset) - ret = self.dll.SetBaselineOffset(coffset) - return (ret) - - def SetCameraLinkMode(self, mode): - ''' - Description: - This function allows the user to enable or disable the Camera Link functionality for the camera. Enabling this functionality will start to stream all acquired data through the camera link interface. - - Synopsis: - ret = SetCameraLinkMode(mode) - - Inputs: - mode - Enables/Disables Camera Link mode: - 1 - Enable Camera Link - 0 - Disable Camera Link - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - Camera Link not supported by this Camera - DRV_P1INVALID - Mode was not zero or one. - - C++ Equiv: - unsigned int SetCameraLinkMode(int mode); - - Note: Only available with iXon Ultra. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCameraLinkMode(cmode) - return (ret) - - def SetCameraStatusEnable(self, Enable): - ''' - Description: - Use this function to Mask out certain types of acquisition status events. The default is to notify on every type of event but this may cause missed events if different types of event occur very close together. The bits in the mask correspond to the following event types: - Use0 - Fire pulse down event - Use1 - Fire pulse up event - Set the corresponding bit to 0 to disable the event type and 1 to enable the event type. - - Synopsis: - ret = SetCameraStatusEnable(Enable) - - Inputs: - Enable - bitmask with bits set for those events about which you wish to be notified. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mask Set. - DRV_VXDNOTINSTALLED - Device Driver not installed. - - C++ Equiv: - unsigned int SetCameraStatusEnable(DWORD Enable); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: Only available with PCI systems using the CCI-23 controller card. - - Fire pulse up event not available on USB systems. - - - ''' - cEnable = (Enable) - ret = self.dll.SetCameraStatusEnable(cEnable) - return (ret) - - def SetChargeShifting(self, NumberRows, NumberRepeats): - ''' - Description: - Use this function in External Charge Shifting trigger mode to configure how many rows to shift and how many times for each frame of data. The number of repeats must be a multiple of 2. - - Synopsis: - ret = SetChargeShifting(NumberRows, NumberRepeats) - - Inputs: - NumberRows - number of rows to shift after each external trigger - NumberRepeats - number of times to shift rows - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Trigger mode not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of rows invalid. - DRV_P2INVALID - Number of repeats invalid. - - C++ Equiv: - unsigned int SetChargeShifting(unsigned int NumberRows, unsigned int NumberRepeats); - - See Also: - SetTriggerMode GetCapabilities - - Note: Only available with certain iKon-M systems. - - ''' - cNumberRows = c_uint(NumberRows) - cNumberRepeats = c_uint(NumberRepeats) - ret = self.dll.SetChargeShifting(cNumberRows, cNumberRepeats) - return (ret) - - def SetComplexImage(self, numAreas): - ''' - Description: - This is a function that allows the setting up of random tracks with more options that the SetRandomTracks function. - The minimum number of tracks is 1. The maximum number of tracks is the number of vertical pixels. - There is a further limit to the number of tracks that can be set due to memory constraints in the camera. It is not a fixed number but depends upon the combinations of the tracks. For example, 20 tracks of different heights will take up more memory than 20 tracks of the same height. - If attempting to set a series of random tracks and the return code equals DRV_RANDOM_TRACK_ERROR, change the makeup of the tracks to have more repeating heights and gaps so less memory is needed. - Each track must be defined by a group of six integers. - -The top and bottom positions of the tracks. - -The left and right positions for the area of interest within each track - -The horizontal and vertical binning for each track. - The positions of the tracks are validated to ensure that the tracks are in increasing order. - The left and right positions for each track must be the same. - For iXon the range is between 8 and CCD width, inclusive - For idus the range must be between 257 and CCD width, inclusive. - Horizontal binning must be an integer between 1 and 64 inclusive, for iXon. - Horizontal binning is not implementated for iDus and must be set to 1. - Vertical binning is used in the following way. A track of: - 1 10 1 1024 1 2 - is actually implemented as 5 tracks of height 2. . Note that a vertical binning of 1 will have the effect of vertically binning the entire track; otherwise vertical binning will operate as normal. - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 - - Synopsis: - (ret, areas) = SetComplexImage(numAreas) - - Inputs: - numAreas - int * areas: - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_RANDOM_TRACK_ERROR - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_ERROR_FILELOAD - Serious internal error - areas - - - C++ Equiv: - unsigned int SetComplexImage(int numAreas, int * areas); - - See Also: - SetRandomTracks - - Note: Only available with iXon+ and USB cameras. - - ''' - cnumAreas = c_int(numAreas) - careas = c_int() - ret = self.dll.SetComplexImage(cnumAreas, byref(careas)) - return (ret, careas.value) - - def SetCoolerMode(self, mode): - ''' - Description: - This function determines whether the cooler is switched off when the camera is shut down. - - Synopsis: - ret = SetCoolerMode(mode) - - Inputs: - mode - : - 0 - Returns to ambient temperature on ShutDown - 1 - Temperature is maintained on ShutDown - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - DRV_NOT_SUPPORTED - Camera does not support - - C++ Equiv: - unsigned int SetCoolerMode(int mode); - - Note: Mode 0 not available on Luca R cameras always cooled to -20C. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCoolerMode(cmode) - return (ret) - - def SetCountConvertMode(self, Mode): - ''' - Description: - This function configures the Count Convert mode. - - Synopsis: - ret = SetCountConvertMode(Mode) - - Inputs: - Mode - : - 0 - Data in Counts - 1 - Data in Electrons - 2 - Data in Photons - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Count Convert not available for this camera - DRV_NOT_AVAILABLE - Count Convert mode not available with current settings - DRV_P1INVALID - Mode parameter was out of range. - - C++ Equiv: - unsigned int SetCountConvertMode(int Mode); - - See Also: - GetCapabilities SetCountConvertWavelength - - Note: Only available on Clara, iXon 3 and iXon Ultra. - - Modes 1 and 2 are only available when: - * Baseline Clamp active - * Isolated crop mode off - * EM gain must be greater than or equal to 10 and the lowest pre-amp not be selected - * For Clara systems the extended infra red mode can not be used - - - ''' - cMode = c_int(Mode) - ret = self.dll.SetCountConvertMode(cMode) - return (ret) - - def SetCountConvertWavelength(self, wavelength): - ''' - Description: - This function configures the wavelength used in Count Convert mode. - - Synopsis: - ret = SetCountConvertWavelength(wavelength) - - Inputs: - wavelength - wavelength used to determine QE - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Count Convert not available for this camera - DRV_P1INVALID - Wavelength value was out of range. - - C++ Equiv: - unsigned int SetCountConvertWavelength(float wavelength); - - See Also: - GetCapabilities SetCountConvertMode - - ''' - cwavelength = c_float(wavelength) - ret = self.dll.SetCountConvertWavelength(cwavelength) - return (ret) - - def SetCropMode(self, active, cropHeight, reserved): - ''' - Description: - This function effectively reduces the height of the CCD by excluding some rows to achieve higher frame rates. This is currently only available on Newton cameras when the selected read mode is Full Vertical Binning. The cropHeight is the number of active rows measured from the bottom of the CCD. - Note: it is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetCropMode(active, cropHeight, reserved) - - Inputs: - active - Crop mode active: - 0 - Crop mode is OFF - 1 - Crop mode if ON - cropHeight - The selected crop height. This value must be between 1 and the CCD: - height - int reserved: This value should be set to 0. - reserved - This value should be set to 0 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIAILIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Active parameter is not zero or one. - DRV_P2INVALID - Cropheight parameter is less than one or greater than the CCD height. - DRV_P3INVALID - Reserved parameter is not equal to zero. - DRV_NOT_SUPPORTED - Either the camera is not a Newton or the read mode is not Full Vertical Binning. - - C++ Equiv: - unsigned int SetCropMode(int active, int cropHeight, int reserved); - - See Also: - GetDetector SetIsolatedCropMode - - Note: Available on Newton - - ''' - cactive = c_int(active) - ccropHeight = c_int(cropHeight) - creserved = c_int(reserved) - ret = self.dll.SetCropMode(cactive, ccropHeight, creserved) - return (ret) - - def SetCurrentCamera(self, cameraHandle): - ''' - Description: - When multiple Andor cameras are installed this function allows the user to select which camera is currently active. Once a camera has been selected the other functions can be called as normal but they will only apply to the selected camera. If only 1 camera is installed calling this function is not required since that camera will be selected by default. - - Synopsis: - ret = SetCurrentCamera(cameraHandle) - - Inputs: - cameraHandle - Selects the active camera - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera successfully selected. - DRV_P1INVALID - Invalid camera handle. - - C++ Equiv: - unsigned int SetCurrentCamera(long cameraHandle); - - See Also: - GetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.SetCurrentCamera(ccameraHandle) - return (ret) - - def SetCustomTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning value to be used when the readout mode is set to Random Track. - - Synopsis: - ret = SetCustomTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetCustomTrackHBin(int bin); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cbin = c_int(bin) - ret = self.dll.SetCustomTrackHBin(cbin) - return (ret) - - def SetDACOutput(self, iOption, iResolution, iValue): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to set the required voltage. - - Synopsis: - ret = SetDACOutput(iOption, iResolution, iValue) - - Inputs: - iOption - DAC Output DAC Pin 1 or 2 (1/2). - iResolution - resolution of DAC can be set from 2 to 16-bit in steps of 2 - iValue - requested DAC value (for particular resolution) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available. - DRV_P1INVALID - DAC range value invalid. - DRV_P2INVALID - Resolution unavailable. - DRV_P3INVALID - Requested value not within DAC range. - - C++ Equiv: - unsigned int SetDACOutput(int iOption, int iResolution, int iValue); - - See Also: - SetDACOutputScale - - Note: Only available on Andor Clara - - ''' - ciOption = c_int(iOption) - ciResolution = c_int(iResolution) - ciValue = c_int(iValue) - ret = self.dll.SetDACOutput(ciOption, ciResolution, ciValue) - return (ret) - - def SetDACOutputScale(self, iScale): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to select the active one. - - Synopsis: - ret = SetDACOutputScale(iScale) - - Inputs: - iScale - 5 or 10 volt DAC range (1/2). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available - DRV_P1INVALID - DAC Scale value invalid. - - C++ Equiv: - unsigned int SetDACOutputScale(int iScale); - - See Also: - SetDACOutput - - Note: Only available on Andor Clara - - ''' - ciScale = c_int(iScale) - ret = self.dll.SetDACOutputScale(ciScale) - return (ret) - - def SetDataType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDataType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDataType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetDataType(ctyp) - return (ret) - - def SetDDGAddress(self, t0, t1, t2, t3, address): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGAddress(t0, t1, t2, t3, address) - - Inputs: - t0 - - t1 - - t2 - - t3 - - address - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGAddress(BYTE t0, BYTE t1, BYTE t2, BYTE t3, BYTE address); - - ''' - ct0 = c_ubyte(t0) - ct1 = c_ubyte(t1) - ct2 = c_ubyte(t2) - ct3 = c_ubyte(t3) - caddress = c_ubyte(address) - ret = self.dll.SetDDGAddress(ct0, ct1, ct2, ct3, caddress) - return (ret) - - def SetDDGExternalOutputEnabled(self, uiIndex, uiEnabled): - ''' - Description: - This function sets the state of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputPolarity(self, uiIndex, uiPolarity): - ''' - Description: - This function sets the polarity of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputPolarity(uiIndex, uiPolarity) - - Inputs: - uiIndex - index of external output. - uiPolarity - polarity of external output (0 - Positive,1 - Negative). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 uiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputPolarity - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiPolarity = c_uint(uiPolarity) - ret = self.dll.SetDDGExternalOutputPolarity(cuiIndex, cuiPolarity) - return (ret) - - def SetDDGExternalOutputStepEnabled(self, uiIndex, uiEnabled): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to set the state of this option. - - Synopsis: - ret = SetDDGExternalOutputStepEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output track step (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputStepEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputStepEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputTime(self, uiIndex, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the timings for a particular external output. - - Synopsis: - ret = SetDDGExternalOutputTime(uiIndex, uiDelay, uiWidth) - - Inputs: - uiIndex - index of external output. - uiDelay - external output delay time in picoseconds. - uiWidth - external output width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGExternalOutputTime(at_u32 uiIndex, at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputTime - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGExternalOutputTime(cuiIndex, cuiDelay, cuiWidth) - return (ret) - - def SetDDGGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetDDGGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetDDGGain(cgain) - return (ret) - - def SetDDGGateStep(self, step): - ''' - Description: - This function will set a constant value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGGateStep(step) - - Inputs: - step - gate step in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step invalid. - - C++ Equiv: - unsigned int SetDDGGateStep(double step); - - See Also: - SetDDGTimes SetDDGVariableGateStep - - Note: Available on iStar. - - ''' - cstep = c_double(step) - ret = self.dll.SetDDGGateStep(cstep) - return (ret) - - def SetDDGGateTime(self, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the gate timings for a USB iStar. - - Synopsis: - ret = SetDDGGateTime(uiDelay, uiWidth) - - Inputs: - uiDelay - gate delay time in picoseconds. - uiWidth - gate width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGGateTime(at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGGateTime - - ''' - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGGateTime(cuiDelay, cuiWidth) - return (ret) - - def SetDDGInsertionDelay(self, state): - ''' - Description: - This function controls the length of the insertion delay. - - Synopsis: - ret = SetDDGInsertionDelay(state) - - Inputs: - state - NORMAL/FAST switch for insertion delay.: - 0 - to set normal insertion delay. - 1 - to set fast insertion delay. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for delay accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGInsertionDelay(int state); - - See Also: - GetCapabilities SetDDGIntelligate - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGInsertionDelay(cstate) - return (ret) - - def SetDDGIntelligate(self, state): - ''' - Description: - This function controls the MCP gating. Not available when the fast insertion delay option is selected. - - Synopsis: - ret = SetDDGIntelligate(state) - - Inputs: - state - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIntelligate(int state); - - See Also: - GetCapabilities SetDDGInsertionDelay - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIntelligate(cstate) - return (ret) - - def SetDDGIOC(self, state): - ''' - Description: - This function activates the integrate on chip (IOC) option. - - Synopsis: - ret = SetDDGIOC(state) - - Inputs: - state - ON/OFF switch for the IOC option.: - 0 - to switch IOC OFF. - 1 - to switch IOC ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIOC(int state); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIOC(cstate) - return (ret) - - def SetDDGIOCFrequency(self, frequency): - ''' - Description: - This function sets the frequency of the integrate on chip option. It should be called once the conditions of the experiment have been setup in order for correct operation. The frequency should be limited to 5000Hz when intelligate is activated to prevent damage to the head and 50000Hz otherwise to prevent the gater from overheating. The recommended order is - ... - Experiment setup (exposure time, readout mode, gate parameters, ...) - ... - SetDDGIOCFrequency (x) - SetDDGIOCSetDDGIOC(true) - GetDDGIOCPulses(y) - StartAcquisitionStartAcquisition() - - Synopsis: - ret = SetDDGIOCFrequency(frequency) - - Inputs: - frequency - frequency of IOC option in Hz. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for frequency accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetDDGIOCFrequency(double frequency); - - See Also: - GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cfrequency = c_double(frequency) - ret = self.dll.SetDDGIOCFrequency(cfrequency) - return (ret) - - def SetDDGIOCNumber(self, numberPulses): - ''' - Description: - This function allows the user to limit the number of pulses used in the integrate on chip option at a given frequency. It should be called once the conditions of the experiment have been setup in order for correct operation. - - Synopsis: - ret = SetDDGIOCNumber(numberPulses) - - Inputs: - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for IOC number accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - IOC not supported - DRV_ERROR_ACK - Unable to communicate with card - - C++ Equiv: - unsigned int SetDDGIOCNumber(long numberPulses); - - See Also: - SetDDGIOCFrequency GetDDGIOCFrequency GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cnumberPulses = c_int(numberPulses) - ret = self.dll.SetDDGIOCNumber(cnumberPulses) - return (ret) - - def SetDDGIOCPeriod(self, period): - ''' - Description: - This function can be used to set the IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - ret = SetDDGIOCPeriod(period) - - Inputs: - period - the period of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid period. - - C++ Equiv: - unsigned int SetDDGIOCPeriod(at_u64 period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency GetDDGIOCPeriod - - ''' - cperiod = c_ulonglong(period) - ret = self.dll.SetDDGIOCPeriod(cperiod) - return (ret) - - def SetDDGIOCTrigger(self, trigger): - ''' - Description: - This function can be used to select whether to trigger the IOC pulse train with either the rising edge of the fire pulse or an externally supplied trigger. - - Synopsis: - ret = SetDDGIOCTrigger(trigger) - - Inputs: - trigger - IOC Trigger Option: - 0 - Fire pulse - 1 - External Trigger - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC trigger set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid trigger. - - C++ Equiv: - unsigned int SetDDGIOCTrigger(at_u32 trigger); - - See Also: - GetCapabilities GetDDGIOCTrigger SetDDGIOC SetTriggerMode - - ''' - ctrigger = c_uint(trigger) - ret = self.dll.SetDDGIOCTrigger(ctrigger) - return (ret) - - def SetDDGLiteControlByte(self, channel, control): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - ret = SetDDGLiteControlByte(channel, control) - - Inputs: - channel - - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteControlByte(AT_DDGLiteChannelId channel, char control); - - ''' - cchannel = (channel) - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteControlByte(cchannel, ccontrol) - return (ret) - - def SetDDGLiteGlobalControlByte(self, control): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteGlobalControlByte(control) - - Inputs: - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteGlobalControlByte(char control); - - ''' - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteGlobalControlByte(ccontrol) - return (ret) - - def SetDDGLiteInitialDelay(self, channel, fDelay): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteInitialDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInitialDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLiteInterPulseDelay(self, channel, fDelay): - ''' - Description: - - - Synopsis: - ret = SetDDGLiteInterPulseDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInterPulseDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLitePulsesPerExposure(self, channel, ui32Pulses): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulsesPerExposure(channel, ui32Pulses) - - Inputs: - channel - - ui32Pulses - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint(ui32Pulses) - ret = self.dll.SetDDGLitePulsesPerExposure(cchannel, cui32Pulses) - return (ret) - - def SetDDGLitePulseWidth(self, channel, fWidth): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulseWidth(channel, fWidth) - - Inputs: - channel - - fWidth - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float(fWidth) - ret = self.dll.SetDDGLitePulseWidth(cchannel, cfWidth) - return (ret) - - def SetDDGOpticalWidthEnabled(self, uiEnabled): - ''' - Description: - This function can be used to configure a system to use optical gate width. - - Synopsis: - ret = SetDDGOpticalWidthEnabled(uiEnabled) - - Inputs: - uiEnabled - optical gate width option (0 - Off, 1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGOpticalWidthEnabled(at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth GetDDGOpticalWidthEnabled - - ''' - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGOpticalWidthEnabled(cuiEnabled) - return (ret) - - def SetDDGStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - StartAcquisition SetDDGStepMode GetDDGStepMode GetDDGStepCoefficients - - Note: Available on iStar and USB iStar. - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGStepMode(self, mode): - ''' - Description: - This function will set the current gate step mode. - - Synopsis: - ret = SetDDGStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGStepMode(at_u32 mode); - - See Also: - StartAcquisition GetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGStepMode(cmode) - return (ret) - - def SetDDGTimes(self, t0, t1, t2): - ''' - Description: - This function sets the properties of the gate pulse. t0 has a resolution of 16 nanoseconds whilst t1 and t2 have a resolution of 25 picoseconds. - - Synopsis: - ret = SetDDGTimes(t0, t1, t2) - - Inputs: - t0 - output A delay in nanoseconds. - t1 - gate delay in picoseconds. - t2 - pulse width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Values for gate pulse accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid output A delay. - DRV_P2INVALID - Invalid gate delay. - DRV_P3INVALID - Invalid pulse width. - - C++ Equiv: - unsigned int SetDDGTimes(double t0, double t1, double t2); - - See Also: - SetDDGGateStep - - Note: Available on iStar. - - ''' - ct0 = c_double(t0) - ct1 = c_double(t1) - ct2 = c_double(t2) - ret = self.dll.SetDDGTimes(ct0, ct1, ct2) - return (ret) - - def SetDDGTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode of the internal delay generator to either internal or External - - Synopsis: - ret = SetDDGTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetDDGTriggerMode(int mode); - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - ret = self.dll.SetDDGTriggerMode(cmode) - return (ret) - - def SetDDGVariableGateStep(self, mode, p1, p2): - ''' - Description: - This function will set a varying value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGVariableGateStep(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 1 - Exponential (p1*exp(p2*n)) - 2 - Logarithmic (p1*log(p2*n)) - 3 - Linear (p1 + p2*n) - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGVariableGateStep(int mode, double p1, double p2); - - See Also: - StartAcquisition - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGVariableGateStep(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate width step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGWidthStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - - n = 1, 2, ..., number in kinetic series - p1 - The first coefficient - p2 - The second coefficient - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGWidthStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - SetDDGWidthStepMode GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGWidthStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepMode(self, mode): - ''' - Description: - This function will set the current gate width step mode. - - Synopsis: - ret = SetDDGWidthStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGWidthStepMode(at_u32 mode); - - See Also: - SetDDGWidthStepCoefficients GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGWidthStepMode(cmode) - return (ret) - - def SetDelayGenerator(self, board, address, typ): - ''' - Description: - This function sets parameters to control the delay generator through the GPIB card in your computer. - - Synopsis: - ret = SetDelayGenerator(board, address, typ) - - Inputs: - board - The GPIB board number of the card used to interface with the Delay Generator.: - short - address: The number that allows the GPIB board to identify and send commands to the delay generator. - address - The number that allows the GPIB board to identify and send commands to the delay generator. - - typ - The type of your Delay Generator. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Delay Generator set up. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - GPIB board invalid. - DRV_P2INVALID - GPIB address invalid - DRV_P3INVALID - Delay generator type invalid. - - C++ Equiv: - unsigned int SetDelayGenerator(int board, short address, int typ); - - See Also: - SetGate - - Note: Available on ICCD. - - ''' - cboard = c_int(board) - caddress = c_short(address) - ctyp = c_int(typ) - ret = self.dll.SetDelayGenerator(cboard, caddress, ctyp) - return (ret) - - def SetDMAParameters(self, MaxImagesPerDMA, SecondsPerDMA): - ''' - Description: - In order to facilitate high image readout rates the controller card may wait for multiple images to be acquired before notifying the SDK that new data is available. Without this facility, there is a chance that hardware interrupts may be lost as the operating system does not have enough time to respond to each interrupt. The drawback to this is that you will not get the data for an image until all images for that interrupt have been acquired. - There are 3 settings involved in determining how many images will be acquired for each notification (DMA interrupt) of the controller card and they are as follows: - 1. The size of the DMA buffer gives an upper limit on the number of images that can be stored within it and is usually set to the size of one full image when installing the software. This will usually mean that if you acquire full frames there will never be more than one image per DMA. - 2. A second setting that is used is the minimum amount of time (SecondsPerDMA) that should expire between interrupts. This can be used to give an indication of the reponsiveness of the operating system to interrupts. Decreasing this value will allow more interrupts per second and should only be done for faster pcs. The default value is 0.03s (30ms), finding the optimal value for your pc can only be done through experimentation. - 3. The third setting is an overide to the number of images calculated using the previous settings. If the number of images per dma is calculated to be greater than MaxImagesPerDMA then it will be reduced to MaxImagesPerDMA. This can be used to, for example, ensure that there is never more than 1 image per DMA by setting MaxImagesPerDMA to 1. Setting MaxImagesPerDMA to zero removes this limit. Care should be taken when modifying these parameters as missed interrupts may prevent the acquisition from completing. - - Synopsis: - ret = SetDMAParameters(MaxImagesPerDMA, SecondsPerDMA) - - Inputs: - MaxImagesPerDMA - Override to the number of images per DMA if the calculated value is higher than this. (Default=0, ie. no override) - SecondsPerDMA - Minimum amount of time to elapse between interrrupts. (Default=0.03s) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DMA Parameters setup successfully. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - MaxImagesPerDMA invalid - DRV_P2INVALID - SecondsPerDMA invalid - - C++ Equiv: - unsigned int SetDMAParameters(int MaxImagesPerDMA, float SecondsPerDMA); - - ''' - cMaxImagesPerDMA = c_int(MaxImagesPerDMA) - cSecondsPerDMA = c_float(SecondsPerDMA) - ret = self.dll.SetDMAParameters(cMaxImagesPerDMA, cSecondsPerDMA) - return (ret) - - def SetDriverEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the SDK via which the the user software can be informed that something has occurred. For example the SDK can set the event when an acquisition has completed thus relieving the user code of having to continually pole to check on the status of the acquisition. - The event will be set under the follow conditions: - 1) Acquisition completed or aborted. - 2) As each scan during an acquisition is completed. - 3) Temperature as stabilized, drifted from stabilization or could not be reached. - When an event is triggered the user software can then use other SDK functions to determine what actually happened. - Condition 1 and 2 can be tested via GetStatusGetStatus function, while condition 3 checked via GetTemperatureGetTemperature function. - You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetDriverEvent with NULL as the parameter. - - Synopsis: - ret = SetDriverEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetDriverEvent(HANDLE driverEvent); - - See Also: - GetStatus GetTemperature GetAcquisitionProgress - - Note: Not all programming environments allow the use of multiple threads and WIN32 events. - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetDriverEvent(cdriverEvent) - return (ret) - - def SetDualExposureMode(self, mode): - ''' - Description: - This function turns on and off the option to acquire 2 frames for each external trigger pulse. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureMode(mode) - - Inputs: - mode - Enables/Disables dual exposure mode: - 1 - Enable mode - 0 - Disable mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode parameter was not zero or one. - - C++ Equiv: - unsigned int SetDualExposureMode(int mode); - - See Also: - GetCapabilities SetDualExposureTimes GetDualExposureTimes - - ''' - cmode = c_int(mode) - ret = self.dll.SetDualExposureMode(cmode) - return (ret) - - def SetDualExposureTimes(self, expTime1, expTime2): - ''' - Description: - This function configures the two exposure times used in dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureTimes(expTime1, expTime2) - - Inputs: - expTime1 - the exposure time in seconds for each odd numbered frame. - expTime2 - the exposure time in seconds for each even numbered frame. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - First exposure out of range. - DRV_P2INVALID - Second exposure out of range. - - C++ Equiv: - unsigned int SetDualExposureTimes(float expTime1, float expTime2); - - See Also: - GetCapabilities SetDualExposureMode GetDualExposureTimes - - ''' - cexpTime1 = c_float(expTime1) - cexpTime2 = c_float(expTime2) - ret = self.dll.SetDualExposureTimes(cexpTime1, cexpTime2) - return (ret) - - def SetEMAdvanced(self, state): - ''' - Description: - This function turns on and off access to higher EM gain levels within the SDK. Typically, optimal signal to noise ratio and dynamic range is achieved between x1 to x300 EM Gain. Higher gains of > x300 are recommended for single photon counting only. Before using higher levels, you should ensure that light levels do not exceed the regime of tens of photons per pixel, otherwise accelerated ageing of the sensor can occur. - - Synopsis: - ret = SetEMAdvanced(state) - - Inputs: - state - Enables/Disables access to higher EM gain levels: - 1 - Enable access - 1 - Disable access - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Advanced EM gain not available for this camera. - DRV_ACQUIRING. - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetEMAdvanced(int state); - - See Also: - GetCapabilities GetEMCCDGain SetEMCCDGain SetEMGainMode - - ''' - cstate = c_int(state) - ret = self.dll.SetEMAdvanced(cstate) - return (ret) - - def SetEMCCDGain(self, gain): - ''' - Description: - Allows the user to change the gain value. The valid range for the gain depends on what gain mode the camera is operating in. See SetEMGainMode to set the mode and GetEMGainRange to get the valid range to work with. To access higher gain values (>x300) see SetEMAdvanced. - - Synopsis: - ret = SetEMCCDGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetEMCCDGain(int gain); - - See Also: - GetEMCCDGain SetEMGainMode GetEMGainRange SetEMAdvanced - - Note: Only available on EMCCD sensor systems. - - ''' - cgain = c_int(gain) - ret = self.dll.SetEMCCDGain(cgain) - return (ret) - - def SetEMClockCompensation(self, EMClockCompensationFlag): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetEMClockCompensation(EMClockCompensationFlag) - - Inputs: - EMClockCompensationFlag - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetEMClockCompensation(int EMClockCompensationFlag); - - ''' - cEMClockCompensationFlag = c_int(EMClockCompensationFlag) - ret = self.dll.SetEMClockCompensation(cEMClockCompensationFlag) - return (ret) - - def SetEMGainMode(self, mode): - ''' - Description: - Set the EM Gain mode to one of the following possible settings. - Mode 0: The EM Gain is controlled by DAC settings in the range 0-255. Default mode. - 1: The EM Gain is controlled by DAC settings in the range 0-4095. - 2: Linear mode. - 3: Real EM gain - To access higher gain values (if available) it is necessary to enable advanced EM gain, see SetEMAdvanced. - - Synopsis: - ret = SetEMGainMode(mode) - - Inputs: - mode - EM Gain mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - EM Gain mode invalid. - - C++ Equiv: - unsigned int SetEMGainMode(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetEMGainMode(cmode) - return (ret) - - def SetExposureTime(self, time): - ''' - Description: - This function will set the exposure time to the nearest valid value not less than the given value. The actual exposure time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetExposureTime(time) - - Inputs: - time - the exposure time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Exposure time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure Time invalid. - - C++ Equiv: - unsigned int SetExposureTime(float time); - - See Also: - GetAcquisitionTimings - - Note: For Classics, if the current acquisition mode is Single-Track, Multi-Track or Image then this function will actually set the Shutter Time. The actual exposure time used is obtained from the GetAcquisitionTimings functionGetAcquisitionTimings. - - ''' - ctime = c_float(time) - ret = self.dll.SetExposureTime(ctime) - return (ret) - - def SetExternalTriggerTermination(self, uiTermination): - ''' - Description: - This function can be used to set the external trigger termination mode. - - Synopsis: - ret = SetExternalTriggerTermination(uiTermination) - - Inputs: - uiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetExternalTriggerTermination(at_u32 uiTermination); - - See Also: - GetCapabilities GetExternalTriggerTermination - - ''' - cuiTermination = c_uint(uiTermination) - ret = self.dll.SetExternalTriggerTermination(cuiTermination) - return (ret) - - def SetFanMode(self, mode): - ''' - Description: - Allows the user to control the mode of the camera fan. If the system is cooled, the fan should only be turned off for short periods of time. During this time the body of the camera will warm up which could compromise cooling capabilities. - If the camera body reaches too high a temperature, depends on camera, the buzzer will sound. If this happens, turn off the external power supply and allow the system to stabilize before continuing. - - Synopsis: - ret = SetFanMode(mode) - - Inputs: - mode - Fan mode setting: - 0 - Fan on full. - 1 - Fan on low. - 2 - Fan off, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Mode value invalid. - - C++ Equiv: - unsigned int SetFanMode(int mode); - - See Also: - GetCapabilities - - ''' - cmode = c_int(mode) - ret = self.dll.SetFanMode(cmode) - return (ret) - - def SetFastExtTrigger(self, mode): - ''' - Description: - This function will enable fast external triggering. When fast external triggering is enabled the system will NOT wait until a Keep Clean cycle has been completed before accepting the next trigger. This setting will only have an effect if the trigger mode has been set to External via SetTriggerMode. - - Synopsis: - ret = SetFastExtTrigger(mode) - - Inputs: - mode - 0 Disabled: - 1 - Enabled - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters accepted. - - C++ Equiv: - unsigned int SetFastExtTrigger(int mode); - - See Also: - SetTriggerMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFastExtTrigger(cmode) - return (ret) - - def SetFastKinetics(self, exposedRows, seriesLength, time, mode, hbin, vbin): - ''' - Description: - This function will set the parameters to be used when taking a fast kinetics acquisition. - - Synopsis: - ret = SetFastKinetics(exposedRows, seriesLength, time, mode, hbin, vbin) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System not initialized. - DRV_NOT_INITIALIZED - Acquisition in progress. - DRV_ACQUIRING - Invalid height. - DRV_P1INVALID - Invalid number in series. - DRV_P2INVALID DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID DRV_P5INVALID - Mode must be equal to 0 or 4. - DRV_P6INVALID - Horizontal binning. - All parameters accepted. - Vertical binning. - - C++ Equiv: - unsigned int SetFastKinetics(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin); - - See Also: - SetFKVShiftSpeed SetFastKineticsEx SetFKVShiftSpeed - - Note: For classic cameras the vertical and horizontal binning must be 1 - For non classic cameras it is recommended that you use SetFastKineticsEx - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFastKinetics(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin) - return (ret) - - def SetFastKineticsEx(self, exposedRows, seriesLength, time, mode, hbin, vbin, offset): - ''' - Description: - This function is the same as SetFastKinetics with the addition of an Offset parameter, which will inform the SDK of the first row to be used. - - Synopsis: - ret = SetFastKineticsEx(exposedRows, seriesLength, time, mode, hbin, vbin, offset) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - offset - offset of first row to be used in Fast Kinetics from the bottom of the CCD. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid height. - DRV_P2INVALID - Invalid number in series. - DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID - Mode must be equal to 0 or 4. - DRV_P5INVALID - Horizontal binning. - DRV_P6INVALID - Vertical binning. - DRV_P7INVALID - Offset not within CCD limits - - C++ Equiv: - unsigned int SetFastKineticsEx(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin, int offset); - - See Also: - SetFKVShiftSpeed SetFastKinetics SetFKVShiftSpeed - - Note: For classic cameras the offset must be 0 and the vertical and horizontal binning must be 1 - For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - coffset = c_int(offset) - ret = self.dll.SetFastKineticsEx(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin, coffset) - return (ret) - - def SetFilterMode(self, mode): - ''' - Description: - This function will set the state of the cosmic ray filter mode for future acquisitions. If the filter mode is on, consecutive scans in an accumulation will be compared and any cosmic ray-like features that are only present in one scan will be replaced with a scaled version of the corresponding pixel value in the correct scan. - - Synopsis: - ret = SetFilterMode(mode) - - Inputs: - mode - current state of filter: - 0 - OFF - 2 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is out off range. - - C++ Equiv: - unsigned int SetFilterMode(int mode); - - See Also: - GetFilterMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFilterMode(cmode) - return (ret) - - def SetFilterParameters(self, width, sensitivity, range, accept, smooth, noise): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFilterParameters(width, sensitivity, range, accept, smooth, noise) - - Inputs: - width - - sensitivity - - range - - accept - - smooth - - noise - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFilterParameters(int width, float sensitivity, int range, float accept, int smooth, int noise); - - ''' - cwidth = c_int(width) - csensitivity = c_float(sensitivity) - crange = c_int(range) - caccept = c_float(accept) - csmooth = c_int(smooth) - cnoise = c_int(noise) - ret = self.dll.SetFilterParameters(cwidth, csensitivity, crange, caccept, csmooth, cnoise) - return (ret) - - def SetFKVShiftSpeed(self, index): - ''' - Description: - This function will set the fast kinetics vertical shift speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetFKVShiftSpeed(index) - - Inputs: - index - the speed to be used: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Fast kinetics vertical shift speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetFKVShiftSpeed(int index); - - See Also: - GetNumberFKVShiftSpeeds GetFKVShiftSpeedF - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - ret = self.dll.SetFKVShiftSpeed(cindex) - return (ret) - - def SetFPDP(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFPDP(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFPDP(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetFPDP(cstate) - return (ret) - - def SetFrameTransferMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Frame Transfer Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetFrameTransferMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame transfer mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetFrameTransferMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is a Frame Transfer chip. - - ''' - cmode = c_int(mode) - ret = self.dll.SetFrameTransferMode(cmode) - return (ret) - - def SetFrontEndEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the Front End cooler has overheated or returned to a normal state. To determine what event has actually occurred call the GetFrontEndStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetFrontEndEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetFrontEndEvent(at_32 driverEvent); - - See Also: - GetFrontEndStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetFrontEndEvent(cdriverEvent) - return (ret) - - def SetFullImage(self, hbin, vbin): - ''' - Description: - Deprecated see Note: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetFullImage(hbin, vbin) - - Inputs: - hbin - number of pixels to bin horizontally - vbin - number of pixels to bin vertically - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning parameters accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Horizontal binning parameter invalid - DRV_P2INVALID - Vertical binning parameter invalid - - C++ Equiv: - unsigned int SetFullImage(int hbin, int vbin); // deprecated - - See Also: - SetReadMode - - Note: Deprecated by SetImageGetNumberHSSpeeds - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFullImage(chbin, cvbin) - return (ret) - - def SetFVBHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Full Vertical Binned read mode. - - Synopsis: - ret = SetFVBHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetFVBHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetFVBHBin(cbin) - return (ret) - - def SetGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetGain(cgain) - return (ret) - - def SetGate(self, delay, width, stepRenamed): - ''' - Description: - This function sets the Gater parameters for an ICCD system. The image intensifier of the Andor ICCD acts as a shutter on nanosecond time-scales using a process known as gating. - - Synopsis: - ret = SetGate(delay, width, stepRenamed) - - Inputs: - delay - Sets the delay(>=0) between the T0 and C outputs on the SRS box to delay nanoseconds. - width - Sets the width(>=0) of the gate in nanoseconds - stepRenamed - Sets the amount(<>0, in nanoseconds) by which the gate position is moved in time after each scan in a kinetic series. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gater parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_GPIBERROR - Error communicating with GPIB card. - DRV_P1INVALID - Invalid delay - DRV_P2INVALID - Invalid width. - DRV_P3INVALID - Invalid step. - - C++ Equiv: - unsigned int SetGate(float delay, float width, float stepRenamed); - - See Also: - SetDelayGenerator - - Note: Available on ICCD. - - ''' - cdelay = c_float(delay) - cwidth = c_float(width) - cstepRenamed = c_float(stepRenamed) - ret = self.dll.SetGate(cdelay, cwidth, cstepRenamed) - return (ret) - - def SetGateMode(self, gatemode): - ''' - Description: - Allows the user to control the photocathode gating mode. - - Synopsis: - ret = SetGateMode(gatemode) - - Inputs: - gatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gating mode invalid. - - C++ Equiv: - unsigned int SetGateMode(int gatemode); - - See Also: - GetCapabilities SetMCPGain SetMCPGating - - ''' - cgatemode = c_int(gatemode) - ret = self.dll.SetGateMode(cgatemode) - return (ret) - - def SetHighCapacity(self, state): - ''' - Description: - This function switches between high sensitivity and high capacity functionality. With high capacity enabled the output amplifier is switched to a mode of operation which reduces the responsivity thus allowing the reading of larger charge packets during binning operations. - - Synopsis: - ret = SetHighCapacity(state) - - Inputs: - state - Enables/Disables High Capacity functionality: - 1 - Enable High Capacity (Disable High Sensitivity) - 0 - Disable High Capacity (Enable High Sensitivity) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetHighCapacity(int state); - - See Also: - GetCapabilities - - ''' - cstate = c_int(state) - ret = self.dll.SetHighCapacity(cstate) - return (ret) - - def SetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the horizontal speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetHorizontalSpeed(index) - - Inputs: - index - the horizontal speed to be used: - 0 - to GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHorizontalSpeed(int index); // deprecated - - See Also: - GetNumberHorizontalSpeeds GetHorizontalSpeed - - Note: Deprecated by SetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - ret = self.dll.SetHorizontalSpeed(cindex) - return (ret) - - def SetHSSpeed(self, typ, index): - ''' - Description: - This function will set the speed at which the pixels are shifted into the output node during the readout phase of an acquisition. Typically your camera will be capable of operating at several horizontal shift speeds. To get the actual speed that an index corresponds to use the GetHSSpeed function. Ensure the desired A/D channel has been set with SetADChannel before calling SetHSSpeed. - - Synopsis: - ret = SetHSSpeed(typ, index) - - Inputs: - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR mode(clara). - index - the horizontal speed to be used: - 0 - to GetNumberHSSpeeds()GetNumberHSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is invalid. - DRV_P2INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHSSpeed(int typ, int index); - - See Also: - GetNumberHSSpeeds GetHSSpeed GetNumberAmp - - ''' - ctyp = c_int(typ) - cindex = c_int(index) - ret = self.dll.SetHSSpeed(ctyp, cindex) - return (ret) - - def SetImage(self, hbin, vbin, hstart, hend, vstart, vend): - ''' - Description: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetImage(hbin, vbin, hstart, hend, vstart, vend) - - Inputs: - hbin - number of pixels to bin horizontally. - vbin - number of pixels to bin vertically. - hstart - Start column (inclusive). - hend - End column (inclusive). - vstart - Start row (inclusive). - vend - End row (inclusive). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Binning parameters invalid. - DRV_P2INVALID - Binning parameters invalid. - DRV_P3INVALID - Sub-area co-ordinate is invalid. - DRV_P4INVALID - Sub-area co-ordinate is invalid. - DRV_P5INVALID - Sub-area co-ordinate is invalid. - DRV_P6INVALID - Sub-area co-ordinate is invalid. - - C++ Equiv: - unsigned int SetImage(int hbin, int vbin, int hstart, int hend, int vstart, int vend); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - chstart = c_int(hstart) - chend = c_int(hend) - cvstart = c_int(vstart) - cvend = c_int(vend) - ret = self.dll.SetImage(chbin, cvbin, chstart, chend, cvstart, cvend) - return (ret) - - def SetImageFlip(self, iHFlip, iVFlip): - ''' - Description: - This function will cause data output from the SDK to be flipped on one or both axes. This flip is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If flipping could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageFlip(iHFlip, iVFlip) - - Inputs: - iHFlip - Sets horizontal flipping. - iVFlip - Sets vertical flipping..: - 1 - Enables Flipping - 0 - Disables Flipping - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - - C++ Equiv: - unsigned int SetImageFlip(int iHFlip, int iVFlip); - - See Also: - SetImageRotate - - Note: If this function is used in conjunction with the SetImageRotate function the rotation will occur before the flip regardless of which order the functions are called. - - ''' - ciHFlip = c_int(iHFlip) - ciVFlip = c_int(iVFlip) - ret = self.dll.SetImageFlip(ciHFlip, ciVFlip) - return (ret) - - def SetImageRotate(self, iRotate): - ''' - Description: - This function will cause data output from the SDK to be rotated on one or both axes. This rotate is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If the rotation could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageRotate(iRotate) - - Inputs: - iRotate - Rotation setting: - 0 - No rotation. - 1 - Rotate 90 degrees clockwise. - 2 - Rotate 90 degrees anti-clockwise. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - - C++ Equiv: - unsigned int SetImageRotate(int iRotate); - - See Also: - SetImageFlip - - Note: If this function is used in conjunction with the SetImageFlip function the rotation will occur before the flip regardless of which order the functions are called. 180 degree rotation can be achieved using the SetImageFlip function by selecting both horizontal and vertical flipping. - - ''' - ciRotate = c_int(iRotate) - ret = self.dll.SetImageRotate(ciRotate) - return (ret) - - def SetIODirection(self, index, iDirection): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIODirection(index, iDirection) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iDirection - requested direction for this index.: - 0 - 0 Output - 1 - 1 Input - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid direction. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIODirection(int index, int iDirection); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int(iDirection) - ret = self.dll.SetIODirection(cindex, ciDirection) - return (ret) - - def SetIOLevel(self, index, iLevel): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIOLevel(index, iLevel) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid level. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIOLevel(int index, int iLevel); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIODirection - - ''' - cindex = c_int(index) - ciLevel = c_int(iLevel) - ret = self.dll.SetIOLevel(cindex, ciLevel) - return (ret) - - def SetIsolatedCropMode(self, active, cropheight, cropwidth, vbin, hbin): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. In isolated crop mode iXon, Newton and iKon cameras can operate in either Full Vertical Binning or Imaging read modes. iDus can operate in Full Vertical Binning read mode only. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - - Inputs: - active - Crop mode active: - 1 - Crop mode is ON. - Crop - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - The selected vertical binning. - hbin - The selected horizontal binning. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_NOT_SUPPORTED - Either the camera does not support isolated Crop mode or the read mode is invalid - - C++ Equiv: - unsigned int SetIsolatedCropMode(int active, int cropheight, int cropwidth, int vbin, int hbin); - - See Also: - GetDetector SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ret = self.dll.SetIsolatedCropMode(cactive, ccropheight, ccropwidth, cvbin, chbin) - return (ret) - - def SetIsolatedCropModeEx(self, active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. This feature is currently only available for iXon Ultra and can only be used in Image readout mode with the EM output amplifier. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - The following centralized regions of interest are recommended to be used with this mode to achieve the fastest possible frame rates. The table below shows the optimally positioned ROI coordinates recommended to be used with this mode: - ROI - Crop Left Start Position - Crop Right Position - Crop Bottom Start Position - Crop Top Position - 32 x 32 - 241 - 272 - 240 - 271 - 64 x 64 - 219 - 282 - 224 - 287 - 96 x 96 - 209 - 304 - 208 - 303 - 128 x 128 - 189 - 316 - 192 - 319 - 192 x 192 - 157 - 348 - 160 - 351 - 256 x 256 - 123 - 378 - 128 - 383 - 496 x 4 - 8 - 503 - 254 - 257 - 496 x 8 - 8 - 503 - 252 - 259 - 496 x 16 - 8 - 503 - 249 - 262 - - Synopsis: - ret = SetIsolatedCropModeEx(active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom) - - Inputs: - active - Crop mode active.: - 1 - Crop mode is ON. - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - vbinThe selected vertical binning. - hbin - hbinThe selected horizontal binning. - cropleft - The selected crop left start position - cropbottom - The selected crop bottom start position - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_P6INVALID - Invalid crop left start position - DRV_P7INVALID - Invalid crop bottom start position - DRV_NOT_SUPPORTED - The camera does not support isolated crop mode - DRV_NOT_AVAILABLE - Invalid read mode - - C++ Equiv: - unsigned int SetIsolatedCropModeEx(int active, int cropheight, int cropwidth, int vbin, int hbin, int cropleft, int cropbottom); - - See Also: - GetDetector SetReadMode - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ccropleft = c_int(cropleft) - ccropbottom = c_int(cropbottom) - ret = self.dll.SetIsolatedCropModeEx(cactive, ccropheight, ccropwidth, cvbin, chbin, ccropleft, ccropbottom) - return (ret) - - def SetKineticCycleTime(self, time): - ''' - Description: - This function will set the kinetic cycle time to the nearest valid value not less than the given value. The actual time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. . Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetKineticCycleTime(time) - - Inputs: - time - the kinetic cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Time invalid. - - C++ Equiv: - unsigned int SetKineticCycleTime(float time); - - See Also: - SetNumberKinetics - - ''' - ctime = c_float(time) - ret = self.dll.SetKineticCycleTime(ctime) - return (ret) - - def SetMCPGain(self, gain): - ''' - Description: - Allows the user to control the voltage across the microchannel plate. Increasing the gain increases the voltage and so amplifies the signal. The gain range can be returned using GetMCPGainRange. - - Synopsis: - ret = SetMCPGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with device. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetMCPGain(int gain); - - See Also: - GetMCPGainRange SetGateMode SetMCPGating - - Note: Available on iStar. - - ''' - cgain = c_int(gain) - ret = self.dll.SetMCPGain(cgain) - return (ret) - - def SetMCPGating(self, gating): - ''' - Description: - This function controls the MCP gating. - - Synopsis: - ret = SetMCPGating(gating) - - Inputs: - gating - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gating accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Value for gating invalid. - - C++ Equiv: - unsigned int SetMCPGating(int gating); - - See Also: - SetMCPGain SetGateMode - - Note: Available on some ICCD models. - - ''' - cgating = c_int(gating) - ret = self.dll.SetMCPGating(cgating) - return (ret) - - def SetMessageWindow(self, wnd): - ''' - Description: - This function is reserved. - - Synopsis: - ret = SetMessageWindow(wnd) - - Inputs: - wnd - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMessageWindow(at_32 wnd); - - ''' - cwnd = c_int(wnd) - ret = self.dll.SetMessageWindow(cwnd) - return (ret) - - def SetMetaData(self, state): - ''' - Description: - This function activates the meta data option. - - Synopsis: - ret = SetMetaData(state) - - Inputs: - state - ON/OFF switch for the meta data option.: - 0 - to switch meta data OFF. - 1 - to switch meta data ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Meta data option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid state. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetMetaData(int state); - - See Also: - GetMetaDataInfo - - ''' - cstate = c_int(state) - ret = self.dll.SetMetaData(cstate) - return (ret) - - def SetMultiTrack(self, number, height, offset): - ''' - Description: - This function will set the multi-Track parameters. The tracks are automatically spread evenly over the detector. Validation of the parameters is carried out in the following order: - * Number of tracks, - * Track height - * Offset. - The first pixels row of the first track is returned via bottom. - The number of rows between each track is returned via gap. - - Synopsis: - (ret, bottom, gap) = SetMultiTrack(number, height, offset) - - Inputs: - number - number tracks (1 to number of vertical pixels) - height - height of each track (>0 (maximum depends on number of tracks)) - offset - vertical displacement of tracks. (depends on number of tracks and track height) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track height invalid. - DRV_P3INVALID - Offset invalid. - bottom - first pixels row of the first track - gap - number of rows between each track (could be 0) - - C++ Equiv: - unsigned int SetMultiTrack(int number, int height, int offset, int * bottom, int * gap); - - See Also: - SetReadMode StartAcquisition SetRandomTracks - - ''' - cnumber = c_int(number) - cheight = c_int(height) - coffset = c_int(offset) - cbottom = c_int() - cgap = c_int() - ret = self.dll.SetMultiTrack(cnumber, cheight, coffset, byref(cbottom), byref(cgap)) - return (ret, cbottom.value, cgap.value) - - def SetMultiTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Multi-Track read mode. - - Synopsis: - ret = SetMultiTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetMultiTrackHBin(int bin); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - Note: 1) If the multitrack range is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetMultiTrackHBin(cbin) - return (ret) - - def SetMultiTrackHRange(self, iStart, iEnd): - ''' - Description: - This function sets the horizontal range used when acquiring in Multi Track read mode. - - Synopsis: - ret = SetMultiTrackHRange(iStart, iEnd) - - Inputs: - iStart - First horizontal pixel in multi track mode. - iEnd - iEndLast horizontal pixel in multi track mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Range set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available for this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid start position. - DRV_P2INVALID - Invalid end position. - - C++ Equiv: - unsigned int SetMultiTrackHRange(int iStart, int iEnd); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - ''' - ciStart = c_int(iStart) - ciEnd = c_int(iEnd) - ret = self.dll.SetMultiTrackHRange(ciStart, ciEnd) - return (ret) - - def SetMultiTrackScan(self, trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetMultiTrackScan(trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames) - - Inputs: - trackHeight - - numberTracks - - iSIHStart - - iSIHEnd - - trackHBinning - - trackVBinning - - trackGap - - trackOffset - - trackSkip - - numberSubFrames - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMultiTrackScan(int trackHeight, int numberTracks, int iSIHStart, int iSIHEnd, int trackHBinning, int trackVBinning, int trackGap, int trackOffset, int trackSkip, int numberSubFrames); - - ''' - ctrackHeight = c_int(trackHeight) - cnumberTracks = c_int(numberTracks) - ciSIHStart = c_int(iSIHStart) - ciSIHEnd = c_int(iSIHEnd) - ctrackHBinning = c_int(trackHBinning) - ctrackVBinning = c_int(trackVBinning) - ctrackGap = c_int(trackGap) - ctrackOffset = c_int(trackOffset) - ctrackSkip = c_int(trackSkip) - cnumberSubFrames = c_int(numberSubFrames) - ret = self.dll.SetMultiTrackScan(ctrackHeight, cnumberTracks, ciSIHStart, ciSIHEnd, ctrackHBinning, ctrackVBinning, ctrackGap, ctrackOffset, ctrackSkip, cnumberSubFrames) - return (ret) - - def SetNextAddress(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNextAddress16(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress16(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress16(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress16(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNumberAccumulations(self, number): - ''' - Description: - This function will set the number of scans accumulated in memory. This will only take effect if the acquisition mode is either Accumulate or Kinetic Series. - - Synopsis: - ret = SetNumberAccumulations(number) - - Inputs: - number - number of scans to accumulate - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Accumulations set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of accumulates. - - C++ Equiv: - unsigned int SetNumberAccumulations(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberKinetics - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberAccumulations(cnumber) - return (ret) - - def SetNumberKinetics(self, number): - ''' - Description: - This function will set the number of scans (possibly accumulated scans) to be taken during a single acquisition sequence. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberKinetics(number) - - Inputs: - number - number of scans to store - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number in series invalid. - - C++ Equiv: - unsigned int SetNumberKinetics(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberKinetics(cnumber) - return (ret) - - def SetNumberPrescans(self, iNumber): - ''' - Description: - This function will set the number of scans acquired before data is to be retrieved. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberPrescans(iNumber) - - Inputs: - iNumber - number of scans to ignore - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Prescans set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of prescans invalid. - - C++ Equiv: - unsigned int SetNumberPrescans(int iNumber); - - See Also: - GetAcquisitionTimings SetAcquisitionMode SetKineticCycleTime SetNumberKinetics - - ''' - ciNumber = c_int(iNumber) - ret = self.dll.SetNumberPrescans(ciNumber) - return (ret) - - def SetOutputAmplifier(self, typ): - ''' - Description: - Some EMCCD systems have the capability to use a second output amplifier. This function will set the type of output amplifier to be used when reading data from the head for these systems. - - Synopsis: - ret = SetOutputAmplifier(typ) - - Inputs: - typ - the type of output amplifier.: - 0 - Standard EMCCD gain register (default)/Conventional(clara). - 1 - Conventional CCD register/Extended NIR mode(clara). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Output amplifier type invalid. - - C++ Equiv: - unsigned int SetOutputAmplifier(int typ); - - Note: 1. Available in Clara, iXon & Newton. - 2. If the current camera HSSpeed is not available when the amplifier is set then it will default to the maximum HSSpeed that is. - - - ''' - ctyp = c_int(typ) - ret = self.dll.SetOutputAmplifier(ctyp) - return (ret) - - def SetOverlapMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Overlap Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetOverlapMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Overlap mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetOverlapMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is an Overlap sensor. - - ''' - cmode = c_int(mode) - ret = self.dll.SetOverlapMode(cmode) - return (ret) - - def SetPCIMode(self, mode, value): - ''' - Description: - With the CCI23 card, events can be sent when the camera is starting to expose and when it has finished exposing. This function will control whether those events happen or not. - - Synopsis: - ret = SetPCIMode(mode, value) - - Inputs: - mode - currently must be set to 1 - value - 0 to disable the events, 1 to enable - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid - - C++ Equiv: - unsigned int SetPCIMode(int mode, int value); - - See Also: - SetAcqStatusEvent SetCameraStatusEnable - - Note: This is only supported by the CCI23 card. The software must register its event via the SetAcqStatusEvent. To specify which event the software is interested in use the SetCameraStatusEnable. - - ''' - cmode = c_int(mode) - cvalue = c_int(value) - ret = self.dll.SetPCIMode(cmode, cvalue) - return (ret) - - def SetPhosphorEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the phosphor has saturated or returned to a normal state. To determine what event has actually occurred call the GetPhosphorStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetPhosphorEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetPhosphorEvent(at_32 driverEvent); - - See Also: - GetPhosphorStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetPhosphorEvent(cdriverEvent) - return (ret) - - def SetPhotonCounting(self, state): - ''' - Description: - This function activates the photon counting option. - - Synopsis: - ret = SetPhotonCounting(state) - - Inputs: - state - ON/OFF switch for the photon counting option.: - 0 - to switch photon counting OFF. - 1 - to switch photon counting ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - photon counting option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCounting(int state); - - See Also: - SetPhotonCountingThreshold - - ''' - cstate = c_int(state) - ret = self.dll.SetPhotonCounting(cstate) - return (ret) - - def SetPhotonCountingDivisions(self, noOfDivisions): - ''' - Description: - This function sets the thresholds for the photon counting option. - - Synopsis: - (ret, divisions) = SetPhotonCountingDivisions(noOfDivisions) - - Inputs: - noOfDivisions - number of thresholds to be used. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Number of thresholds outside valid range - DRV_P2INVALID - Thresholds outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Feature not supported. - divisions - threshold levels. - - C++ Equiv: - unsigned int SetPhotonCountingDivisions(at_u32 noOfDivisions, at_32 * divisions); - - See Also: - SetPhotonCounting GetNumberPhotonCountingDivisions - - ''' - cnoOfDivisions = c_uint(noOfDivisions) - cdivisions = c_int() - ret = self.dll.SetPhotonCountingDivisions(cnoOfDivisions, byref(cdivisions)) - return (ret, cdivisions.value) - - def SetPhotonCountingThreshold(self, min, max): - ''' - Description: - This function sets the minimum and maximum threshold for the photon counting option. - - Synopsis: - ret = SetPhotonCountingThreshold(min, max) - - Inputs: - min - minimum threshold in counts for photon counting. - max - maximum threshold in counts for photon counting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Minimum threshold outside valid range (1-65535) - DRV_P2INVALID - Maximum threshold outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCountingThreshold(long min, long max); - - See Also: - SetPhotonCounting - - ''' - cmin = c_int(min) - cmax = c_int(max) - ret = self.dll.SetPhotonCountingThreshold(cmin, cmax) - return (ret) - - def SetPixelMode(self, bitdepth, colormode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetPixelMode(bitdepth, colormode) - - Inputs: - bitdepth - - colormode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetPixelMode(int bitdepth, int colormode); - - ''' - cbitdepth = c_int(bitdepth) - ccolormode = c_int(colormode) - ret = self.dll.SetPixelMode(cbitdepth, ccolormode) - return (ret) - - def SetPreAmpGain(self, index): - ''' - Description: - This function will set the pre amp gain to be used for subsequent acquisitions. The actual gain factor that will be applied can be found through a call to the GetPreAmpGain function. - The number of Pre Amp Gains available is found by calling the GetNumberPreAmpGains function. - - Synopsis: - ret = SetPreAmpGain(index) - - Inputs: - index - index pre amp gain table: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pre amp gain set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetPreAmpGain(int index); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains GetPreAmpGain - - Note: Available on iDus, iXon & Newton. - - ''' - cindex = c_int(index) - ret = self.dll.SetPreAmpGain(cindex) - return (ret) - - def SetRandomTracks(self, numTracks): - ''' - Description: - This function will set the Random-Track parameters. The positions of the tracks are validated to ensure that the tracks are in increasing order and do not overlap. The horizontal binning is set via the SetCustomTrackHBin function. The vertical binning is set to the height of each track. - Some cameras need to have at least 1 row in between specified tracks. Ixon+ and the USB cameras allow tracks with no gaps in between. - Example: - Tracks specified as 20 30 31 40 tells the SDK that the first track starts at row 20 in the CCD and finishes at row 30. The next track starts at row 31 (no gap between tracks) and ends at row 40. - - Synopsis: - (ret, areas) = SetRandomTracks(numTracks) - - Inputs: - numTracks - number tracks: - 1 - to number of vertical pixels/2 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_RANDOM_TRACK_ERROR - Invalid combination of tracks, out of memory or mode not available. - areas - pointer to an array of track positions. The array has the form: - bottom1 - bottom1 top1, bottom2, top2 ... bottomN, topN - - C++ Equiv: - unsigned int SetRandomTracks(int numTracks, int * areas); - - See Also: - SetCustomTrackHBin SetReadMode StartAcquisition SetComplexImage - - ''' - cnumTracks = c_int(numTracks) - careas = c_int() - ret = self.dll.SetRandomTracks(cnumTracks, byref(careas)) - return (ret, careas.value) - - def SetReadMode(self, mode): - ''' - Description: - This function will set the readout mode to be used on the subsequent acquisitions. - - Synopsis: - ret = SetReadMode(mode) - - Inputs: - mode - readout mode: - 0 - Full Vertical Binning - 1 - Multi-Track - 2 - Random-Track - 3 - Single-Track - 4 - Image - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadMode(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadMode(cmode) - return (ret) - - def SetReadoutRegisterPacking(self, mode): - ''' - Description: - This function will configure whether data is packed into the readout register to improve frame rates for sub-images. - Note: It is important to ensure that no light falls outside of the sub-image area otherwise the acquired data will be corrupted. Only currently available on iXon+ and iXon3. - - Synopsis: - ret = SetReadoutRegisterPacking(mode) - - Inputs: - mode - register readout mode: - 0 - Packing Off - 1 - Packing On - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadoutRegisterPacking(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadoutRegisterPacking(cmode) - return (ret) - - def SetRegisterDump(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetRegisterDump(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetRegisterDump(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetRegisterDump(cmode) - return (ret) - - def SetRingExposureTimes(self, numTimes): - ''' - Description: - This function will send up an array of exposure times to the camera if the hardware supports the feature. See GetCapabilities. Each acquisition will then use the next exposure in the ring looping round to the start again when the end is reached. There can be a maximum of 16 exposures. - - Synopsis: - (ret, times) = SetRingExposureTimes(numTimes) - - Inputs: - numTimes - The number of exposures - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_NOTAVAILABLE - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - This mode is not available. - DRV_P1INVALID - Must be between 1 and 16 exposures inclusive - DRV_P2INVALID - The exposures times are invalid. - times - A predeclared pointer to an array of numTimes floats - - C++ Equiv: - unsigned int SetRingExposureTimes(int numTimes, float * times); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable - - ''' - cnumTimes = c_int(numTimes) - ctimes = c_float() - ret = self.dll.SetRingExposureTimes(cnumTimes, byref(ctimes)) - return (ret, ctimes.value) - - def SetSaturationEvent(self, saturationEvent): - ''' - Description: - This is only supported with the CCI-23 PCI card. USB cameras do not have this feature. - This function passes a Win32 Event handle to the driver via which the driver can inform the main software that an acquisition has saturated the sensor to a potentially damaging level. You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetEvent with NULL as the parameter. - - Synopsis: - ret = SetSaturationEvent(saturationEvent) - - Inputs: - saturationEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetSaturationEvent(HANDLE saturationEvent); - - See Also: - SetDriverEvent - - Note: The programmer must reset the event after it has been handled in order to receive additional triggers, unless the event has been created with auto-reset, e.g. event = CreateEvent(NULL, FALSE, FALSE, NULL). Also, NOT all programming environments allow the use of multiple threads and Win32 events. - Only supported with the CCI-23 card. - USB cameras do not have this feature. - - - - ''' - csaturationEvent = c_void_p(saturationEvent) - ret = self.dll.SetSaturationEvent(csaturationEvent) - return (ret) - - def SetShutter(self, typ, mode, closingtime, openingtime): - ''' - Description: - This function controls the behaviour of the shutter. - The typ parameter allows the user to control the TTL signal output to an external shutter. The mode parameter configures whether the shutter opens & closes automatically (controlled by the camera) or is permanently open or permanently closed. - The opening and closing time specify the time required to open and close the shutter (this information is required for calculating acquisition timings (see SHUTTER TRANSFER TIME). - - Synopsis: - ret = SetShutter(typ, mode, closingtime, openingtime) - - Inputs: - typ - shutter type: - 1 - Output TTL high signal to open shutter - 0 - Output TTL low signal to open shutter - mode - Shutter mode: - 0 - Automatic - 1 - Open - 2 - Close - closingtime - Time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_ERROR_ACK - Acquisition in progress. - DRV_NOT_SUPPORTED - Unable to communicate with card. - DRV_P1INVALID - Camera does not support shutter control. - DRV_P2INVALID - Invalid TTL type. - DRV_P3INVALID - Invalid mode. - DRV_P4INVALID - Invalid time to open. - - C++ Equiv: - unsigned int SetShutter(int typ, int mode, int closingtime, int openingtime); - - See Also: - SetShutterEx - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - ret = self.dll.SetShutter(ctyp, cmode, cclosingtime, copeningtime) - return (ret) - - def SetShutterEx(self, typ, mode, closingtime, openingtime, extmode): - ''' - Description: - This function expands the control offered by SetShutter to allow an external shutter and internal shutter to be controlled independently (only available on some cameras - please consult your Camera User Guide). The typ parameter allows the user to control the TTL signal output to an external shutter. The opening and closing times specify the length of time required to open and close the shutter (this information is required for calculating acquisition timings - see SHUTTER TRANSFER TIME). - The mode and extmode parameters control the behaviour of the internal and external shutters. To have an external shutter open and close automatically in an experiment, set the mode parameter to Open and set the extmode parameter to Auto. To have an internal shutter open and close automatically in an experiment, set the extmode parameter to Open and set the mode parameter to Auto. - To not use any shutter in the experiment, set both shutter modes to permanently open. - - Synopsis: - ret = SetShutterEx(typ, mode, closingtime, openingtime, extmode) - - Inputs: - typ - Shutter type: - 0 - Output TTL low signal to open shutter - 1 - Output TTL high signal to open shutter - mode - Internal shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - closingtime - time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - extmode - External shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_P5INVALID - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support shutter control. - DRV_P1INVALID - Invalid TTL type. - DRV_P2INVALID - Invalid internal mode - DRV_P3INVALID - Invalid time to open. - DRV_P4INVALID - Invalid time to close - - C++ Equiv: - unsigned int SetShutterEx(int typ, int mode, int closingtime, int openingtime, int extmode); - - See Also: - SetShutter - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cextmode = c_int(extmode) - ret = self.dll.SetShutterEx(ctyp, cmode, cclosingtime, copeningtime, cextmode) - return (ret) - - def SetShutters(self, typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetShutters(typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2) - - Inputs: - typ - - mode - - closingtime - - openingtime - - exttype - - extmode - - dummy1 - - dummy2 - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetShutters(int typ, int mode, int closingtime, int openingtime, int exttype, int extmode, int dummy1, int dummy2); - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cexttype = c_int(exttype) - cextmode = c_int(extmode) - cdummy1 = c_int(dummy1) - cdummy2 = c_int(dummy2) - ret = self.dll.SetShutters(ctyp, cmode, cclosingtime, copeningtime, cexttype, cextmode, cdummy1, cdummy2) - return (ret) - - def SetSifComment(self, comment): - ''' - Description: - This function will set the user text that will be added to any sif files created with the SaveAsSif function. The stored comment can be cleared by passing NULL or an empty text string. - - Synopsis: - ret = SetSifComment(comment) - - Inputs: - comment - The comment to add to new sif files. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sif comment set. - - C++ Equiv: - unsigned int SetSifComment(char * comment); - - See Also: - SaveAsSif SaveAsCommentedSif SaveAsSif SetReadMode - - Note: To add a comment to a SIF file that will not be used in any future SIF files that are saved, use the function SaveAsCommentedSif. - - ''' - ccomment = comment - ret = self.dll.SetSifComment(ccomment) - return (ret) - - def SetSingleTrack(self, centre, height): - ''' - Description: - This function will set the single track parameters. The parameters are validated in the following order: centre row and then track height. - - Synopsis: - ret = SetSingleTrack(centre, height) - - Inputs: - centre - centre row of track: - Valid - range 0 to number of vertical pixels. - height - height of track: - Valid - range > 1 (maximum value depends on centre row and number of vertical pixels). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Center row invalid. - DRV_P2INVALID - Track height invalid. - - C++ Equiv: - unsigned int SetSingleTrack(int centre, int height); - - See Also: - SetReadMode - - ''' - ccentre = c_int(centre) - cheight = c_int(height) - ret = self.dll.SetSingleTrack(ccentre, cheight) - return (ret) - - def SetSingleTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Single Track read mode. - - Synopsis: - ret = SetSingleTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetSingleTrackHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetSingleTrackHBin(cbin) - return (ret) - - def SetSpool(self, active, method, path, framebuffersize): - ''' - Description: - This function will enable and disable the spooling of acquired data to the hard disk or to the RAM. - With spooling method 0, each scan in the series will be saved to a separate file composed of a sequence of 32-bit integers. - With spooling method 1 the type of data in the output files depends on what type of acquisition is taking place (see below). - Spooling method 2 writes out the data to file as 16-bit integers. - Spooling method 3 creates a directory structure for storing images where multiple images may appear in each file within the directory structure and the files may be spread across multiple directories. Like method 1 the data type of the image pixels depends on whether accumulate mode is being used. - Method 4 Creates a RAM disk for storing images so you should ensure that there is enough free RAM to store the full acquisition. - Methods 5, 6 and 7 can be used to directly spool out to a particular file type, either FITS, SIF or TIFF respectively. In the case of FITS and TIFF the data will be written out as 16-bit values. - Method 8 is similar to method 3, however the data is first compressed before writing to disk. In some circumstances this may improve the maximum rate of writing images to disk, however as the compression can be very CPU intensive this option may not be suitable on slower processors. - The data is stored in row order starting with the row nearest the readout register. With the exception of methods 5, 6 and 7, the data acquired during a spooled acquisition can be retrieved through the normal functions. This is a change to previous versions; it is no longer necessary to load the data from disk from your own application. - - Synopsis: - ret = SetSpool(active, method, path, framebuffersize) - - Inputs: - active - Enable/disable spooling: - 0 - Disable spooling. - 1 - Enable spooling. - method - Indicates the format of the files written to disk: - 0 - Files contain sequence of 32-bit integers - 1 - Format of data in files depends on whether multiple accumulations are being taken for each scan. Format will be 32-bit integer if data is being accumulated each scan; otherwise the format will be 16-bit integer. - 2 - Files contain sequence of 16-bit integers. - 3 - Multiple directory structure with multiple images per file and multiple files per directory. - 4 - Spool to RAM disk. - 5 - Spool to 16-bit Fits File. - 6 - Spool to Andor Sif format. - 7 - Spool to 16-bit Tiff File. - 8 - Similar to method 3 but with data compression. - path - String containing the filename stem. May also contain the path to the directory into which the files are to be stored. - framebuffersize - This sets the size of an internal circular buffer used as temporary storage. The value is the total number images the buffer can hold, not the size in bytes. Typical value would be 10. This value would be increased in situations where the computer is not able to spool the data to disk at the required rate. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - - C++ Equiv: - unsigned int SetSpool(int active, int method, char * path, int framebuffersize); - - See Also: - GetSpoolProgress - - Note: Spooled images will not be post processed, i.e. flipped or rotated. - - ''' - cactive = c_int(active) - cmethod = c_int(method) - cpath = path - cframebuffersize = c_int(framebuffersize) - ret = self.dll.SetSpool(cactive, cmethod, cpath, cframebuffersize) - return (ret) - - def SetSpoolThreadCount(self, count): - ''' - Description: - This function sets the number of parallel threads used for writing data to disk when spooling is enabled. Increasing this to a value greater than the default of 1, can sometimes improve the data rate to the hard disk particularly with Solid State hard disks. In other cases increasing this value may actually reduce the rate at which data is written to disk. - - Synopsis: - ret = SetSpoolThreadCount(count) - - Inputs: - count - The number of threads to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread count is set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid thread count. - - C++ Equiv: - unsigned int SetSpoolThreadCount(int count); - - See Also: - SetSpool - - Note: This feature is currently only available when using the Neo camera. - - ''' - ccount = c_int(count) - ret = self.dll.SetSpoolThreadCount(ccount) - return (ret) - - def SetStorageMode(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetStorageMode(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetStorageMode(long mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetStorageMode(cmode) - return (ret) - - def SetTECEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the TEC has overheated or returned to a normal state. To determine what event has actually occurred call the GetTECStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetTECEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetTECEvent(HANDLE driverEvent); - - See Also: - GetTECStatus - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetTECEvent(cdriverEvent) - return (ret) - - def SetTemperature(self, temperature): - ''' - Description: - This function will set the desired temperature of the detector. To turn the cooling ON and OFF use the CoolerONCoolerON and CoolerOFFCoolerOFF function respectively. - - Synopsis: - ret = SetTemperature(temperature) - - Inputs: - temperature - the temperature in Centigrade.: - Valid - range is given by GetTemperatureRangeGetTemperatureRange - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Temperature invalid. - DRV_NOT_SUPPORTED - The camera does not support setting the temperature. - - C++ Equiv: - unsigned int SetTemperature(int temperature); - - See Also: - CoolerOFF CoolerON GetTemperature GetTemperatureF GetTemperatureRange - - Note: Not available on Luca R cameras - automatically cooled to -20C. - - ''' - ctemperature = c_int(temperature) - ret = self.dll.SetTemperature(ctemperature) - return (ret) - - def SetTemperatureEvent(self, temperatureEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetTemperatureEvent(temperatureEvent) - - Inputs: - temperatureEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetTemperatureEvent(at_32 temperatureEvent); - - ''' - ctemperatureEvent = c_int(temperatureEvent) - ret = self.dll.SetTemperatureEvent(ctemperatureEvent) - return (ret) - - def SetTriggerInvert(self, mode): - ''' - Description: - This function will set whether an acquisition will be triggered on a rising or falling edge external trigger. - - Synopsis: - ret = SetTriggerInvert(mode) - - Inputs: - mode - trigger mode: - 0 - Rising Edge - 1 - Falling Edge - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetTriggerInvert(int mode); - - See Also: - Trigger Modes SetTriggerMode SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerInvert(cmode) - return (ret) - - def SetTriggerLevel(self, f_level): - ''' - Description: - This function sets the trigger voltage which the system will use. - - Synopsis: - ret = SetTriggerLevel(f_level) - - Inputs: - f_level - trigger voltage - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetTriggerLevel(float f_level); - - See Also: - GetCapabilities GetTriggerLevelRange - - ''' - cf_level = c_float(f_level) - ret = self.dll.SetTriggerLevel(cf_level) - return (ret) - - def SetTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode that the camera will operate in. - - Synopsis: - ret = SetTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - 6 - External Start - 7 - External Exposure (Bulb) - 9 - External FVB EM (only valid for EM Newton models in FVB mode) 10. Software Trigger - 12 - External Charge Shifting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetTriggerMode(int mode); - - See Also: - Trigger Modes SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerMode(cmode) - return (ret) - - def SetUserEvent(self, userEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUserEvent(userEvent) - - Inputs: - userEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUserEvent(at_32 userEvent); - - ''' - cuserEvent = c_int(userEvent) - ret = self.dll.SetUserEvent(cuserEvent) - return (ret) - - def SetUSGenomics(self, width, height): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUSGenomics(width, height) - - Inputs: - width - - height - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUSGenomics(long width, long height); - - ''' - cwidth = c_int(width) - cheight = c_int(height) - ret = self.dll.SetUSGenomics(cwidth, cheight) - return (ret) - - def SetVerticalRowBuffer(self, rows): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVerticalRowBuffer(rows) - - Inputs: - rows - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVerticalRowBuffer(int rows); - - ''' - crows = c_int(rows) - ret = self.dll.SetVerticalRowBuffer(crows) - return (ret) - - def SetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVerticalSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVerticalSpeed(int index); // deprecated - - See Also: - GetNumberVerticalSpeeds GetVerticalSpeed - - Note: Deprecated by SetVSSpeedSetVSSpeed. - - ''' - cindex = c_int(index) - ret = self.dll.SetVerticalSpeed(cindex) - return (ret) - - def SetVirtualChip(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVirtualChip(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVirtualChip(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetVirtualChip(cstate) - return (ret) - - def SetVSAmplitude(self, index): - ''' - Description: - If you choose a high readout speed (a low readout time), then you should also consider increasing the amplitude of the Vertical Clock Voltage. - There are five levels of amplitude available for you to choose from: - * Normal - * +1 - * +2 - * +3 - * +4 - Exercise caution when increasing the amplitude of the vertical clock voltage, since higher clocking voltages may result in increased clock-induced charge (noise) in your signal. In general, only the very highest vertical clocking speeds are likely to benefit from an increased vertical clock voltage amplitude. - - Synopsis: - ret = SetVSAmplitude(index) - - Inputs: - index - desired Vertical Clock Voltage Amplitude: - 0 - Normal - 1 ->4 - Increasing Clock voltage Amplitude - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplitude set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Your system does not support this feature - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid amplitude parameter. - - C++ Equiv: - unsigned int SetVSAmplitude(int index); - - Note: Available in iXon, iKon and Newton - full range of amplitude levels is not available on all compatible cameras. - - ''' - cindex = c_int(index) - ret = self.dll.SetVSAmplitude(cindex) - return (ret) - - def SetVSSpeed(self, index): - ''' - Description: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVSSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVSSpeed(int index); - - See Also: - GetNumberVSSpeeds GetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - ret = self.dll.SetVSSpeed(cindex) - return (ret) - - def ShutDown(self): - ''' - Description: - This function will close the AndorMCD system down. - - Synopsis: - ret = ShutDown() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System shut down. - - C++ Equiv: - unsigned int ShutDown(void); - - See Also: - CoolerOFF CoolerON SetTemperature GetTemperature - - Note: 1. For Classic & ICCD systems, the temperature of the detector should be above -20C before shutting down the system. - 2. When dynamically loading a DLL which is statically linked to the SDK library, ShutDown MUST be called before unloading. - - ''' - ret = self.dll.ShutDown() - return (ret) - - def StartAcquisition(self): - ''' - Description: - This function starts an acquisition. The status of the acquisition can be monitored via GetStatus(). - - Synopsis: - ret = StartAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition started. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int StartAcquisition(void); - - See Also: - GetStatus GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - ret = self.dll.StartAcquisition() - return (ret) - - def UnMapPhysicalAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = UnMapPhysicalAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int UnMapPhysicalAddress(void); - - ''' - ret = self.dll.UnMapPhysicalAddress() - return (ret) - - def WaitForAcquisition(self): - ''' - Description: - WaitForAcquisition can be called after an acquisition is started using StartAcquisitionStartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. - Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWaitCancelWait. - An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - If a second event occurs before the first one has been acknowledged, the first one will be ignored. Care should be taken in this case, as you may have to use CancelWaitCancelWait to exit the function. - - Synopsis: - ret = WaitForAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred - DRV_NOT_INITIALIZED - System not initialized. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(e.g. CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisition(void); - - See Also: - StartAcquisition CancelWait - - ''' - ret = self.dll.WaitForAcquisition() - return (ret) - - def WaitForAcquisitionByHandle(self, cameraHandle): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - - Synopsis: - ret = WaitForAcquisitionByHandle(cameraHandle) - - Inputs: - cameraHandle - handle of camera to put into wait state. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandle(long cameraHandle); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionTimeOut WaitForAcquisitionByHandleTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.WaitForAcquisitionByHandle(ccameraHandle) - return (ret) - - def WaitForAcquisitionByHandleTimeOut(self, cameraHandle, iTimeOutMs): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionByHandleTimeOut(cameraHandle, iTimeOutMs) - - Inputs: - cameraHandle - handle of camera to put into wait state. - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandleTimeOut(long cameraHandle, int iTimeOutMs); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionByHandleTimeOut(ccameraHandle, ciTimeOutMs) - return (ret) - - def WaitForAcquisitionTimeOut(self, iTimeOutMs): - ''' - Description: - WaitForAcquisitionTimeOut can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - Inputs: - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionTimeOut(int iTimeOutMs); - - See Also: - CancelWait StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionByHandleTimeOut - - ''' - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionTimeOut(ciTimeOutMs) - return (ret) - - def WhiteBalance(self): - ''' - Description: - For colour sensors only - Calculates the red and blue relative to green factors to white balance a colour image using the parameters stored in info. - Before passing the address of an WhiteBalanceInfo structure to the function the iSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - nfo-> iSize = sizeof(WhiteBalanceInfo); - Below is the WhiteBalanceInfo structure definition and a description of its members: - struct WHITEBALANCEINFO { - int iSize; // Structure size. - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to used to calculate white balance. - int iROI_left; // Region Of interest from which white balance is calculated - int iROI_right; // Region Of interest from which white balance is calculated - int iROI_top; // Region Of interest from which white balance is calculated - int iROI_bottom; // Region Of interest from which white balance is calculated - WhiteBalanceInfo; - iX and iY are the image dimensions. The number of elements of the input, red, green and blue arrays are iX x iY. - iAlgorithm sets the algorithm to use. The function sums all the colour values per each colour field within the Region Of interest (ROI) and calculates the relative to green values as: 0) _fRelR = GreenSum / RedSum and _fRelB = GreenSum / BlueSum; 1) _fRelR = 2/3 GreenSum / RedSum and _fRelB = 2/3 GreenSum / BlueSum, giving more importance to the green field. - iROI_left, iROI_right, iROI_top and iROI_bottom define the ROI with the constraints: - iROI_left0 <= iROI_left < iROI_right <= iX and 0 <= iROI_ bottom < iROI_ top <= iX - - Synopsis: - (ret, wRed, wGreen, wBlue, fRelR, fRelB, info) = WhiteBalance() - - Inputs: - None - - Outputs: - ret - Function Return Code: - SUCCESS - White balance calculated. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Invalid pointer (i.e. NULL). - DRV_P6INVALID - One or more parameters in info is out of range - DRV_DIVIDE_BY_ZERO_ERROR - The sum of the green field within the ROI is zero. _fRelR and _fRelB are set to 1 - wRed - pointer to red field. - wGreen - pointer to green field. - wBlue - pointer to blue field. - fRelR - pointer to the relative to green red factor. - fRelB - pointer to the relative to green blue factor. - info - pointer to white balance information structure - - C++ Equiv: - unsigned int WhiteBalance(WORD * wRed, WORD * wGreen, WORD * wBlue, float * fRelR, float * fRelB, WhiteBalanceInfo * info); - - See Also: - DemosaicImage GetMostRecentColorImage16 - - ''' - cwRed = c_short() - cwGreen = c_short() - cwBlue = c_short() - cfRelR = c_float() - cfRelB = c_float() - cinfo = WhiteBalanceInfo() - ret = self.dll.WhiteBalance(byref(cwRed), byref(cwGreen), byref(cwBlue), byref(cfRelR), byref(cfRelB), byref(cinfo)) - return (ret, cwRed.value, cwGreen.value, cwBlue.value, cfRelR.value, cfRelB.value, cinfo) - diff --git a/Andor/andorv1/build/lib/andor/__init__.py b/Andor/andorv1/build/lib/andor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv1/build/lib/andor/aqctl_andor.py b/Andor/andorv1/build/lib/andor/aqctl_andor.py deleted file mode 100644 index 29d9c08..0000000 --- a/Andor/andorv1/build/lib/andor/aqctl_andor.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from andorv1.0.driver import andor -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the andor camera") - common_args.simple_network_args(parser, 3210) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = andor(args.device if not args.simulation else None) - dev = andor() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("andor server startup on port",args.port,"successful...") - simple_server_loop( - {"andor": dev}, common_args.bind_address_from_args(args), args.port) - truthcounter=1 - finally: - print("Closing server...") - #dev.close() - -if __name__ == "__main__": - main() diff --git a/Andor/andorv1/build/lib/andor/atmcd.py b/Andor/andorv1/build/lib/andor/atmcd.py deleted file mode 100644 index 03a3281..0000000 --- a/Andor/andorv1/build/lib/andor/atmcd.py +++ /dev/null @@ -1,12230 +0,0 @@ -from ctypes import * -import time -import platform -import sys - -MAX_PATH = 256 - -class ColorDemosaicInfo(Structure) : - _fields_ = [("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iXPhase", c_int), - ("iYPhase", c_int), - ("iBackground", c_int)] -class AndorCapabilities(Structure) : - _fields_ = [("ulSize", c_ulong), - ("ulAcqModes", c_ulong), - ("ulReadModes", c_ulong), - ("ulTriggerModes", c_ulong), - ("ulCameraType", c_ulong), - ("ulPixelMode", c_ulong), - ("ulSetFunctions", c_ulong), - ("ulGetFunctions", c_ulong), - ("ulFeatures", c_ulong), - ("ulPCICard", c_ulong), - ("ulEMGainCapability", c_ulong), - ("ulFTReadModes", c_ulong)] -class WhiteBalanceInfo(Structure) : - _fields_ = [("iSize", c_int), - ("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iROI_left", c_int), - ("iROI_right", c_int), - ("iROI_top", c_int), - ("iROI_bottom", c_int), - ("iOperation", c_int)] -class SYSTEMTIME(Structure) : - _fields_ = [("wYear", c_short), - ("wMonth", c_short), - ("wDayOfWeek", c_short), - ("wDay", c_short), - ("wHour", c_short), - ("wMinute", c_short), - ("wSecond", c_short), - ("wMilliseconds", c_short)] - -class atmcd: - def __init__(self): - if sys.platform == "linux2": - dllname = "/usr/local/lib/libandor.so" - self.dll = cdll.LoadLibrary(dllname) - elif sys.platform == "win32": - if platform.architecture()[0] == "64bit" : - dllname = "C:\\Program Files\\Andor SDK\\atmcd64d.dll" - else: - dllname = "C:\\Program Files\\Andor SDK\\atmcd32d.dll" - self.dll = windll.LoadLibrary(dllname) - else: - print("Cannot detect operating system, will now stop") - raise - - # Error Code Returns and Definitions - DRV_ERROR_CODES = 20001 - DRV_SUCCESS = 20002 - DRV_VXDNOTINSTALLED = 20003 - DRV_ERROR_SCAN = 20004 - DRV_ERROR_CHECK_SUM = 20005 - DRV_ERROR_FILELOAD = 20006 - DRV_UNKNOWN_FUNCTION = 20007 - DRV_ERROR_VXD_INIT = 20008 - DRV_ERROR_ADDRESS = 20009 - DRV_ERROR_PAGELOCK = 20010 - DRV_ERROR_PAGEUNLOCK = 20011 - DRV_ERROR_BOARDTEST = 20012 - DRV_ERROR_ACK = 20013 - DRV_ERROR_UP_FIFO = 20014 - DRV_ERROR_PATTERN = 20015 - DRV_ACQUISITION_ERRORS = 20017 - DRV_ACQ_BUFFER = 20018 - DRV_ACQ_DOWNFIFO_FULL = 20019 - DRV_PROC_UNKONWN_INSTRUCTION = 20020 - DRV_ILLEGAL_OP_CODE = 20021 - DRV_KINETIC_TIME_NOT_MET = 20022 - DRV_ACCUM_TIME_NOT_MET = 20023 - DRV_NO_NEW_DATA = 20024 - DRV_PCI_DMA_FAIL = 20025 - DRV_SPOOLERROR = 20026 - DRV_SPOOLSETUPERROR = 20027 - DRV_FILESIZELIMITERROR = 20028 - DRV_ERROR_FILESAVE = 20029 - DRV_TEMPERATURE_CODES = 20033 - DRV_TEMPERATURE_OFF = 20034 - DRV_TEMPERATURE_NOT_STABILIZED = 20035 - DRV_TEMPERATURE_STABILIZED = 20036 - DRV_TEMPERATURE_NOT_REACHED = 20037 - DRV_TEMPERATURE_OUT_RANGE = 20038 - DRV_TEMPERATURE_NOT_SUPPORTED = 20039 - DRV_TEMPERATURE_DRIFT = 20040 - DRV_TEMP_CODES = 20033 - DRV_TEMP_OFF = 20034 - DRV_TEMP_NOT_STABILIZED = 20035 - DRV_TEMP_STABILIZED = 20036 - DRV_TEMP_NOT_REACHED = 20037 - DRV_TEMP_OUT_RANGE = 20038 - DRV_TEMP_NOT_SUPPORTED = 20039 - DRV_TEMP_DRIFT = 20040 - DRV_GENERAL_ERRORS = 20049 - DRV_INVALID_AUX = 20050 - DRV_COF_NOTLOADED = 20051 - DRV_FPGAPROG = 20052 - DRV_FLEXERROR = 20053 - DRV_GPIBERROR = 20054 - DRV_EEPROMVERSIONERROR = 20055 - DRV_DATATYPE = 20064 - DRV_DRIVER_ERRORS = 20065 - DRV_P1INVALID = 20066 - DRV_P2INVALID = 20067 - DRV_P3INVALID = 20068 - DRV_P4INVALID = 20069 - DRV_INIERROR = 20070 - DRV_COFERROR = 20071 - DRV_ACQUIRING = 20072 - DRV_IDLE = 20073 - DRV_TEMPCYCLE = 20074 - DRV_NOT_INITIALIZED = 20075 - DRV_P5INVALID = 20076 - DRV_P6INVALID = 20077 - DRV_INVALID_MODE = 20078 - DRV_INVALID_FILTER = 20079 - DRV_I2CERRORS = 20080 - DRV_I2CDEVNOTFOUND = 20081 - DRV_I2CTIMEOUT = 20082 - DRV_P7INVALID = 20083 - DRV_P8INVALID = 20084 - DRV_P9INVALID = 20085 - DRV_P10INVALID = 20086 - DRV_P11INVALID = 20087 - DRV_USBERROR = 20089 - DRV_IOCERROR = 20090 - DRV_VRMVERSIONERROR = 20091 - DRV_GATESTEPERROR = 20092 - DRV_USB_INTERRUPT_ENDPOINT_ERROR = 20093 - DRV_RANDOM_TRACK_ERROR = 20094 - DRV_INVALID_TRIGGER_MODE = 20095 - DRV_LOAD_FIRMWARE_ERROR = 20096 - DRV_DIVIDE_BY_ZERO_ERROR = 20097 - DRV_INVALID_RINGEXPOSURES = 20098 - DRV_BINNING_ERROR = 20099 - DRV_INVALID_AMPLIFIER = 20100 - DRV_INVALID_COUNTCONVERT_MODE = 20101 - DRV_ERROR_NOCAMERA = 20990 - DRV_NOT_SUPPORTED = 20991 - DRV_NOT_AVAILABLE = 20992 - DRV_ERROR_MAP = 20115 - DRV_ERROR_UNMAP = 20116 - DRV_ERROR_MDL = 20117 - DRV_ERROR_UNMDL = 20118 - DRV_ERROR_BUFFSIZE = 20119 - DRV_ERROR_NOHANDLE = 20121 - DRV_GATING_NOT_AVAILABLE = 20130 - DRV_FPGA_VOLTAGE_ERROR = 20131 - DRV_OW_CMD_FAIL = 20150 - DRV_OWMEMORY_BAD_ADDR = 20151 - DRV_OWCMD_NOT_AVAILABLE = 20152 - DRV_OW_NO_SLAVES = 20153 - DRV_OW_NOT_INITIALIZED = 20154 - DRV_OW_ERROR_SLAVE_NUM = 20155 - DRV_MSTIMINGS_ERROR = 20156 - DRV_OA_NULL_ERROR = 20173 - DRV_OA_PARSE_DTD_ERROR = 20174 - DRV_OA_DTD_VALIDATE_ERROR = 20175 - DRV_OA_FILE_ACCESS_ERROR = 20176 - DRV_OA_FILE_DOES_NOT_EXIST = 20177 - DRV_OA_XML_INVALID_OR_NOT_FOUND_ERROR = 20178 - DRV_OA_PRESET_FILE_NOT_LOADED = 20179 - DRV_OA_USER_FILE_NOT_LOADED = 20180 - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED = 20181 - DRV_OA_INVALID_FILE = 20182 - DRV_OA_FILE_HAS_BEEN_MODIFIED = 20183 - DRV_OA_BUFFER_FULL = 20184 - DRV_OA_INVALID_STRING_LENGTH = 20185 - DRV_OA_INVALID_CHARS_IN_NAME = 20186 - DRV_OA_INVALID_NAMING = 20187 - DRV_OA_GET_CAMERA_ERROR = 20188 - DRV_OA_MODE_ALREADY_EXISTS = 20189 - DRV_OA_STRINGS_NOT_EQUAL = 20190 - DRV_OA_NO_USER_DATA = 20191 - DRV_OA_VALUE_NOT_SUPPORTED = 20192 - DRV_OA_MODE_DOES_NOT_EXIST = 20193 - DRV_OA_CAMERA_NOT_SUPPORTED = 20194 - DRV_OA_FAILED_TO_GET_MODE = 20195 - DRV_PROCESSING_FAILED = 20211 - AT_NoOfVersionInfoIds = 2 - AT_VERSION_INFO_LEN = 80 - AT_CONTROLLER_CARD_MODEL_LEN = 80 - AT_DDGLite_ControlBit_GlobalEnable = 0x01 - AT_DDGLite_ControlBit_ChannelEnable = 0x01 - AT_DDGLite_ControlBit_FreeRun = 0x02 - AT_DDGLite_ControlBit_DisableOnFrame = 0x04 - AT_DDGLite_ControlBit_RestartOnFire = 0x08 - AT_DDGLite_ControlBit_Invert = 0x10 - AT_DDGLite_ControlBit_EnableOnFire = 0x20 - AT_DDG_POLARITY_POSITIVE = 0 - AT_DDG_POLARITY_NEGATIVE = 1 - AT_DDG_TERMINATION_50OHMS = 0 - AT_DDG_TERMINATION_HIGHZ = 1 - AT_STEPMODE_CONSTANT = 0 - AT_STEPMODE_EXPONENTIAL = 1 - AT_STEPMODE_LOGARITHMIC = 2 - AT_STEPMODE_LINEAR = 3 - AT_STEPMODE_OFF = 100 - AT_GATEMODE_FIRE_AND_GATE = 0 - AT_GATEMODE_FIRE_ONLY = 1 - AT_GATEMODE_GATE_ONLY = 2 - AT_GATEMODE_CW_ON = 3 - AT_GATEMODE_CW_OFF = 4 - AT_GATEMODE_DDG = 5 - AC_ACQMODE_SINGLE = 1 - AC_ACQMODE_VIDEO = 2 - AC_ACQMODE_ACCUMULATE = 4 - AC_ACQMODE_KINETIC = 8 - AC_ACQMODE_FRAMETRANSFER = 16 - AC_ACQMODE_FASTKINETICS = 32 - AC_ACQMODE_OVERLAP = 64 - AC_READMODE_FULLIMAGE = 1 - AC_READMODE_SUBIMAGE = 2 - AC_READMODE_SINGLETRACK = 4 - AC_READMODE_FVB = 8 - AC_READMODE_MULTITRACK = 16 - AC_READMODE_RANDOMTRACK = 32 - AC_READMODE_MULTITRACKSCAN = 64 - AC_TRIGGERMODE_INTERNAL = 1 - AC_TRIGGERMODE_EXTERNAL = 2 - AC_TRIGGERMODE_EXTERNAL_FVB_EM = 4 - AC_TRIGGERMODE_CONTINUOUS = 8 - AC_TRIGGERMODE_EXTERNALSTART = 16 - AC_TRIGGERMODE_EXTERNALEXPOSURE = 32 - AC_TRIGGERMODE_INVERTED = 0x40 - AC_TRIGGERMODE_EXTERNAL_CHARGESHIFTING = 0x80 - AC_TRIGGERMODE_BULB = 32 - AC_CAMERATYPE_PDA = 0 - AC_CAMERATYPE_IXON = 1 - AC_CAMERATYPE_ICCD = 2 - AC_CAMERATYPE_EMCCD = 3 - AC_CAMERATYPE_CCD = 4 - AC_CAMERATYPE_ISTAR = 5 - AC_CAMERATYPE_VIDEO = 6 - AC_CAMERATYPE_IDUS = 7 - AC_CAMERATYPE_NEWTON = 8 - AC_CAMERATYPE_SURCAM = 9 - AC_CAMERATYPE_USBICCD = 10 - AC_CAMERATYPE_LUCA = 11 - AC_CAMERATYPE_RESERVED = 12 - AC_CAMERATYPE_IKON = 13 - AC_CAMERATYPE_INGAAS = 14 - AC_CAMERATYPE_IVAC = 15 - AC_CAMERATYPE_UNPROGRAMMED = 16 - AC_CAMERATYPE_CLARA = 17 - AC_CAMERATYPE_USBISTAR = 18 - AC_CAMERATYPE_SIMCAM = 19 - AC_CAMERATYPE_NEO = 20 - AC_CAMERATYPE_IXONULTRA = 21 - AC_CAMERATYPE_VOLMOS = 22 - AC_PIXELMODE_8BIT = 1 - AC_PIXELMODE_14BIT = 2 - AC_PIXELMODE_16BIT = 4 - AC_PIXELMODE_32BIT = 8 - AC_PIXELMODE_MONO = 0x000000 - AC_PIXELMODE_RGB = 0x010000 - AC_PIXELMODE_CMY = 0x020000 - AC_SETFUNCTION_VREADOUT = 0x01 - AC_SETFUNCTION_HREADOUT = 0x02 - AC_SETFUNCTION_TEMPERATURE = 0x04 - AC_SETFUNCTION_MCPGAIN = 0x08 - AC_SETFUNCTION_EMCCDGAIN = 0x10 - AC_SETFUNCTION_BASELINECLAMP = 0x20 - AC_SETFUNCTION_VSAMPLITUDE = 0x40 - AC_SETFUNCTION_HIGHCAPACITY = 0x80 - AC_SETFUNCTION_BASELINEOFFSET = 0x0100 - AC_SETFUNCTION_PREAMPGAIN = 0x0200 - AC_SETFUNCTION_CROPMODE = 0x0400 - AC_SETFUNCTION_DMAPARAMETERS = 0x0800 - AC_SETFUNCTION_HORIZONTALBIN = 0x1000 - AC_SETFUNCTION_MULTITRACKHRANGE = 0x2000 - AC_SETFUNCTION_RANDOMTRACKNOGAPS = 0x4000 - AC_SETFUNCTION_EMADVANCED = 0x8000 - AC_SETFUNCTION_GATEMODE = 0x010000 - AC_SETFUNCTION_DDGTIMES = 0x020000 - AC_SETFUNCTION_IOC = 0x040000 - AC_SETFUNCTION_INTELLIGATE = 0x080000 - AC_SETFUNCTION_INSERTION_DELAY = 0x100000 - AC_SETFUNCTION_GATESTEP = 0x200000 - AC_SETFUNCTION_GATEDELAYSTEP = 0x200000 - AC_SETFUNCTION_TRIGGERTERMINATION = 0x400000 - AC_SETFUNCTION_EXTENDEDNIR = 0x800000 - AC_SETFUNCTION_SPOOLTHREADCOUNT = 0x1000000 - AC_SETFUNCTION_REGISTERPACK = 0x2000000 - AC_SETFUNCTION_PRESCANS = 0x4000000 - AC_SETFUNCTION_GATEWIDTHSTEP = 0x8000000 - AC_SETFUNCTION_GAIN = 8 - AC_SETFUNCTION_ICCDGAIN = 8 - AC_GETFUNCTION_TEMPERATURE = 0x01 - AC_GETFUNCTION_TARGETTEMPERATURE = 0x02 - AC_GETFUNCTION_TEMPERATURERANGE = 0x04 - AC_GETFUNCTION_DETECTORSIZE = 0x08 - AC_GETFUNCTION_MCPGAIN = 0x10 - AC_GETFUNCTION_EMCCDGAIN = 0x20 - AC_GETFUNCTION_HVFLAG = 0x40 - AC_GETFUNCTION_GATEMODE = 0x80 - AC_GETFUNCTION_DDGTIMES = 0x0100 - AC_GETFUNCTION_IOC = 0x0200 - AC_GETFUNCTION_INTELLIGATE = 0x0400 - AC_GETFUNCTION_INSERTION_DELAY = 0x0800 - AC_GETFUNCTION_GATESTEP = 0x1000 - AC_GETFUNCTION_GATEDELAYSTEP = 0x1000 - AC_GETFUNCTION_PHOSPHORSTATUS = 0x2000 - AC_GETFUNCTION_MCPGAINTABLE = 0x4000 - AC_GETFUNCTION_BASELINECLAMP = 0x8000 - AC_GETFUNCTION_GATEWIDTHSTEP = 0x10000 - AC_GETFUNCTION_GAIN = 0x10 - AC_GETFUNCTION_ICCDGAIN = 0x10 - AC_FEATURES_POLLING = 1 - AC_FEATURES_EVENTS = 2 - AC_FEATURES_SPOOLING = 4 - AC_FEATURES_SHUTTER = 8 - AC_FEATURES_SHUTTEREX = 16 - AC_FEATURES_EXTERNAL_I2C = 32 - AC_FEATURES_SATURATIONEVENT = 64 - AC_FEATURES_FANCONTROL = 128 - AC_FEATURES_MIDFANCONTROL = 256 - AC_FEATURES_TEMPERATUREDURINGACQUISITION = 512 - AC_FEATURES_KEEPCLEANCONTROL = 1024 - AC_FEATURES_DDGLITE = 0x0800 - AC_FEATURES_FTEXTERNALEXPOSURE = 0x1000 - AC_FEATURES_KINETICEXTERNALEXPOSURE = 0x2000 - AC_FEATURES_DACCONTROL = 0x4000 - AC_FEATURES_METADATA = 0x8000 - AC_FEATURES_IOCONTROL = 0x10000 - AC_FEATURES_PHOTONCOUNTING = 0x20000 - AC_FEATURES_COUNTCONVERT = 0x40000 - AC_FEATURES_DUALMODE = 0x80000 - AC_FEATURES_OPTACQUIRE = 0x100000 - AC_FEATURES_REALTIMESPURIOUSNOISEFILTER = 0x200000 - AC_FEATURES_POSTPROCESSSPURIOUSNOISEFILTER = 0x400000 - AC_FEATURES_DUALPREAMPGAIN = 0x800000 - AC_FEATURES_DEFECT_CORRECTION = 0x1000000 - AC_FEATURES_STARTOFEXPOSURE_EVENT = 0x2000000 - AC_FEATURES_ENDOFEXPOSURE_EVENT = 0x4000000 - AC_FEATURES_CAMERALINK = 0x8000000 - AC_EMGAIN_8BIT = 1 - AC_EMGAIN_12BIT = 2 - AC_EMGAIN_LINEAR12 = 4 - AC_EMGAIN_REAL12 = 8 - def AbortAcquisition(self): - ''' - Description: - This function aborts the current acquisition if one is active. - - Synopsis: - ret = AbortAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition aborted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_IDLE - The system is not currently acquiring. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int AbortAcquisition(void); - - See Also: - GetStatus StartAcquisition - - ''' - ret = self.dll.AbortAcquisition() - return (ret) - - def CancelWait(self): - ''' - Description: - This function restarts a thread which is sleeping within the WaitForAcquisitionWaitForAcquisition function. The sleeping thread will return from WaitForAcquisition with a value not equal to DRV_SUCCESS. - - Synopsis: - ret = CancelWait() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread restarted successfully. - - C++ Equiv: - unsigned int CancelWait(void); - - See Also: - WaitForAcquisition - - ''' - ret = self.dll.CancelWait() - return (ret) - - def CoolerOFF(self): - ''' - Description: - Switches OFF the cooling. The rate of temperature change is controlled in some models until the temperature reaches 0C. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerOFF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched OFF. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support switching cooler off. - - C++ Equiv: - unsigned int CoolerOFF(void); - - See Also: - CoolerON SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: Not available on Luca R cameras - always cooled to -20C. - - NOTE: (Classic & ICCD only) 1. When the temperature control is switched off the temperature of the sensor is gradually raised to 0C to ensure no thermal stresses are set up in the sensor. 2. When closing down the program via ShutDown you must ensure that the temperature of the detector is above -20C, otherwise calling ShutDown while the detector is still cooled will cause the temperature to rise faster than certified. - - - ''' - ret = self.dll.CoolerOFF() - return (ret) - - def CoolerON(self): - ''' - Description: - Switches ON the cooling. On some systems the rate of temperature change is controlled until the temperature is within 3C of the set value. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerON() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched ON. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int CoolerON(void); - - See Also: - CoolerOFF SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: The temperature to which the detector will be cooled is set via SetTemperatureSetTemperature. The temperature stabilization is controlled via hardware, and the current temperature can be obtained via GetTemperatureGetTemperature. The temperature of the sensor is gradually brought to the desired temperature to ensure no thermal stresses are set up in the sensor. - - Can be called for certain systems during an acquisition. This can be tested for using GetCapabilities. - - - ''' - ret = self.dll.CoolerON() - return (ret) - - def DemosaicImage(self, grey, info): - ''' - Description: - For colour sensors only - Demosaics an image taken with a CYMG CCD into RGB using the parameters stored in info. Below is the ColorDemosaicInfo structure definition and a description of its members: - struct COLORDEMOSAICINFO { - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to demosaic image. - int iXPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iYPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iBackground; // Background to remove from raw data when demosaicing. - ColorDemosaicInfo; - * iX and iY are the image dimensions. The number of elements in the input red, green and blue arrays is iX x iY. - * iAlgorithm sets the algorithm to use: 0 for a 2x2 matrix demosaic algorithm or 1 for a 3x3 one. - The CYMG CCD pattern can be broken into cells of 2x4 pixels, e.g.: - * iXPhase and iYPhase store what colour is the bottom-left pixel. - * iBackground sets the numerical value to be removed from every pixel in the input image before demosaicing is done. - - Synopsis: - (ret, red, green, blue) = DemosaicImage(grey, info) - - Inputs: - grey - pointer to image to demosaic - info - pointer to demosaic information structure. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image demosaiced - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - One or more parameters in info is out of range - red - pointer to the red plane storage allocated by the user. - green - pointer to the green plane storage allocated by the user. - blue - pointer to the blue plane storage allocated by the user. - - C++ Equiv: - unsigned int DemosaicImage(WORD * grey, WORD * red, WORD * green, WORD * blue, ColorDemosaicInfo * info); - - See Also: - GetMostRecentColorImage16 WhiteBalance - - ''' - cgrey = (c_short * info.iX * info.iY)(grey) - cred = (c_short * info.iX * info.iY)() - cgreen = (c_short * info.iX * info.iY)() - cblue = (c_short * info.iX * info.iY)() - cinfo = ColorDemosaicInfo(info) - ret = self.dll.DemosaicImage(cgrey, cred, cgreen, cblue, byref(cinfo)) - return (ret, cred, cgreen, cblue) - - def EnableKeepCleans(self, mode): - ''' - Description: - This function is only available on certain cameras operating in FVB external trigger mode. It determines if the camera keep clean cycle will run between acquisitions. - When keep cleans are disabled in this way the exposure time is effectively the exposure time between triggers. - The Keep Clean cycle is enabled by default. - The feature capability AC_FEATURES_KEEPCLEANCONTROL determines if this function can be called for the camera. - - Synopsis: - ret = EnableKeepCleans(mode) - - Inputs: - mode - The keep clean mode.: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Keep clean cycle mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int EnableKeepCleans(int mode); - - See Also: - GetCapabilities - - Note: Currently only available on Newton and iKon cameras operating in FVB external trigger mode. - - ''' - cmode = c_int(mode) - ret = self.dll.EnableKeepCleans(cmode) - return (ret) - - def Filter_GetAveragingFactor(self): - ''' - Description: - Returns the current averaging factor value. - - Synopsis: - (ret, averagingFactor) = Filter_GetAveragingFactor() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid averagingFactor (i.e. NULL pointer). - averagingFactor - The current averaging factor value. - - C++ Equiv: - unsigned int Filter_GetAveragingFactor(int * averagingFactor); - - See Also: - Filter_SetAveragingFactor - - ''' - caveragingFactor = c_int() - ret = self.dll.Filter_GetAveragingFactor(byref(caveragingFactor)) - return (ret, caveragingFactor.value) - - def Filter_GetAveragingFrameCount(self): - ''' - Description: - Returns the current frame count value. - - Synopsis: - (ret, frames) = Filter_GetAveragingFrameCount() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count (i.e. NULL pointer). - frames - The current frame count value. - - C++ Equiv: - unsigned int Filter_GetAveragingFrameCount(int * frames); - - See Also: - Filter_SetAveragingFrameCount - - ''' - cframes = c_int() - ret = self.dll.Filter_GetAveragingFrameCount(byref(cframes)) - return (ret, cframes.value) - - def Filter_GetDataAveragingMode(self): - ''' - Description: - Returns the current averaging mode. - - Synopsis: - (ret, mode) = Filter_GetDataAveragingMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - mode - The current averaging mode. - - C++ Equiv: - unsigned int Filter_GetDataAveragingMode(int * mode); - - See Also: - Filter_SetDataAveragingMode - - ''' - cmode = c_int() - ret = self.dll.Filter_GetDataAveragingMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetMode(self): - ''' - Description: - Returns the current Noise Filter mode. - - Synopsis: - (ret, mode) = Filter_GetMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode (i.e. NULL pointer) - mode - Noise Filter mode. - - C++ Equiv: - unsigned int Filter_GetMode(unsigned int * mode); - - See Also: - Filter_SetMode - - ''' - cmode = c_uint() - ret = self.dll.Filter_GetMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetThreshold(self): - ''' - Description: - Returns the current Noise Filter threshold value. - - Synopsis: - (ret, threshold) = Filter_GetThreshold() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - threshold - The current threshold value. - - C++ Equiv: - unsigned int Filter_GetThreshold(float * threshold); - - See Also: - Filter_SetThreshold - - ''' - cthreshold = c_float() - ret = self.dll.Filter_GetThreshold(byref(cthreshold)) - return (ret, cthreshold.value) - - def Filter_SetAveragingFactor(self, averagingFactor): - ''' - Description: - Sets the averaging factor. - - Synopsis: - ret = Filter_SetAveragingFactor(averagingFactor) - - Inputs: - averagingFactor - The averaging factor to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging factor set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - - C++ Equiv: - unsigned int Filter_SetAveragingFactor(int averagingFactor); - - See Also: - Filter_GetAveragingFactor - - ''' - caveragingFactor = c_int(averagingFactor) - ret = self.dll.Filter_SetAveragingFactor(caveragingFactor) - return (ret) - - def Filter_SetAveragingFrameCount(self, frames): - ''' - Description: - Sets the averaging frame count. - - Synopsis: - ret = Filter_SetAveragingFrameCount(frames) - - Inputs: - frames - The averaging frame count to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging frame count set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count. - - C++ Equiv: - unsigned int Filter_SetAveragingFrameCount(int frames); - - See Also: - Filter_GetAveragingFrameCount - - ''' - cframes = c_int(frames) - ret = self.dll.Filter_SetAveragingFrameCount(cframes) - return (ret) - - def Filter_SetDataAveragingMode(self, mode): - ''' - Description: - Sets the current data averaging mode. - - Synopsis: - ret = Filter_SetDataAveragingMode(mode) - - Inputs: - mode - The averaging factor mode to use.: - 0 - No Averaging Filter - 5 - Recursive Averaging Filter - 6 - Frame Averaging Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetDataAveragingMode(int mode); - - See Also: - Filter_GetDataAveragingMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetDataAveragingMode(cmode) - return (ret) - - def Filter_SetMode(self, mode): - ''' - Description: - Set the Noise Filter to use. - - Synopsis: - ret = Filter_SetMode(mode) - - Inputs: - mode - Filter mode to use.: - 0 - No Filter - 1 - Median Filter - 2 - Level Above Filter - 3 - interquartile Range Filter - 4 - Noise Threshold Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetMode(int mode); - - See Also: - Filter_GetMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetMode(cmode) - return (ret) - - def Filter_SetThreshold(self, threshold): - ''' - Description: - Sets the threshold value for the Noise Filter. - - Synopsis: - ret = Filter_SetThreshold(threshold) - - Inputs: - threshold - Threshold value used to process image.: - 0 - 65535 for Level Above filter. - 0 - 10 for all other filters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold. - - C++ Equiv: - unsigned int Filter_SetThreshold(float threshold); - - See Also: - Filter_GetThreshold - - ''' - cthreshold = c_float(threshold) - ret = self.dll.Filter_SetThreshold(cthreshold) - return (ret) - - def FreeInternalMemory(self): - ''' - Description: - The FreeinternalMemory function will deallocate any memory used internally to store the previously acquired data. Note that once this function has been called, data from last acquisition cannot be retrieved. - - Synopsis: - ret = FreeInternalMemory() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Memory freed. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int FreeInternalMemory(void); - - See Also: - GetImages PrepareAcquisition - - ''' - ret = self.dll.FreeInternalMemory() - return (ret) - - def GetAcquiredData(self, size): - ''' - Description: - This function will return the data from the last acquisition. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData(at_32 * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData16 - - ''' - carr = c_int() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredData16(self, size): - ''' - Description: - 16-bit version of the GetAcquiredDataGetAcquiredData function. The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size isincorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData16(WORD * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData - - ''' - carr = c_short() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData16(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAcquiredFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAcquiredFloatData(float * arr, unsigned long size); - - ''' - carr = c_float() - csize = c_ulong(size) - ret = self.dll.GetAcquiredFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquisitionProgress(self): - ''' - Description: - This function will return information on the progress of the current acquisition. It can be called at any time but is best used in conjunction with SetDriverEventSetDriverEvent. - The values returned show the number of completed scans in the current acquisition. - If 0 is returned for both accum and series then either:- - * No acquisition is currently running - * The acquisition has just completed - * The very first scan of an acquisition has just started and not yet completed - GetStatus can be used to confirm if the first scan has just started, returning - DRV_ACQUIRING, otherwise it will return DRV_IDLE. - For example, if [i]accum[/i]=2 and [i]series[/i]=3 then the acquisition has completed 3 in the series and 2 accumulations in the 4 scan of the series. - - Synopsis: - (ret, acc, series) = GetAcquisitionProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of accumulation and series scans completed. - DRV_NOT_INITIALIZED - System not initialized. - acc - returns the number of accumulations completed in the current kinetic scan. - series - series the number of kinetic scans completed - - C++ Equiv: - unsigned int GetAcquisitionProgress(long * acc, long * series); - - See Also: - SetAcquisitionMode SetNumberAccumulations SetNumberKinetics SetDriverEvent - - ''' - cacc = c_int() - cseries = c_int() - ret = self.dll.GetAcquisitionProgress(byref(cacc), byref(cseries)) - return (ret, cacc.value, cseries.value) - - def GetAcquisitionTimings(self): - ''' - Description: - This function will return the current "valid" acquisition timing information. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The values returned are the actual times used in subsequent acquisitions. - This function is required as it is possible to set the exposure time to 20ms, accumulate cycle time to 30ms and then set the readout mode to full image. As it can take 250ms to read out an image it is not possible to have a cycle time of 30ms. - - Synopsis: - (ret, exposure, accumulate, kinetic) = GetAcquisitionTimings() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Acquisition or readout mode is not available. - exposure - valid exposure time in seconds - accumulate - valid accumulate cycle time in seconds - kinetic - valid kinetic cycle time in seconds - - C++ Equiv: - unsigned int GetAcquisitionTimings(float * exposure, float * accumulate, float * kinetic); - - See Also: - SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - cexposure = c_float() - caccumulate = c_float() - ckinetic = c_float() - ret = self.dll.GetAcquisitionTimings(byref(cexposure), byref(caccumulate), byref(ckinetic)) - return (ret, cexposure.value, caccumulate.value, ckinetic.value) - - def GetAdjustedRingExposureTimes(self, inumTimes): - ''' - Description: - This function will return the actual exposure times that the camera will use. There may be differences between requested exposures and the actual exposures. - - Synopsis: - (ret, fptimes) = GetAdjustedRingExposureTimes(inumTimes) - - Inputs: - inumTimes - inumTimesNumbers of times requested. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number of exposures requested - fptimes - fptimesPointer to an array large enough to hold _inumTimes floats. - - C++ Equiv: - unsigned int GetAdjustedRingExposureTimes(int inumTimes, float * fptimes); - - See Also: - GetNumberRingExposureTimes SetRingExposureTimes - - ''' - cinumTimes = c_int(inumTimes) - cfptimes = c_float() - ret = self.dll.GetAdjustedRingExposureTimes(cinumTimes, byref(cfptimes)) - return (ret, cfptimes.value) - - def GetAllDMAData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAllDMAData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAllDMAData(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetAllDMAData(byref(carr), csize) - return (ret, carr.value) - - def GetAmpDesc(self, index, length): - ''' - Description: - This function will return a string with an amplifier description. The amplifier is selected using the index. The SDK has a string associated with each of its amplifiers. The maximum number of characters needed to store the amplifier descriptions is 21. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetAmpDesc(index, length) - - Inputs: - index - The amplifier index. - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid. - DRV_P2INVALID - The desc pointer is null. - DRV_P3INVALID - The length parameter is invalid (less than 1) - name - A user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetAmpDesc(int index, char * name, int length); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetAmpDesc(cindex, cname, clength) - return (ret, cname) - - def GetAmpMaxSpeed(self, index): - ''' - Description: - This function will return the maximum available horizontal shift speed for the amplifier selected by the index parameter. - - Synopsis: - (ret, speed) = GetAmpMaxSpeed(index) - - Inputs: - index - amplifier index - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid - speed - horizontal shift speed - - C++ Equiv: - unsigned int GetAmpMaxSpeed(int index, float * speed); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetAmpMaxSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetAvailableCameras(self): - ''' - Description: - This function returns the total number of Andor cameras currently installed. It is possible to call this function before any of the cameras are initialized. - - Synopsis: - (ret, totalCameras) = GetAvailableCameras() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of available cameras returned. - DRV_GENERAL_ERRORS - An error occurred while obtaining the number of available cameras. - totalCameras - the number of cameras currently installed - - C++ Equiv: - unsigned int GetAvailableCameras(long * totalCameras); - - See Also: - SetCurrentCamera GetCurrentCamera GetCameraHandle - - ''' - ctotalCameras = c_int() - ret = self.dll.GetAvailableCameras(byref(ctotalCameras)) - return (ret, ctotalCameras.value) - - def GetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetBackground(byref(carr), csize) - return (ret, carr.value) - - def GetBaselineClamp(self): - ''' - Description: - This function returns the status of the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - (ret, state) = GetBaselineClamp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - state - Baseline clamp functionality Enabled/Disabled: - 1 - Baseline Clamp Enabled - 0 - Baseline Clamp Disabled - - C++ Equiv: - unsigned int GetBaselineClamp(int * state); - - See Also: - SetBaselineClamp SetBaselineOffset - - ''' - cstate = c_int() - ret = self.dll.GetBaselineClamp(byref(cstate)) - return (ret, cstate.value) - - def GetBitDepth(self, channel): - ''' - Description: - This function will retrieve the size in bits of the dynamic range for any available AD channel. - - Synopsis: - (ret, depth) = GetBitDepth(channel) - - Inputs: - channel - the AD channel. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Depth returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel - depth - dynamic range in bits - - C++ Equiv: - unsigned int GetBitDepth(int channel, int * depth); - - See Also: - GetNumberADChannels SetADChannel - - ''' - cchannel = c_int(channel) - cdepth = c_int() - ret = self.dll.GetBitDepth(cchannel, byref(cdepth)) - return (ret, cdepth.value) - - def GetCameraEventStatus(self): - ''' - Description: - This function will return if the system is exposing or not. - - Synopsis: - (ret, camStatus) = GetCameraEventStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - camStatus - The status of the firepulse will be returned that the firepulse is low: - 0 - Fire pulse low - 1 - Fire pulse high - - C++ Equiv: - unsigned int GetCameraEventStatus(DWORD * camStatus); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: This is only supported by the CCI23 card. - - ''' - ccamStatus = () - ret = self.dll.GetCameraEventStatus(byref(ccamStatus)) - return (ret, ccamStatus.value) - - def GetCameraHandle(self, cameraIndex): - ''' - Description: - This function returns the handle for the camera specified by cameraIndex. When multiple Andor cameras are installed the handle of each camera must be retrieved in order to select a camera using the SetCurrentCamera function. - The number of cameras can be obtained using the GetAvailableCameras function. - - Synopsis: - (ret, cameraHandle) = GetCameraHandle(cameraIndex) - - Inputs: - cameraIndex - index of any of the installed cameras. 0 to NumberCameras-1 where NumberCameras is the value returned by the GetAvailableCamerasGetAvailableCameras functionGetAvailableCamerasGetNumberVerticalSpeedsGetNumberHSSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - DRV_P1INVALID - Invalid camera index. - cameraHandle - handle of the camera. - - C++ Equiv: - unsigned int GetCameraHandle(long cameraIndex, long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCurrentCamera - - ''' - ccameraIndex = c_int(cameraIndex) - ccameraHandle = c_int() - ret = self.dll.GetCameraHandle(ccameraIndex, byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCameraInformation(self, index): - ''' - Description: - This function will return information on a particular camera denoted by the index. - - Synopsis: - (ret, information) = GetCameraInformation(index) - - Inputs: - index - (reserved) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Driver status return - DRV_VXDNOTINSTALLED - Driver not installed - DRV_USBERROR - USB device error - information - current state of camera: - Bit:1 - USB camera present - Bit:2 - All dlls loaded properly - Bit:3 - Camera Initialized correctly - - C++ Equiv: - unsigned int GetCameraInformation(int index, long * information); - - See Also: - GetCameraHandle GetHeadModel GetCameraSerialNumber GetCapabilities - - Note: Only available in iDus. The index parameter is not used at present so should be set to 0. For any camera except the iDus The value of information following a call to this function will be zero. - - ''' - cindex = c_int(index) - cinformation = c_int() - ret = self.dll.GetCameraInformation(cindex, byref(cinformation)) - return (ret, cinformation.value) - - def GetCameraSerialNumber(self): - ''' - Description: - This function will retrieve camera's serial number. - - Synopsis: - (ret, number) = GetCameraSerialNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Serial Number returned. - DRV_NOT_INITIALIZED - System not initialized. - number - Serial Number. - - C++ Equiv: - unsigned int GetCameraSerialNumber(int * number); - - See Also: - GetCameraHandle GetHeadModel GetCameraInformation GetCapabilities - - ''' - cnumber = c_int() - ret = self.dll.GetCameraSerialNumber(byref(cnumber)) - return (ret, cnumber.value) - - def GetCapabilities(self): - ''' - Description: - This function will fill in an AndorCapabilities structure with the capabilities associated with the connected camera. Before passing the address of an AndorCapabilites structure to the function the ulSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - caps->ulSize = sizeof(AndorCapabilities); - Individual capabilities are determined by examining certain bits and combinations of bits in the member variables of the AndorCapabilites structure. - - Synopsis: - (ret, caps) = GetCapabilities() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized - DRV_SUCCESS - Capabilities returned. - DRV_P1INVALID - Invalid caps parameter (i.e. NULL). - caps - the capabilities structure to be filled in. - - C++ Equiv: - unsigned int GetCapabilities(AndorCapabilities * caps); - - See Also: - GetCameraHandle GetCameraSerialNumber GetHeadModel GetCameraInformation - - ''' - caps = AndorCapabilities() - caps.ulSize = sizeof(caps) - ret = self.dll.GetCapabilities(byref(caps)) - return (ret, caps) - - def GetControllerCardModel(self): - ''' - Description: - This function will retrieve the type of PCI controller card included in your system. This function is not applicable for USB systems. The maximum number of characters that can be returned from this function is 10. - - Synopsis: - (ret, controllerCardModel) = GetControllerCardModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized - controllerCardModel - A user allocated array of characters for storage of the controller card model. - - C++ Equiv: - unsigned int GetControllerCardModel(char * controllerCardModel); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - ccontrollerCardModel = create_string_buffer(10) - ret = self.dll.GetControllerCardModel(ccontrollerCardModel) - return (ret, ccontrollerCardModel) - - def GetCountConvertWavelengthRange(self): - ''' - Description: - This function returns the valid wavelength range available in Count Convert mode. - - Synopsis: - (ret, minval, maxval) = GetCountConvertWavelengthRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - minval - minimum wavelength permited. - maxval - maximum wavelength permited. - - C++ Equiv: - unsigned int GetCountConvertWavelengthRange(float * minval, float * maxval); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cminval = c_float() - cmaxval = c_float() - ret = self.dll.GetCountConvertWavelengthRange(byref(cminval), byref(cmaxval)) - return (ret, cminval.value, cmaxval.value) - - def GetCurrentCamera(self): - ''' - Description: - When multiple Andor cameras are installed this function returns the handle of the currently selected one. - - Synopsis: - (ret, cameraHandle) = GetCurrentCamera() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - cameraHandle - handle of the currently selected camera - - C++ Equiv: - unsigned int GetCurrentCamera(long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int() - ret = self.dll.GetCurrentCamera(byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCYMGShift(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, iXshift, iYShift) = GetCYMGShift() - - Inputs: - None - - Outputs: - ret - Function Return Code - iXshift - - iYShift - - - C++ Equiv: - unsigned int GetCYMGShift(int * iXshift, int * iYShift); - - ''' - ciXshift = c_int() - ciYShift = c_int() - ret = self.dll.GetCYMGShift(byref(ciXshift), byref(ciYShift)) - return (ret, ciXshift.value, ciYShift.value) - - def GetDDGExternalOutputEnabled(self, uiIndex): - ''' - Description: - This function gets the current state of a selected external output. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputPolarity(self, uiIndex): - ''' - Description: - This function gets the current polarity of a selected external output. - - Synopsis: - (ret, puiPolarity) = GetDDGExternalOutputPolarity(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiPolarity - current polarity of external output (0 - Positive, 1 - Negative). - - C++ Equiv: - unsigned int GetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 * puiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputPolarity SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiPolarity = c_uint() - ret = self.dll.GetDDGExternalOutputPolarity(cuiIndex, byref(cpuiPolarity)) - return (ret, cpuiPolarity.value) - - def GetDDGExternalOutputStepEnabled(self, uiIndex): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to determine if this option is currently active. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputStepEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output track step (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputStepEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputStepEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputTime(self, uiIndex): - ''' - Description: - This function can be used to find the actual timings for a particular external output. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGExternalOutputTime(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Delay has invalid memory address. - puiDelay - actual external output delay time in picoseconds. - puiWidth - actual external output width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGExternalOutputTime(at_u32 uiIndex, at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputTime SetDDGGateStep - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGExternalOutputTime(cuiIndex, byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGGateTime(self): - ''' - Description: - This function can be used to get the actual gate timings for a USB iStar. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGGateTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Delay has invalid memory address. - puiDelay - gate delay time in picoseconds. - puiWidth - gate width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGGateTime(at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities SetDDGGateTimeSetDDGGateStep - - ''' - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGGateTime(byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGInsertionDelay(self): - ''' - Description: - This function gets the current state of the insertion delay. - - Synopsis: - (ret, piState) = GetDDGInsertionDelay() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Insertion delay state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Insertion delay not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the insertion delay option (0 - Normal, 1 - Ultra Fast). - - C++ Equiv: - unsigned int GetDDGInsertionDelay(int * piState); - - See Also: - GetCapabilities SetDDGInsertionDelay SetDDGIntelligate - - ''' - cpiState = c_int() - ret = self.dll.GetDDGInsertionDelay(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIntelligate(self): - ''' - Description: - This function gets the current state of intelligate. - - Synopsis: - (ret, piState) = GetDDGIntelligate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - intelligate not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the intelligate option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIntelligate(int * piState); - - See Also: - GetCapabilities SetDDGIntelligate SetDDGInsertionDelay - - ''' - cpiState = c_int() - ret = self.dll.GetDDGIntelligate(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIOC(self): - ''' - Description: - This function gets the current state of the integrate on chip (IOC) option. - - Synopsis: - (ret, state) = GetDDGIOC() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - state has invalid memory address. - state - current state of the IOC option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIOC(int * state); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency - - ''' - cstate = c_int() - ret = self.dll.GetDDGIOC(byref(cstate)) - return (ret, cstate.value) - - def GetDDGIOCFrequency(self): - ''' - Description: - This function can be used to return the actual IOC frequency that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, frequency) = GetDDGIOCFrequency() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - frequency - the frequency of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCFrequency(double * frequency); - - See Also: - GetCapabilities SetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cfrequency = c_double() - ret = self.dll.GetDDGIOCFrequency(byref(cfrequency)) - return (ret, cfrequency.value) - - def GetDDGIOCNumber(self): - ''' - Description: - This function can be used to return the actual number of pulses that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, numberPulses) = GetDDGIOCNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCNumber(unsigned long * numberPulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cnumberPulses = c_ulong() - ret = self.dll.GetDDGIOCNumber(byref(cnumberPulses)) - return (ret, cnumberPulses.value) - - def GetDDGIOCNumberRequested(self): - ''' - Description: - This function can be used to return the number of pulses that were requested by the user. - - Synopsis: - (ret, pulses) = GetDDGIOCNumberRequested() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - pulses has invalid memory address. - pulses - the number of integrate on chip pulses requested. - - C++ Equiv: - unsigned int GetDDGIOCNumberRequested(at_u32 * pulses); - - See Also: - GetCapabilities SetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_uint() - ret = self.dll.GetDDGIOCNumberRequested(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCPeriod(self): - ''' - Description: - This function can be used to return the actual IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, period) = GetDDGIOCPeriod() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - period has invalid memory address. - period - the period of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPeriod(at_u64 * period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCPeriod SetDDGIOCFrequency - - ''' - cperiod = c_ulonglong() - ret = self.dll.GetDDGIOCPeriod(byref(cperiod)) - return (ret, cperiod.value) - - def GetDDGIOCPulses(self): - ''' - Description: - This function can be used to calculate the number of pulses that will be triggered with the given exposure time, readout mode, acquisition mode and integrate on chip frequency. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, pulses) = GetDDGIOCPulses() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - pulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPulses(int * pulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_int() - ret = self.dll.GetDDGIOCPulses(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCTrigger(self): - ''' - Description: - function can be used to retrieve the active IOC trigger. - at_u32* trigger: active IOC trigger (0 - Fire pulse, 1 - External trigger). - at_u32 int - DRV_SUCCESS - DRV_NOT_INITIALIZED - DRV_NOT_SUPPORTED - DRV_ACQUIRING - DRV_ERROR_ACK - DRV_P1INVALID - IOC trigger returned. - System not initialized. - IOC not supported. - Acquisition in progress. - Unable to communicate with system. - Invalid trigger. - See also - GetCapabilities SetDDGIOC SetDDGIOCFrequency SetDDGIOCTrigger SetTriggerMode - GetDDGLiteControlByte - GetDDGLiteControlByte int WINAPI GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control) - Description - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, trigger) = GetDDGIOCTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code - trigger - - - C++ Equiv: - unsigned int GetDDGIOCTrigger(at_u32 * trigger); - - ''' - ctrigger = c_uint() - ret = self.dll.GetDDGIOCTrigger(byref(ctrigger)) - return (ret, ctrigger.value) - - def GetDDGLiteControlByte(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, control) = GetDDGLiteControlByte(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control); - - ''' - cchannel = (channel) - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteControlByte(cchannel, byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteGlobalControlByte(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, control) = GetDDGLiteGlobalControlByte() - - Inputs: - None - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteGlobalControlByte(unsigned char * control); - - ''' - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteGlobalControlByte(byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteInitialDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInitialDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInitialDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLiteInterPulseDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInterPulseDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInterPulseDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLitePulsesPerExposure(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, ui32Pulses) = GetDDGLitePulsesPerExposure(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - ui32Pulses - - - C++ Equiv: - unsigned int GetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 * ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint() - ret = self.dll.GetDDGLitePulsesPerExposure(cchannel, byref(cui32Pulses)) - return (ret, cui32Pulses.value) - - def GetDDGLitePulseWidth(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fWidth) = GetDDGLitePulseWidth(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fWidth - - - C++ Equiv: - unsigned int GetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float * fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float() - ret = self.dll.GetDDGLitePulseWidth(cchannel, byref(cfWidth)) - return (ret, cfWidth.value) - - def GetDDGOpticalWidthEnabled(self): - ''' - Description: - This function can be used to check whether optical gate widths are being used. - - Synopsis: - (ret, puiEnabled) = GetDDGOpticalWidthEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiEnabled - optical gate width option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGOpticalWidthEnabled(at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth - - ''' - cpuiEnabled = c_uint() - ret = self.dll.GetDDGOpticalWidthEnabled(byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGPulse(self, wid, resolution): - ''' - Description: - This function attempts to find a laser pulse in a user-defined region with a given resolution. The values returned will provide an estimation of the location of the pulse. - - Synopsis: - (ret, Delay, Width) = GetDDGPulse(wid, resolution) - - Inputs: - wid - the time in picoseconds of the region to be searched. - resolution - the minimum gate pulse used to locate the laser. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Location returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - Delay - the approximate start of the laser pulse. - Width - the pulse width, which encapsulated the laser pulse. - - C++ Equiv: - unsigned int GetDDGPulse(double wid, double resolution, double * Delay, double * Width); - - Note: Available in iStar. - - ''' - cwid = c_double(wid) - cresolution = c_double(resolution) - cDelay = c_double() - cWidth = c_double() - ret = self.dll.GetDDGPulse(cwid, cresolution, byref(cDelay), byref(cWidth)) - return (ret, cDelay.value, cWidth.value) - - def GetDDGStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate step mode. - - Synopsis: - (ret, p1, p2) = GetDDGStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - First coefficient - p2 - Second coefficient - - C++ Equiv: - unsigned int GetDDGStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGStepMode(self): - ''' - Description: - This function will return the current gate step mode. - - Synopsis: - (ret, mode) = GetDDGStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGStepMode(at_u32 * mode); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint() - ret = self.dll.GetDDGStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDDGTTLGateWidth(self, opticalWidth): - ''' - Description: - This function can be used to get the TTL gate width which corresponds to a particular optical gate width. - - Synopsis: - (ret, ttlWidth) = GetDDGTTLGateWidth(opticalWidth) - - Inputs: - opticalWidth - optical gate width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P2_INVALID - Unable to communicate with system. - ttlWidth - TTL gate width in picoseconds. - - C++ Equiv: - unsigned int GetDDGTTLGateWidth(at_u64 opticalWidth, at_u64 * ttlWidth); - - See Also: - GetCapabilities SetDDGOpticalWidthEnabled SetDDGGateStep - - ''' - copticalWidth = c_ulonglong(opticalWidth) - cttlWidth = c_ulonglong() - ret = self.dll.GetDDGTTLGateWidth(copticalWidth, byref(cttlWidth)) - return (ret, cttlWidth.value) - - def GetDDGWidthStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate width step mode. - - Synopsis: - (ret, p1, p2) = GetDDGWidthStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - The first coefficient. - p2 - The second coefficient. - - C++ Equiv: - unsigned int GetDDGWidthStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepMode - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGWidthStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGWidthStepMode(self): - ''' - Description: - This function will return the current gate width step mode. - - Synopsis: - (ret, mode) = GetDDGWidthStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGWidthStepMode(at_u32 * mode); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepCoefficients StartAcquisition - - ''' - cmode = c_uint() - ret = self.dll.GetDDGWidthStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDetector(self): - ''' - Description: - This function returns the size of the detector in pixels. The horizontal axis is taken to be the axis parallel to the readout register. - - Synopsis: - (ret, xpixels, ypixels) = GetDetector() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Detector size returned. - DRV_NOT_INITIALIZED - System not initialized. - xpixels - number of horizontal pixels. - ypixels - number of vertical pixels. - - C++ Equiv: - unsigned int GetDetector(int * xpixels, int * ypixels); - - ''' - cxpixels = c_int() - cypixels = c_int() - ret = self.dll.GetDetector(byref(cxpixels), byref(cypixels)) - return (ret, cxpixels.value, cypixels.value) - - def GetDICameraInfo(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, info) = GetDICameraInfo() - - Inputs: - None - - Outputs: - ret - Function Return Code - info - - - C++ Equiv: - unsigned int GetDICameraInfo(void * info); - - ''' - cinfo = c_void() - ret = self.dll.GetDICameraInfo(byref(cinfo)) - return (ret, cinfo.value) - - def GetDualExposureTimes(self): - ''' - Description: - This function will return the current valid acquisition timing information for dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - (ret, exposure1, exposure2) = GetDualExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. . - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_NOT_AVAILABLE - Dual exposure mode not configured correctly. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - exposure1 has invalid memory address. - DRV_P2INVALID - exposure2 has invalid memory address. - exposure1 - valid exposure time in seconds for each odd numbered frame. - exposure2 - valid exposure time in seconds for each even numbered frame. - - C++ Equiv: - unsigned int GetDualExposureTimes(float * exposure1, float * exposure2); - - See Also: - GetCapabilities SetDualExposureMode SetDualExposureTimes - - ''' - cexposure1 = c_float() - cexposure2 = c_float() - ret = self.dll.GetDualExposureTimes(byref(cexposure1), byref(cexposure2)) - return (ret, cexposure1.value, cexposure2.value) - - def GetEMAdvanced(self): - ''' - Description: - Returns the current Advanced gain setting. - - Synopsis: - (ret, state) = GetEMAdvanced() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Advanced state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - state has invalid memory address. - state - current EM advanced gain setting - - C++ Equiv: - unsigned int GetEMAdvanced(int * state); - - ''' - cstate = c_int() - ret = self.dll.GetEMAdvanced(byref(cstate)) - return (ret, cstate.value) - - def GetEMCCDGain(self): - ''' - Description: - Returns the current gain setting. The meaning of the value returned depends on the EM Gain mode. - - Synopsis: - (ret, gain) = GetEMCCDGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - gain - current EM gain setting - - C++ Equiv: - unsigned int GetEMCCDGain(int * gain); - - ''' - cgain = c_int() - ret = self.dll.GetEMCCDGain(byref(cgain)) - return (ret, cgain.value) - - def GetEMGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the current selected EM Gain mode and temperature of the sensor. - - Synopsis: - (ret, low, high) = GetEMGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - low - lowest gain setting - high - highest gain setting - - C++ Equiv: - unsigned int GetEMGainRange(int * low, int * high); - - ''' - clow = c_int() - chigh = c_int() - ret = self.dll.GetEMGainRange(byref(clow), byref(chigh)) - return (ret, clow.value, chigh.value) - - def GetExternalTriggerTermination(self): - ''' - Description: - This function can be used to get the current external trigger termination mode. - - Synopsis: - (ret, puiTermination) = GetExternalTriggerTermination() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - C++ Equiv: - unsigned int GetExternalTriggerTermination(at_u32 * puiTermination); - - See Also: - GetCapabilities SetExternalTriggerTermination - - ''' - cpuiTermination = c_uint() - ret = self.dll.GetExternalTriggerTermination(byref(cpuiTermination)) - return (ret, cpuiTermination.value) - - def GetFastestRecommendedVSSpeed(self): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the fastest recommended speed available. The very high readout speeds, may require an increase in the amplitude of the Vertical Clock Voltage using SetVSAmplitudeSetVSAmplitude. This function returns the fastest speed which does not require the Vertical Clock Voltage to be adjusted. The values returned are the vertical shift speed index and the actual speed in microseconds per pixel shift. - - Synopsis: - (ret, index, speed) = GetFastestRecommendedVSSpeed() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - index - index of the fastest recommended vertical shift speed - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetFastestRecommendedVSSpeed(int * index, float * speed); - - See Also: - GetVSSpeed GetNumberVSSpeeds SetVSSpeed - - ''' - cindex = c_int() - cspeed = c_float() - ret = self.dll.GetFastestRecommendedVSSpeed(byref(cindex), byref(cspeed)) - return (ret, cindex.value, cspeed.value) - - def GetFIFOUsage(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, FIFOusage) = GetFIFOUsage() - - Inputs: - None - - Outputs: - ret - Function Return Code - FIFOusage - - - C++ Equiv: - unsigned int GetFIFOUsage(int * FIFOusage); - - ''' - cFIFOusage = c_int() - ret = self.dll.GetFIFOUsage(byref(cFIFOusage)) - return (ret, cFIFOusage.value) - - def GetFilterMode(self): - ''' - Description: - This function returns the current state of the cosmic ray filtering mode. - - Synopsis: - (ret, mode) = GetFilterMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mode - current state of filter: - 0 - OFF - 2 - ON - - C++ Equiv: - unsigned int GetFilterMode(int * mode); - - See Also: - SetFilterMode - - ''' - cmode = c_int() - ret = self.dll.GetFilterMode(byref(cmode)) - return (ret, cmode.value) - - def GetFKExposureTime(self): - ''' - Description: - This function will return the current "valid" exposure time for a fast kinetics acquisition. This function should be used after all the acquisitions settings have been set, i.e. SetFastKineticsSetFastKinetics and SetFKVShiftSpeedSetFKVShiftSpeed. The value returned is the actual time used in subsequent acquisitions. - - Synopsis: - (ret, time) = GetFKExposureTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Fast kinetics is not available. - time - valid exposure time in seconds - - C++ Equiv: - unsigned int GetFKExposureTime(float * time); - - See Also: - SetFastKinetics SetFKVShiftSpeed - - ''' - ctime = c_float() - ret = self.dll.GetFKExposureTime(byref(ctime)) - return (ret, ctime.value) - - def GetFKVShiftSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Deprecated by GetFKVShiftSpeedFGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetFKVShiftSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFKVShiftSpeedF(self, index): - ''' - Description: - As your Andor system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeedF(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeedF(int index, float * speed); - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetFKVShiftSpeedF(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFrontEndStatus(self): - ''' - Description: - This function will return if the Front End cooler has overheated. - - Synopsis: - (ret, piFlag) = GetFrontEndStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Front End cooler not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the front end cooler: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetFrontEndStatus(int * piFlag); - - See Also: - SetFrontEndEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetFrontEndStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetGateMode(self): - ''' - Description: - Allows the user to get the current photocathode gating mode. - - Synopsis: - (ret, piGatemode) = GetGateMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - gatemode has invalid memory address. - piGatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - C++ Equiv: - unsigned int GetGateMode(int * piGatemode); - - See Also: - GetCapabilities SetGateMode - - ''' - cpiGatemode = c_int() - ret = self.dll.GetGateMode(byref(cpiGatemode)) - return (ret, cpiGatemode.value) - - def GetHardwareVersion(self): - ''' - Description: - This function returns the Hardware version information. - - Synopsis: - (ret, PCB, Decode, dummy1, dummy2, CameraFirmwareVersion, CameraFirmwareBuild) = GetHardwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - PCB - Plug-in card version - Decode - Flex 10K file version - dummy1 - - dummy2 - - CameraFirmwareVersion - Version number of camera firmware - CameraFirmwareBuild - Build number of camera firmware - - C++ Equiv: - unsigned int GetHardwareVersion(unsigned int * PCB, unsigned int * Decode, unsigned int * dummy1, unsigned int * dummy2, unsigned int * CameraFirmwareVersion, unsigned int * CameraFirmwareBuild); - - ''' - cPCB = c_uint() - cDecode = c_uint() - cdummy1 = c_uint() - cdummy2 = c_uint() - cCameraFirmwareVersion = c_uint() - cCameraFirmwareBuild = c_uint() - ret = self.dll.GetHardwareVersion(byref(cPCB), byref(cDecode), byref(cdummy1), byref(cdummy2), byref(cCameraFirmwareVersion), byref(cCameraFirmwareBuild)) - return (ret, cPCB.value, cDecode.value, cdummy1.value, cdummy2.value, cCameraFirmwareVersion.value, cCameraFirmwareBuild.value) - - def GetHeadModel(self): - ''' - Description: - This function will retrieve the type of CCD attached to your system. - - Synopsis: - (ret, name) = GetHeadModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized. - name - A user allocated array of characters for storage of the Head Model. This should be declared as size MAX_PATH. - - C++ Equiv: - unsigned int GetHeadModel(char * name); - - ''' - cname = create_string_buffer(MAX_PATH) - ret = self.dll.GetHeadModel(cname) - return (ret, cname.value) - - def GetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetHorizontalSpeed(index) - - Inputs: - index - speed required, 0 to NumberSpeeds-1, where NumberSpeeds is the parameter returned by GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetHorizontalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberHorizontalSpeeds SetHorizontalSpeed - - Note: Deprecated by GetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetHorizontalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHSSpeed(self, channel, typ, index): - ''' - Description: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in MHz. - - Synopsis: - (ret, speed) = GetHSSpeed(channel, typ, index) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR Mode(clara). - index - speed required Valid values: 0 to NumberSpeeds-1, where NumberSpeeds is value returned in first parameter after a call to GetNumberHSSpeedsGetNumberHSSpeeds(). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - DRV_P3INVALID - Invalid index - speed - speed in in MHz. - - C++ Equiv: - unsigned int GetHSSpeed(int channel, int typ, int index, float * speed); - - See Also: - GetNumberHSSpeeds SetHSSpeed - - Note: The speed is returned in microseconds per pixel shift for iStar and Classic systems. - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetHSSpeed(cchannel, ctyp, cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHVflag(self): - ''' - Description: - This function will retrieve the High Voltage flag from your USB iStar intensifier. A 0 value indicates that the high voltage is abnormal. - - Synopsis: - (ret, bFlag) = GetHVflag() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - HV flag returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - bFlag - pointer to High Voltage flag. - - C++ Equiv: - unsigned int GetHVflag(int * bFlag); - - Note: Available only on USB iStar. - - ''' - cbFlag = c_int() - ret = self.dll.GetHVflag(byref(cbFlag)) - return (ret, cbFlag.value) - - def GetID(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, id) = GetID(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - id - - - C++ Equiv: - unsigned int GetID(int devNum, int * id); - - ''' - cdevNum = c_int(devNum) - cid = c_int() - ret = self.dll.GetID(cdevNum, byref(cid)) - return (ret, cid.value) - - def GetImageFlip(self): - ''' - Description: - This function will obtain whether the acquired data output is flipped in either the horizontal or vertical direction. - - Synopsis: - (ret, iHFlip, iVFlip) = GetImageFlip() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - iHFlip - Gets horizontal flipping. - iVFlip - Gets vertical flipping.: - 1 - Flipping Enabled - 0 - Flipping Disabled - - C++ Equiv: - unsigned int GetImageFlip(int * iHFlip, int * iVFlip); - - See Also: - SetImageRotate SetImageFlip - - ''' - ciHFlip = c_int() - ciVFlip = c_int() - ret = self.dll.GetImageFlip(byref(ciHFlip), byref(ciVFlip)) - return (ret, ciHFlip.value, ciVFlip.value) - - def GetImageRotate(self): - ''' - Description: - This function will obtain whether the acquired data output is rotated in any direction. - - Synopsis: - (ret, iRotate) = GetImageRotate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - iRotate - Rotation setting: - 0 - - No rotation - 1 - - Rotate 90 degrees clockwise - 2 - - Rotate 90 degrees anti-clockwise - - C++ Equiv: - unsigned int GetImageRotate(int * iRotate); - - See Also: - SetImageFlip SetImageRotate SetReadMode - - ''' - ciRotate = c_int() - ret = self.dll.GetImageRotate(byref(ciRotate)) - return (ret, ciRotate.value) - - def GetImages(self, first, last, size): - ''' - Description: - This function will update the data array with the specified series of images from the circular buffer. If the specified series is out of range (i.e. the images have been overwritten or have not yet been acquired then an error will be returned. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages(long first, long last, at_32 * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages16 GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_int * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImages16(self, first, last, size): - ''' - Description: - 16-bit version of the GetImagesGetImages function. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages16(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages16(long first, long last, WORD * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_short * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages16(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImagesPerDMA(self): - ''' - Description: - This function will return the maximum number of images that can be transferred during a single DMA transaction. - - Synopsis: - (ret, images) = GetImagesPerDMA() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of images per DMA returned. - images - The maximum number of images that can be transferred during a single DMA transaction - - C++ Equiv: - unsigned int GetImagesPerDMA(unsigned long * images); - - ''' - cimages = c_ulong() - ret = self.dll.GetImagesPerDMA(byref(cimages)) - return (ret, cimages.value) - - def GetIODirection(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iDirection) = GetIODirection(index) - - Inputs: - index - IO index. Valid values: 0 to GetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iDirection - current direction for this index.: - 0 - 0 Output - 1 - 1 Input - - C++ Equiv: - unsigned int GetIODirection(int index, int * iDirection); - - See Also: - GetNumberIO GetIOLevel SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int() - ret = self.dll.GetIODirection(cindex, byref(ciDirection)) - return (ret, ciDirection.value) - - def GetIOLevel(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iLevel) = GetIOLevel(index) - - Inputs: - index - IO index: - 0 - toGetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - C++ Equiv: - unsigned int GetIOLevel(int index, int * iLevel); - - See Also: - GetNumberIO GetIODirection SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciLevel = c_int() - ret = self.dll.GetIOLevel(cindex, byref(ciLevel)) - return (ret, ciLevel.value) - - def GetIRQ(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, IRQ) = GetIRQ() - - Inputs: - None - - Outputs: - ret - Function Return Code - IRQ - - - C++ Equiv: - unsigned int GetIRQ(int * IRQ); - - ''' - cIRQ = c_int() - ret = self.dll.GetIRQ(byref(cIRQ)) - return (ret, cIRQ.value) - - def GetKeepCleanTime(self): - ''' - Description: - This function will return the time to perform a keep clean cycle. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, KeepCleanTime) = GetKeepCleanTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - KeepCleanTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetKeepCleanTime(float * KeepCleanTime); - - See Also: - GetAcquisitionTimings GetReadOutTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cKeepCleanTime = c_float() - ret = self.dll.GetKeepCleanTime(byref(cKeepCleanTime)) - return (ret, cKeepCleanTime.value) - - def GetMaximumBinning(self, ReadMode, HorzVert): - ''' - Description: - This function will return the maximum binning allowable in either the vertical or horizontal dimension for a particular readout mode. - - Synopsis: - (ret, MaxBinning) = GetMaximumBinning(ReadMode, HorzVert) - - Inputs: - ReadMode - The readout mode for which to retrieve the maximum binning (see SetReadMode for possible values). - HorzVert - 0 to retrieve horizontal binning limit, 1 to retreive limit in the vertical. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Binning returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid Readmode - DRV_P2INVALID - HorzVert not equal to 0 or 1 - DRV_P3INVALID - Invalid MaxBinning address (i.e. NULL) - MaxBinning - Will contain the Maximum binning value on return. - - C++ Equiv: - unsigned int GetMaximumBinning(int ReadMode, int HorzVert, int * MaxBinning); - - See Also: - GetMinimumImageLength SetReadMode - - ''' - cReadMode = c_int(ReadMode) - cHorzVert = c_int(HorzVert) - cMaxBinning = c_int() - ret = self.dll.GetMaximumBinning(cReadMode, cHorzVert, byref(cMaxBinning)) - return (ret, cMaxBinning.value) - - def GetMaximumExposure(self): - ''' - Description: - This function will return the maximum Exposure Time in seconds that is settable by the SetExposureTime function. - - Synopsis: - (ret, MaxExp) = GetMaximumExposure() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Exposure returned. - DRV_P1INVALID - Invalid MaxExp value (i.e. NULL) - MaxExp - Will contain the Maximum exposure value on return. - - C++ Equiv: - unsigned int GetMaximumExposure(float * MaxExp); - - See Also: - SetExposureTime - - ''' - cMaxExp = c_float() - ret = self.dll.GetMaximumExposure(byref(cMaxExp)) - return (ret, cMaxExp.value) - - def GetMaximumNumberRingExposureTimes(self): - ''' - Description: - This function will return the maximum number of exposures that can be configured in the SetRingExposureTimes SDK function. - - Synopsis: - (ret, number) = GetMaximumNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number value (ie NULL) - DRV_NOTAVAILABLE - System does not support this option - number - Will contain the maximum number of exposures on return. - - C++ Equiv: - unsigned int GetMaximumNumberRingExposureTimes(int * number); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable SetRingExposureTimes - - ''' - cnumber = c_int() - ret = self.dll.GetMaximumNumberRingExposureTimes(byref(cnumber)) - return (ret, cnumber.value) - - def GetMCPGain(self): - ''' - Description: - This function will retrieve the set value for the MCP Gain. - - Synopsis: - (ret, gain) = GetMCPGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Table returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Invalid pointer (i.e. NULL) - DRV_NOT_AVAILABLE - Not a USB iStar - gain - Returned gain value. - - C++ Equiv: - unsigned int GetMCPGain(int * gain); - - See Also: - SetMCPGain - - Note: Available only on USB iStar. - - ''' - cgain = c_int() - ret = self.dll.GetMCPGain(byref(cgain)) - return (ret, cgain.value) - - def GetMCPGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the SetMCPGain function. - - Synopsis: - (ret, iLow, iHigh) = GetMCPGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - iLow - lowest gain setting - iHigh - highest gain setting - - C++ Equiv: - unsigned int GetMCPGainRange(int * iLow, int * iHigh); - - See Also: - SetMCPGain - - Note: Available only iStar. - - ''' - ciLow = c_int() - ciHigh = c_int() - ret = self.dll.GetMCPGainRange(byref(ciLow), byref(ciHigh)) - return (ret, ciLow.value, ciHigh.value) - - def GetMCPGainTable(self, iNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, piGain, pfPhotoepc) = GetMCPGainTable(iNum) - - Inputs: - iNum - - - Outputs: - ret - Function Return Code - piGain - - pfPhotoepc - - - C++ Equiv: - unsigned int GetMCPGainTable(int iNum, int * piGain, float * pfPhotoepc); - - ''' - ciNum = c_int(iNum) - cpiGain = c_int() - cpfPhotoepc = c_float() - ret = self.dll.GetMCPGainTable(ciNum, byref(cpiGain), byref(cpfPhotoepc)) - return (ret, cpiGain.value, cpfPhotoepc.value) - - def GetMCPVoltage(self): - ''' - Description: - This function will retrieve the current Micro Channel Plate voltage. - - Synopsis: - (ret, iVoltage) = GetMCPVoltage() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Voltage returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - DRV_GENERAL_ERRORS - EEPROM not valid - iVoltage - Will contain voltage on return. The unit is in Volts and should be between the range 600 - 1100 Volts. - - C++ Equiv: - unsigned int GetMCPVoltage(int * iVoltage); - - See Also: - GetMCPGain - - Note: Available only on USB iStar. - - ''' - ciVoltage = c_int() - ret = self.dll.GetMCPVoltage(byref(ciVoltage)) - return (ret, ciVoltage.value) - - def GetMetaDataInfo(self, index): - ''' - Description: - This function will return the time of the initial frame and the time in milliseconds of further frames from this point. - - Synopsis: - (ret, TimeOfStart, pfTimeFromStart) = GetMetaDataInfo(index) - - Inputs: - index - frame for which time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - TimeOfStart - Structure with start time details. - pfTimeFromStart - time in milliseconds for a particular frame from time of start. - - C++ Equiv: - unsigned int GetMetaDataInfo(SYSTEMTIME * TimeOfStart, float * pfTimeFromStart, int index); - - See Also: - SetMetaData - - ''' - cTimeOfStart = SYSTEMTIME() - cpfTimeFromStart = c_float() - cindex = c_int(index) - ret = self.dll.GetMetaDataInfo(byref(cTimeOfStart), byref(cpfTimeFromStart), cindex) - return (ret, cTimeOfStart, cpfTimeFromStart.value) - - def GetMinimumImageLength(self): - ''' - Description: - This function will return the minimum number of pixels that can be read out from the chip at each exposure. This minimum value arises due the way in which the chip is read out and will limit the possible sub image dimensions and binning sizes that can be applied. - - Synopsis: - (ret, MinImageLength) = GetMinimumImageLength() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum Number of Pixels returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid MinImageLength value (i.e. NULL) - MinImageLength - Will contain the minimum number of super pixels on return. - - C++ Equiv: - unsigned int GetMinimumImageLength(int * MinImageLength); - - See Also: - SetImage - - ''' - cMinImageLength = c_int() - ret = self.dll.GetMinimumImageLength(byref(cMinImageLength)) - return (ret, cMinImageLength.value) - - def GetMinimumNumberInSeries(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, number) = GetMinimumNumberInSeries() - - Inputs: - None - - Outputs: - ret - Function Return Code - number - - - C++ Equiv: - unsigned int GetMinimumNumberInSeries(int * number); - - ''' - cnumber = c_int() - ret = self.dll.GetMinimumNumberInSeries(byref(cnumber)) - return (ret, cnumber.value) - - def GetMostRecentColorImage16(self, size, algorithm): - ''' - Description: - For colour sensors only. - Color version of the GetMostRecentImage16 function. The CCD is sensitive to Cyan, Yellow, Magenta and Green (CYMG). The Red, Green and Blue (RGB) are calculated and Data is stored in 3 planes/images, one for each basic color. - - Synopsis: - (ret, red, green, blue) = GetMostRecentColorImage16(size, algorithm) - - Inputs: - size - total number of pixels. - algorithm - algorithm used to extract the RGB from the original CYMG CCD.: - 0 - 0 basic algorithm combining Cyan, Yellow and Magenta. - 1 - 1 algorithm combining Cyan, Yellow, Magenta and Green. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image RGB has been copied into arrays. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Arrays size is incorrect. - DRV_P2INVALID - Invalid algorithm. - DRV_P3INVALID - Invalid red pointer (i.e. NULL).. - DRV_P4INVALID - Invalid green pointer (i.e. NULL).. - DRV_P5INVALID - Invalid bluepointer (i.e. NULL).. - DRV_NO_NEW_DATA - There is no new data yet. - red - pointer to red data storage allocated by the user. - green - pointer to red data storage allocated by the user. - blue - pointer to red data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentColorImage16(unsigned long size, int algorithm, WORD * red, WORD * green, WORD * blue); - - See Also: - GetMostRecentImage16 DemosaicImage WhiteBalance - - ''' - csize = c_ulong(size) - calgorithm = c_int(algorithm) - cred = (c_short * size)() - cgreen = (c_short * size)() - cblue = (c_short * size)() - ret = self.dll.GetMostRecentColorImage16(csize, calgorithm, cred, cgreen, cblue) - return (ret, cred, cgreen, cblue) - - def GetMostRecentImage(self, size): - ''' - Description: - This function will update the data array with the most recently acquired image in any acquisition mode. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the complete image. - - Synopsis: - (ret, arr) = GetMostRecentImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage(at_32 * arr, unsigned long size); - - See Also: - GetMostRecentImage16 GetOldestImage GetOldestImage16 GetImages - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetMostRecentImage(carr, csize) - return (ret, carr) - - def GetMostRecentImage16(self, size): - ''' - Description: - 16-bit version of the GetMostRecentImageGetMostRecentImage function. - - Synopsis: - (ret, arr) = GetMostRecentImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage16(WORD * arr, long size); - - See Also: - GetMostRecentImage GetOldestImage16 GetOldestImage GetImages - - ''' - carr = (c_short * size)() - csize = c_int(size) - ret = self.dll.GetMostRecentImage16(carr, csize) - return (ret, carr) - - def GetMSTimingsData(self, inoOfImages): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, TimeOfStart, pfDifferences) = GetMSTimingsData(inoOfImages) - - Inputs: - inoOfImages - - - Outputs: - ret - Function Return Code - TimeOfStart - - pfDifferences - - - C++ Equiv: - unsigned int GetMSTimingsData(SYSTEMTIME * TimeOfStart, float * pfDifferences, int inoOfImages); - - ''' - cTimeOfStart = SYSTEMTIME() - cpfDifferences = c_float() - cinoOfImages = c_int(inoOfImages) - ret = self.dll.GetMSTimingsData(byref(cTimeOfStart), byref(cpfDifferences), cinoOfImages) - return (ret, cTimeOfStart, cpfDifferences.value) - - def GetMSTimingsEnabled(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = GetMSTimingsEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int GetMSTimingsEnabled(void); - - ''' - ret = self.dll.GetMSTimingsEnabled() - return (ret) - - def GetNewData(self, size): - ''' - Description: - Deprecated see Note: - This function will update the data array to hold data acquired so far. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. When used in conjunction with the SetDriverEventSetDriverEvent and GetAcquisitonProgressGetAcquisitionProgress functions, the data from each scan in a kinetic series can be processed while the acquisition is taking place. - - Synopsis: - (ret, arr) = GetNewData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData(at_32 * arr, long size); // deprecated - - See Also: - SetDriverEvent GetAcquisitionProgress SetAcquisitionMode SetAcGetNewData8 GetNewData16 - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetNewData(byref(carr), csize) - return (ret, carr.value) - - def GetNewData16(self, size): - ''' - Description: - Deprecated see Note: - 16-bit version of the GetNewDataGetNewData function. - - Synopsis: - (ret, arr) = GetNewData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData16(WORD * arr, long size); // deprecated - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_short() - csize = c_int(size) - ret = self.dll.GetNewData16(byref(carr), csize) - return (ret, carr.value) - - def GetNewData8(self, size): - ''' - Description: - Deprecated see Note: - 8-bit version of the GetNewDataGetNewData function. This function will return the data in the lower 8 bits of the acquired data. - - Synopsis: - (ret, arr) = GetNewData8(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData8(unsigned char * arr, long size); - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = (c_ubyte * size)() - csize = c_int(size) - ret = self.dll.GetNewData8(carr, csize) - return (ret, carr) - - def GetNewFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetNewFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetNewFloatData(float * arr, long size); - - ''' - carr = c_float() - csize = c_int(size) - ret = self.dll.GetNewFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetNumberADChannels(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one A-D converter, this function will tell you the number available. - - Synopsis: - (ret, channels) = GetNumberADChannels() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of channels returned. - channels - number of allowed channels - - C++ Equiv: - unsigned int GetNumberADChannels(int * channels); - - See Also: - SetADChannel - - ''' - cchannels = c_int() - ret = self.dll.GetNumberADChannels(byref(cchannels)) - return (ret, cchannels.value) - - def GetNumberAmp(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one output amplifier, this function will tell you the number available. - - Synopsis: - (ret, amp) = GetNumberAmp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of output amplifiers returned. - amp - number of allowed channels - - C++ Equiv: - unsigned int GetNumberAmp(int * amp); - - See Also: - SetOutputAmplifier - - ''' - camp = c_int() - ret = self.dll.GetNumberAmp(byref(camp)) - return (ret, camp.value) - - def GetNumberAvailableImages(self): - ''' - Description: - This function will return information on the number of available images in the circular buffer. This information can be used with GetImages to retrieve a series of images. If any images are overwritten in the circular buffer they no longer can be retrieved and the information returned will treat overwritten images as not available. - - Synopsis: - (ret, first, last) = GetNumberAvailableImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - DRV_NO_NEW_DATA - There is no new data yet - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberAvailableImages(at_32 * first, at_32 * last); - - See Also: - GetImages GetImages16 GetNumberNewImages - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberAvailableImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberDDGExternalOutputs(self): - ''' - Description: - This function gets the number of available external outputs. - - Synopsis: - (ret, puiCount) = GetNumberDDGExternalOutputs() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiCount - number of available external outputs. - - C++ Equiv: - unsigned int GetNumberDDGExternalOutputs(at_u32 * puiCount); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cpuiCount = c_uint() - ret = self.dll.GetNumberDDGExternalOutputs(byref(cpuiCount)) - return (ret, cpuiCount.value) - - def GetNumberDevices(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, numDevs) = GetNumberDevices() - - Inputs: - None - - Outputs: - ret - Function Return Code - numDevs - - - C++ Equiv: - unsigned int GetNumberDevices(int * numDevs); - - ''' - cnumDevs = c_int() - ret = self.dll.GetNumberDevices(byref(cnumDevs)) - return (ret, cnumDevs.value) - - def GetNumberFKVShiftSpeeds(self): - ''' - Description: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberFKVShiftSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed speeds - - C++ Equiv: - unsigned int GetNumberFKVShiftSpeeds(int * number); - - See Also: - GetFKVShiftSpeedF SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cnumber = c_int() - ret = self.dll.GetNumberFKVShiftSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHorizontalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberHorizontalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHorizontalSpeeds(int * number); // deprecated - - See Also: - GetHorizontalSpeed SetHorizontalSpeed - - Note: Deprecated by GetNumberHSSpeedsGetNumberHSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberHorizontalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHSSpeeds(self, channel, typ): - ''' - Description: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, speeds) = GetNumberHSSpeeds(channel, typ) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication. - 1 - conventional. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - speeds - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHSSpeeds(int channel, int typ, int * speeds); - - See Also: - GetHSSpeed SetHSSpeed GetNumberADChannel - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cspeeds = c_int() - ret = self.dll.GetNumberHSSpeeds(cchannel, ctyp, byref(cspeeds)) - return (ret, cspeeds.value) - - def GetNumberIO(self): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the number of these IOs available. The functions GetIODirection, GetIOLevel, SetIODirection and SetIOLevel can be used to specify the configuration. - - Synopsis: - (ret, iNumber) = GetNumberIO() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of IOs returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iNumber - number of allowed IOs - - C++ Equiv: - unsigned int GetNumberIO(int * iNumber); - - See Also: - GetIOLevel GetIODirection SetIODirection SetIOLevel - - ''' - ciNumber = c_int() - ret = self.dll.GetNumberIO(byref(ciNumber)) - return (ret, ciNumber.value) - - def GetNumberNewImages(self): - ''' - Description: - This function will return information on the number of new images (i.e. images which have not yet been retrieved) in the circular buffer. This information can be used with GetImages to retrieve a series of the latest images. If any images are overwritten in the circular buffer they can no longer be retrieved and the information returned will treat overwritten images as having been retrieved. - - Synopsis: - (ret, first, last) = GetNumberNewImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NO_NEW_DATA - There is no new data yet. - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberNewImages(long * first, long * last); - - See Also: - GetImages GetImages16 GetNumberAvailableImages - - Note: This index will increment as soon as a single accumulation has been completed within the current acquisition. - - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberNewImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberPhotonCountingDivisions(self): - ''' - Description: - Available in some systems is photon counting mode. This function gets the number of photon counting divisions available. The functions SetPhotonCounting and SetPhotonCountingThreshold can be used to specify which of these divisions is to be used. - - Synopsis: - (ret, noOfDivisions) = GetNumberPhotonCountingDivisions() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of photon counting divisions returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Photon Counting not available - noOfDivisions - number of allowed photon counting divisions - - C++ Equiv: - unsigned int GetNumberPhotonCountingDivisions(at_u32 * noOfDivisions); - - See Also: - SetPhotonCounting IsPreAmpGainAvailable SetPhotonCountingThresholdGetPreAmpGain GetCapabilities - - ''' - cnoOfDivisions = c_uint() - ret = self.dll.GetNumberPhotonCountingDivisions(byref(cnoOfDivisions)) - return (ret, cnoOfDivisions.value) - - def GetNumberPreAmpGains(self): - ''' - Description: - Available in some systems are a number of pre amp gains that can be applied to the data as it is read out. This function gets the number of these pre amp gains available. The functions GetPreAmpGain and SetPreAmpGain can be used to specify which of these gains is to be used. - - Synopsis: - (ret, noGains) = GetNumberPreAmpGains() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of pre amp gains returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - noGains - number of allowed pre amp gains - - C++ Equiv: - unsigned int GetNumberPreAmpGains(int * noGains); - - See Also: - IsPreAmpGainAvailable GetPreAmpGain SetPreAmpGain GetCapabilities - - ''' - cnoGains = c_int() - ret = self.dll.GetNumberPreAmpGains(byref(cnoGains)) - return (ret, cnoGains.value) - - def GetNumberRingExposureTimes(self): - ''' - Description: - Gets the number of exposures in the ring at this moment. - - Synopsis: - (ret, ipnumTimes) = GetNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - ipnumTimes - Numberof exposure times. - - C++ Equiv: - unsigned int GetNumberRingExposureTimes(int * ipnumTimes); - - See Also: - SetRingExposureTimes - - ''' - cipnumTimes = c_int() - ret = self.dll.GetNumberRingExposureTimes(byref(cipnumTimes)) - return (ret, cipnumTimes.value) - - def GetNumberVerticalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberVerticalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed vertical speeds - - C++ Equiv: - unsigned int GetNumberVerticalSpeeds(int * number); // deprecated - - See Also: - GetVerticalSpeed SetVerticalSpeed - - Note: Deprecated by GetNumberVSSpeedsGetNumberVSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVerticalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSAmplitudes(self): - ''' - Description: - This function will normally return the number of vertical clock voltage amplitues that the camera has. - - Synopsis: - (ret, number) = GetNumberVSAmplitudes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters - DRV_NOT_INITIALIZED - int* speeds: number of allowed vertical speeds - DRV_NOT_AVAILABLE - Return - Number returned - Return int - System not initialized - DRV_SUCCESS - Your system does not support this feature - DRV_NOT_INITIALIZED - GetNumberVSSpeeds - DRV_ACQUIRING - GetNumberVSSpeeds int WINAPI GetNumberVSSpeeds(int* speeds) - Number of speeds returned. - Description - System not initialized. - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - Acquisition in progress. - number - Number of vertical clock voltages. - - C++ Equiv: - unsigned int GetNumberVSAmplitudes(int * number); - - See Also: - GetVSSpeed SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVSAmplitudes(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSSpeeds(self): - ''' - Description: - - - Synopsis: - (ret, speeds) = GetNumberVSSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code - speeds - - - C++ Equiv: - unsigned int GetNumberVSSpeeds(int * speeds); - - ''' - cspeeds = c_int() - ret = self.dll.GetNumberVSSpeeds(byref(cspeeds)) - return (ret, cspeeds.value) - - def GetOldestImage(self, size): - ''' - Description: - This function will update the data array with the oldest image in the circular buffer. Once the oldest image has been retrieved it no longer is available. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the full image. - - Synopsis: - (ret, arr) = GetOldestImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage(at_32 * arr, unsigned long size); - - See Also: - GetOldestImage16 GetMostRecentImage GetMostRecentImage16 - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage(carr, csize) - return (ret, carr) - - def GetOldestImage16(self, size): - ''' - Description: - 16-bit version of the GetOldestImageGetOldestImage function. - - Synopsis: - (ret, arr) = GetOldestImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage16(WORD * arr, unsigned long size); - - See Also: - GetOldestImage GetMostRecentImage16 GetMostRecentImage - - ''' - carr = (c_short * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage16(carr, csize) - return (ret, carr) - - def GetPhosphorStatus(self): - ''' - Description: - This function will return if the phosphor has saturated. - - Synopsis: - (ret, flag) = GetPhosphorStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Phosphor status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - flag - The status of the phosphor: - 0 - Normal - 1 - Saturated - - C++ Equiv: - unsigned int GetPhosphorStatus(int * flag); - - ''' - cflag = c_int() - ret = self.dll.GetPhosphorStatus(byref(cflag)) - return (ret, cflag.value) - - def GetPhysicalDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetPhysicalDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetPhysicalDMAAddress(unsigned long * Address1, unsigned long * Address2); - - ''' - cAddress1 = c_ulong() - cAddress2 = c_ulong() - ret = self.dll.GetPhysicalDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetPixelSize(self): - ''' - Description: - This function returns the dimension of the pixels in the detector in microns. - - Synopsis: - (ret, xSize, ySize) = GetPixelSize() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pixel size returned. - xSize - width of pixel. - ySize - height of pixel. - - C++ Equiv: - unsigned int GetPixelSize(float * xSize, float * ySize); - - ''' - cxSize = c_float() - cySize = c_float() - ret = self.dll.GetPixelSize(byref(cxSize), byref(cySize)) - return (ret, cxSize.value, cySize.value) - - def GetPreAmpGain(self, index): - ''' - Description: - For those systems that provide a number of pre amp gains to apply to the data as it is read out; this function retrieves the amount of gain that is stored for a particular index. The number of gains available can be obtained by calling the GetNumberPreAmpGainsGetNumberPreAmpGains function and a specific Gain can be selected using the function SetPreAmpGainSetPreAmpGain. - - Synopsis: - (ret, gain) = GetPreAmpGain(index) - - Inputs: - index - gain index: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - gain - gain factor for this index. - - C++ Equiv: - unsigned int GetPreAmpGain(int index, float * gain); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cgain = c_float() - ret = self.dll.GetPreAmpGain(cindex, byref(cgain)) - return (ret, cgain.value) - - def GetPreAmpGainText(self, index, length): - ''' - Description: - This function will return a string with a pre amp gain description. The pre amp gain is selected using the index. The SDK has a string associated with each of its pre amp gains. The maximum number of characters needed to store the pre amp gain descriptions is 30. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetPreAmpGainText(index, length) - - Inputs: - index - gain index 0 to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Array size is incorrect - DRV_NOT_SUPPORTED - Function not supported with this camera - name - nameA user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetPreAmpGainText(int index, char * name, int length); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetPreAmpGainText(cindex, cname, clength) - return (ret, cname) - - def GetQE(self, sensor, wavelength, mode): - ''' - Description: - Returns the percentage QE for a particular head model at a user specified wavelengthSetPreAmpGain. - - Synopsis: - (ret, QE) = GetQE(sensor, wavelength, mode) - - Inputs: - sensor - head model - wavelength - wavelength at which QE is required - mode - Clara mode (Normal (0) or Extended NIR (1)). 0 for all other systems - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - QE returned. - DRV_NOT_INITIALIZED - System not initialized. - QE - requested QE - - C++ Equiv: - unsigned int GetQE(char * sensor, float wavelength, int mode, float * QE); - - See Also: - GetHeadModel IsPreAmpGainAvailable SetPreAmpGain GetCapabilities - - ''' - csensor = sensor - cwavelength = c_float(wavelength) - cmode = c_int(mode) - cQE = c_float() - ret = self.dll.GetQE(csensor, cwavelength, cmode, byref(cQE)) - return (ret, cQE.value) - - def GetReadOutTime(self): - ''' - Description: - This function will return the time to readout data from a sensor. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, ReadOutTime) = GetReadOutTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - ReadOutTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetReadOutTime(float * ReadOutTime); - - See Also: - GetAcquisitionTimings GetKeepCleanTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cReadOutTime = c_float() - ret = self.dll.GetReadOutTime(byref(cReadOutTime)) - return (ret, cReadOutTime.value) - - def GetRegisterDump(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, mode) = GetRegisterDump() - - Inputs: - None - - Outputs: - ret - Function Return Code - mode - - - C++ Equiv: - unsigned int GetRegisterDump(int * mode); - - ''' - cmode = c_int() - ret = self.dll.GetRegisterDump(byref(cmode)) - return (ret, cmode.value) - - def GetRelativeImageTimes(self, first, last, size): - ''' - Description: - This function will return an array of the start times in nanoseconds of a user defined number of frames relative to the initial frame. - - Synopsis: - (ret, arr) = GetRelativeImageTimes(first, last, size) - - Inputs: - first - Index of first frame in array. - last - Index of last frame in array. - size - number of frames for which start time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - arr - array of times in nanoseconds for each frame from time of start. - - C++ Equiv: - unsigned int GetRelativeImageTimes(int first, int last, at_u64 * arr, int size); - - See Also: - GetCapabilities SetMetaData - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = c_ulonglong() - csize = c_int(size) - ret = self.dll.GetRelativeImageTimes(cfirst, clast, byref(carr), csize) - return (ret, carr.value) - - def GetRingExposureRange(self): - ''' - Description: - With the Ring Of Exposure feature there may be a case when not all exposures can be met. The ring of exposure feature will guarantee that the highest exposure will be met but this may mean that the lower exposures may not be. If the lower exposures are too low they will be increased to the lowest value possible. This function will return these upper and lower values. - - Synopsis: - (ret, fpMin, fpMax) = GetRingExposureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Min and max returned - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Trigger mode is not available - fpMin - Minimum exposure - fpMax - Maximum exposure. - - C++ Equiv: - unsigned int GetRingExposureRange(float * fpMin, float * fpMax); - - See Also: - GetCapabilities GetNumberRingExposureTimes IsTriggerModeAvailable SetRingExposureTimes - - ''' - cfpMin = c_float() - cfpMax = c_float() - ret = self.dll.GetRingExposureRange(byref(cfpMin), byref(cfpMax)) - return (ret, cfpMin.value, cfpMax.value) - - def GetSDK3Handle(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Handle) = GetSDK3Handle() - - Inputs: - None - - Outputs: - ret - Function Return Code - Handle - - - C++ Equiv: - unsigned int GetSDK3Handle(int * Handle); - - ''' - cHandle = c_int() - ret = self.dll.GetSDK3Handle(byref(cHandle)) - return (ret, cHandle.value) - - def GetSensitivity(self, channel, horzShift, amplifier, pa): - ''' - Description: - This function returns the sensitivity for a particular speed. - - Synopsis: - (ret, sensitivity) = GetSensitivity(channel, horzShift, amplifier, pa) - - Inputs: - channel - AD channel index. - horzShift - Type of output amplifier. - amplifier - Channel speed index. - pa - PreAmp gain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sensitivity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - sensitivity - requested sensitivity. - - C++ Equiv: - unsigned int GetSensitivity(int channel, int horzShift, int amplifier, int pa, float * sensitivity); - - See Also: - GetCapabilities - - Note: Available only on iXon+ and Clara. - - ''' - cchannel = c_int(channel) - chorzShift = c_int(horzShift) - camplifier = c_int(amplifier) - cpa = c_int(pa) - csensitivity = c_float() - ret = self.dll.GetSensitivity(cchannel, chorzShift, camplifier, cpa, byref(csensitivity)) - return (ret, csensitivity.value) - - def GetShutterMinTimes(self): - ''' - Description: - This function will return the minimum opening and closing times in milliseconds for the shutter on the current camera. - - Synopsis: - (ret, minclosingtime, minopeningtime) = GetShutterMinTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum times successfully returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Parameter is NULL. - DRV_P2INVALID - Parameter is NULL - minclosingtime - returns the minimum closing time in milliseconds that the shutter of the camera supports. - minopeningtime - returns the minimum opening time in milliseconds that the shutter of the camera supports. - - C++ Equiv: - unsigned int GetShutterMinTimes(int * minclosingtime, int * minopeningtime); - - ''' - cminclosingtime = c_int() - cminopeningtime = c_int() - ret = self.dll.GetShutterMinTimes(byref(cminclosingtime), byref(cminopeningtime)) - return (ret, cminclosingtime.value, cminopeningtime.value) - - def GetSizeOfCircularBuffer(self): - ''' - Description: - This function will return the maximum number of images the circular buffer can store based on the current acquisition settings. - - Synopsis: - (ret, index) = GetSizeOfCircularBuffer() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum number of images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the maximum number of images the circular buffer can store. - - C++ Equiv: - unsigned int GetSizeOfCircularBuffer(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetSizeOfCircularBuffer(byref(cindex)) - return (ret, cindex.value) - - def GetSlotBusDeviceFunction(self): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, dwslot, dwBus, dwDevice, dwFunction) = GetSlotBusDeviceFunction() - - Inputs: - None - - Outputs: - ret - Function Return Code - dwslot - - dwBus - - dwDevice - - dwFunction - - - C++ Equiv: - unsigned int GetSlotBusDeviceFunction(DWORD * dwslot, DWORD * dwBus, DWORD * dwDevice, DWORD * dwFunction); - - ''' - cdwslot = () - cdwBus = () - cdwDevice = () - cdwFunction = () - ret = self.dll.GetSlotBusDeviceFunction(byref(cdwslot), byref(cdwBus), byref(cdwDevice), byref(cdwFunction)) - return (ret, cdwslot.value, cdwBus.value, cdwDevice.value, cdwFunction.value) - - def GetSoftwareVersion(self): - ''' - Description: - This function returns the Software version information for the microprocessor code and the driver. - - Synopsis: - (ret, eprom, coffile, vxdrev, vxdver, dllrev, dllver) = GetSoftwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - eprom - EPROM version - coffile - COF file version - vxdrev - Driver revision number - vxdver - Driver version number - dllrev - DLL revision number - dllver - DLL version number - - C++ Equiv: - unsigned int GetSoftwareVersion(unsigned int * eprom, unsigned int * coffile, unsigned int * vxdrev, unsigned int * vxdver, unsigned int * dllrev, unsigned int * dllver); - - ''' - ceprom = c_uint() - ccoffile = c_uint() - cvxdrev = c_uint() - cvxdver = c_uint() - cdllrev = c_uint() - cdllver = c_uint() - ret = self.dll.GetSoftwareVersion(byref(ceprom), byref(ccoffile), byref(cvxdrev), byref(cvxdver), byref(cdllrev), byref(cdllver)) - return (ret, ceprom.value, ccoffile.value, cvxdrev.value, cvxdver.value, cdllrev.value, cdllver.value) - - def GetSpoolProgress(self): - ''' - Description: - Deprecated see Note: - This function will return information on the progress of the current spool operation. The value returned is the number of images that have been saved to disk during the current kinetic scan. - - Synopsis: - (ret, index) = GetSpoolProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Spool progress returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the number of files saved to disk in the current kinetic scan. - - C++ Equiv: - unsigned int GetSpoolProgress(long * index); // deprecated - - See Also: - SetSpool - - Note: Deprecated by GetTotalNumberImagesAcquiredGetNumberHSSpeeds - - ''' - cindex = c_int() - ret = self.dll.GetSpoolProgress(byref(cindex)) - return (ret, cindex.value) - - def GetStartUpTime(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, time) = GetStartUpTime() - - Inputs: - None - - Outputs: - ret - Function Return Code - time - - - C++ Equiv: - unsigned int GetStartUpTime(float * time); - - ''' - ctime = c_float() - ret = self.dll.GetStartUpTime(byref(ctime)) - return (ret, ctime.value) - - def GetStatus(self): - ''' - Description: - This function will return the current status of the Andor SDK system. This function should be called before an acquisition is started to ensure that it is IDLE and during an acquisition to monitor the process. - - Synopsis: - (ret, status) = GetStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - status - current status: - DRV_IDLE - waiting on instructions. - DRV_TEMPCYCLE - Executing temperature cycle. - DRV_ACQUIRING - Acquisition in progress. - DRV_ACCUM_TIME_NOT_MET - Unable to meet Accumulate cycle time. - DRV_KINETIC_TIME_NOT_MET - Unable to meet Kinetic cycle time. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQ_BUFFER - Computer unable to read the data via the ISA slot at the required rate. - DRV_SPOOLERROR - Overflow of the spool buffer. - - C++ Equiv: - unsigned int GetStatus(int * status); - - See Also: - SetTemperature StartAcquisition - - Note: If the status is one of the following: - - ''' - cstatus = c_int() - ret = self.dll.GetStatus(byref(cstatus)) - return (ret, cstatus.value) - - def GetTECStatus(self): - ''' - Description: - This function will return if the TEC has overheated. - - Synopsis: - (ret, piFlag) = GetTECStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - TEC status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the TEC: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetTECStatus(int * piFlag); - - See Also: - SetTECEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetTECStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetTemperature(self): - ''' - Description: - This function returns the temperature of the detector to the nearest degree. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperature() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilized but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperature(int * temperature); - - See Also: - GetTemperatureF SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_int() - ret = self.dll.GetTemperature(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureF(self): - ''' - Description: - This function returns the temperature in degrees of the detector. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperatureF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilised but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperatureF(float * temperature); - - See Also: - GetTemperature SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_float() - ret = self.dll.GetTemperatureF(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureRange(self): - ''' - Description: - This function returns the valid range of temperatures in centigrade to which the detector can be cooled. - - Synopsis: - (ret, mintemp, maxtemp) = GetTemperatureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature range returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mintemp - minimum temperature - maxtemp - maximum temperature - - C++ Equiv: - unsigned int GetTemperatureRange(int * mintemp, int * maxtemp); - - See Also: - GetTemperature GetTemperatureF SetTemperature CoolerON CoolerOFF - - ''' - cmintemp = c_int() - cmaxtemp = c_int() - ret = self.dll.GetTemperatureRange(byref(cmintemp), byref(cmaxtemp)) - return (ret, cmintemp.value, cmaxtemp.value) - - def GetTemperatureStatus(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, SensorTemp, TargetTemp, AmbientTemp, CoolerVolts) = GetTemperatureStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code - SensorTemp - - TargetTemp - - AmbientTemp - - CoolerVolts - - - C++ Equiv: - unsigned int GetTemperatureStatus(float * SensorTemp, float * TargetTemp, float * AmbientTemp, float * CoolerVolts); - - ''' - cSensorTemp = c_float() - cTargetTemp = c_float() - cAmbientTemp = c_float() - cCoolerVolts = c_float() - ret = self.dll.GetTemperatureStatus(byref(cSensorTemp), byref(cTargetTemp), byref(cAmbientTemp), byref(cCoolerVolts)) - return (ret, cSensorTemp.value, cTargetTemp.value, cAmbientTemp.value, cCoolerVolts.value) - - def GetTotalNumberImagesAcquired(self): - ''' - Description: - This function will return the total number of images acquired since the current acquisition started. If the camera is idle the value returned is the number of images acquired during the last acquisition. - - Synopsis: - (ret, index) = GetTotalNumberImagesAcquired() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the total number of images acquired since the acquisition started. - - C++ Equiv: - unsigned int GetTotalNumberImagesAcquired(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetTotalNumberImagesAcquired(byref(cindex)) - return (ret, cindex.value) - - def GetTriggerLevelRange(self): - ''' - Description: - This function returns the valid range of triggers in volts which the system can use. - - Synopsis: - (ret, minimum, maximum) = GetTriggerLevelRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Levels returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - minimum has invalid memory address. - minimum - minimum trigger voltage - maximum - maximum trigger voltage - - C++ Equiv: - unsigned int GetTriggerLevelRange(float * minimum, float * maximum); - - See Also: - GetCapabilities SetTriggerLevel - - ''' - cminimum = c_float() - cmaximum = c_float() - ret = self.dll.GetTriggerLevelRange(byref(cminimum), byref(cmaximum)) - return (ret, cminimum.value, cmaximum.value) - - def GetVersionInfo(self, arr, ui32BufferLen): - ''' - Description: - This function retrieves version information about different aspects of the Andor system. The information is copied into a passed string buffer. Currently, the version of the SDK and the Device Driver (USB or PCI) is supported. - - Synopsis: - (ret, szVersionInfo) = GetVersionInfo(arr, ui32BufferLen) - - Inputs: - arr - : - AT_SDKVersion - requests the SDK version information - AT_DeviceDriverVersion - requests the device driver version - ui32BufferLen - The size of the passed character array, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS Information returned - Information returned - DRV_NOT_INITIALIZED System not initialized - System not initialized - DRV_P1INVALID - Invalid information type requested - DRV_P2INVALID - Storage array pointer is NULL - DRV_P3INVALID - Size of the storage array is zero - szVersionInfo - A user allocated array of characters for storage of the information - - C++ Equiv: - unsigned int GetVersionInfo(AT_VersionInfoId arr, char * szVersionInfo, at_u32 ui32BufferLen); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - carr = (arr) - cszVersionInfo = create_string_buffer(ui32BufferLen) - cui32BufferLen = c_uint(ui32BufferLen) - ret = self.dll.GetVersionInfo(carr, cszVersionInfo, cui32BufferLen) - return (ret, cszVersionInfo) - - def GetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetVerticalSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING DRV_P1INVALID - Acquisition in progress. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVerticalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberVerticalSpeeds SetVerticalSpeed - - Note: Deprecated by GetVSSpeedGetVSSpeed. - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetVerticalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetVirtualDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetVirtualDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetVirtualDMAAddress(void * Address1, void * Address2); - - ''' - cAddress1 = c_void() - cAddress2 = c_void() - ret = self.dll.GetVirtualDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetVSAmplitudeFromString(self, text): - ''' - Description: - This Function is used to get the index of the Vertical Clock Amplitude that corresponds to the string passed in. - - Synopsis: - (ret, index) = GetVSAmplitudeFromString(text) - - Inputs: - text - String to test "Normal" , "+1" , "+2" , "+3" , "+4" - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string Index returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid text. - DRV_P2INVALID - Invalid index pointer. - index - Returns the Index of the VSAmplitude that matches string passed in - - C++ Equiv: - unsigned int GetVSAmplitudeFromString(char * text, int * index); - - See Also: - GetVSAmplitudeString GetVSAmplitudeValue - - ''' - ctext = text - cindex = c_int() - ret = self.dll.GetVSAmplitudeFromString(ctext, byref(cindex)) - return (ret, cindex.value) - - def GetVSAmplitudeString(self, index): - ''' - Description: - This Function is used to get the Vertical Clock Amplitude string that corresponds to the index passed in. - - Synopsis: - (ret, text) = GetVSAmplitudeString(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid text pointer. - text - Returns string value of the VS Amplitude found at the index supplied - - C++ Equiv: - unsigned int GetVSAmplitudeString(int index, char * text); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeValue - - ''' - cindex = c_int(index) - ctext = create_string_buffer(64) - ret = self.dll.GetVSAmplitudeString(cindex, ctext) - return (ret, ctext) - - def GetVSAmplitudeValue(self, index): - ''' - Description: - This Function is used to get the value of the Vertical Clock Amplitude found at the index passed in. - - Synopsis: - (ret, value) = GetVSAmplitudeValue(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude value returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid value pointer. - value - Returns Value of Vertical Clock Amplitude that matches index passed in - - C++ Equiv: - unsigned int GetVSAmplitudeValue(int index, int * value); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeString - - ''' - cindex = c_int(index) - cvalue = c_int() - ret = self.dll.GetVSAmplitudeValue(cindex, byref(cvalue)) - return (ret, cvalue.value) - - def GetVSSpeed(self, index): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds. - - Synopsis: - (ret, speed) = GetVSSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVSSpeed(int index, float * speed); - - See Also: - GetNumberVSSpeeds SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetVSSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GPIBReceive(self, id, address, size): - ''' - Description: - This function reads data from a device until a byte is received with the EOI line asserted or until size bytes have been read. - - Synopsis: - (ret, text) = GPIBReceive(id, address, size) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The address to send the data to - size - Number of characters to read - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data received. - DRV_P3INVALID - Invalid pointer (e.g. NULL). .Other errors may be returned by the GPIB device. Consult the help documentation supplied with these devices. - text - The data to be sent - - C++ Equiv: - unsigned int GPIBReceive(int id, short address, char * text, int size); - - See Also: - GPIBSend - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = create_string_buffer(size) - csize = c_int(size) - ret = self.dll.GPIBReceive(cid, caddress, ctext, csize) - return (ret, ctext) - - def GPIBSend(self, id, address, text): - ''' - Description: - This function initializes the GPIB by sending interface clear. Then the device described by address is put in a listen-active state. Finally the string of characters, text, is sent to the device with a newline character and with the EOI line asserted after the final character. - - Synopsis: - ret = GPIBSend(id, address, text) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The GPIB address to send data to - text - The data to send - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data sent. - DRV_P3INVALID - Invalid pointer (e.g. NULL). The GPIB device may return other errors. Consult the help documentation supplied with these devices. - - C++ Equiv: - unsigned int GPIBSend(int id, short address, char * text); - - See Also: - GPIBReceive - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = text - ret = self.dll.GPIBSend(cid, caddress, ctext) - return (ret) - - def I2CBurstRead(self, i2cAddress, nBytes): - ''' - Description: - This function will read a specified number of bytes from a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstRead(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to read from. - nBytes - The number of bytes to read from the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data read from the device. - - C++ Equiv: - unsigned int I2CBurstRead(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstWrite I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstRead(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CBurstWrite(self, i2cAddress, nBytes): - ''' - Description: - This function will write a specified number of bytes to a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstWrite(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to write to. - nBytes - The number of bytes to write to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data to write to the device. - - C++ Equiv: - unsigned int I2CBurstWrite(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstRead I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstWrite(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CRead(self, deviceID, intAddress): - ''' - Description: - This function will read a single byte from the chosen device. - - Synopsis: - (ret, pdata) = I2CRead(deviceID, intAddress) - - Inputs: - deviceID - The device to read from. - intAddress - The internal address of the device to be read from. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - pdata - The byte read from the device. - - C++ Equiv: - unsigned int I2CRead(BYTE deviceID, BYTE intAddress, BYTE * pdata); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cpdata = c_ubyte() - ret = self.dll.I2CRead(cdeviceID, cintAddress, byref(cpdata)) - return (ret, cpdata.value) - - def I2CReset(self): - ''' - Description: - This function will reset the I2C data bus. - - Synopsis: - ret = I2CReset() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Reset successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CReset(void); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite - - ''' - ret = self.dll.I2CReset() - return (ret) - - def I2CWrite(self, deviceID, intAddress, data): - ''' - Description: - This function will write a single byte to the chosen device. - - Synopsis: - ret = I2CWrite(deviceID, intAddress, data) - - Inputs: - deviceID - The device to write to. - intAddress - The internal address of the device to write to. - data - The byte to be written to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CWrite(BYTE deviceID, BYTE intAddress, BYTE data); - - See Also: - I2CBurstWrite I2CBurstRead I2CRead I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cdata = c_ubyte(data) - ret = self.dll.I2CWrite(cdeviceID, cintAddress, cdata) - return (ret) - - def IdAndorDll(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = IdAndorDll() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int IdAndorDll(void); - - ''' - ret = self.dll.IdAndorDll() - return (ret) - - def InAuxPort(self, port): - ''' - Description: - This function returns the state of the TTL Auxiliary Input Port on the Andor plug-in card. - - Synopsis: - (ret, state) = InAuxPort(port) - - Inputs: - port - Number of AUX in port on Andor card. Valid Values: 1 to 4 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX read. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - state - current state of port: - 0 - OFF/LOW - all others - ON/HIGH - - C++ Equiv: - unsigned int InAuxPort(int port, int * state); - - See Also: - OutAuxPort - - ''' - cport = c_int(port) - cstate = c_int() - ret = self.dll.InAuxPort(cport, byref(cstate)) - return (ret, cstate.value) - - def Initialize(self, dir): - ''' - Description: - This function will initialize the Andor SDK System. As part of the initialization procedure on some cameras (i.e. Classic, iStar and earlier iXion) the DLL will need access to a DETECTOR.INI which contains information relating to the detector head, number pixels, readout speeds etc. If your system has multiple cameras then see the section Controlling multiple cameras - - Synopsis: - ret = Initialize(dir) - - Inputs: - dir - Path to the directory containing the files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_VXDNOTINSTALLED - Initialisation successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ERROR_FILELOAD - Unable to load *.COF or *.RBF files. - DRV_ERROR_PAGELOCK - Unable to acquire lock on requested memory. - DRV_USBERROR - Unable to detect USB device or not USB2.0. - DRV_ERROR_NOCAMERA - No camera found - - C++ Equiv: - unsigned int Initialize(char * dir); - - See Also: - GetAvailableCameras SetCurrentCamera GetCurrentCamera - - ''' - cdir = dir - ret = self.dll.Initialize(cdir) - return (ret) - - def InitializeDevice(self, dir): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = InitializeDevice(dir) - - Inputs: - dir - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int InitializeDevice(char * dir); - - ''' - cdir = dir - ret = self.dll.InitializeDevice(cdir) - return (ret) - - def IsAmplifierAvailable(self, iamp): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified amplifier. - - Synopsis: - ret = IsAmplifierAvailable(iamp) - - Inputs: - iamp - amplifier to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplifier available - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_AMPLIFIER - Not a valid amplifier - - C++ Equiv: - unsigned int IsAmplifierAvailable(int iamp); - - See Also: - SetHSSpeed - - ''' - ciamp = c_int(iamp) - ret = self.dll.IsAmplifierAvailable(ciamp) - return (ret) - - def IsCoolerOn(self): - ''' - Description: - This function checks the status of the cooler. - - Synopsis: - (ret, iCoolerStatus) = IsCoolerOn() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Parameter is NULL - iCoolerStatus - iCoolerStatus0: Cooler is OFF.: - 1 - 1 Cooler is ON. - - C++ Equiv: - unsigned int IsCoolerOn(int * iCoolerStatus); - - See Also: - CoolerON CoolerOFF - - ''' - ciCoolerStatus = c_int() - ret = self.dll.IsCoolerOn(byref(ciCoolerStatus)) - return (ret, ciCoolerStatus.value) - - def IsCountConvertModeAvailable(self, mode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified Count Convert mode. - - Synopsis: - ret = IsCountConvertModeAvailable(mode) - - Inputs: - mode - Count Convert mode to be checked - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode available. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - DRV_INVALID_COUNTCONVERT_MODE - Count Convert mode not available with current acquisition settings - - C++ Equiv: - unsigned int IsCountConvertModeAvailable(int mode); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cmode = c_int(mode) - ret = self.dll.IsCountConvertModeAvailable(cmode) - return (ret) - - def IsInternalMechanicalShutter(self): - ''' - Description: - This function checks if an iXon camera has a mechanical shutter installed. - - - Synopsis: - (ret, internalShutter) = IsInternalMechanicalShutter() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Internal shutter state returned - DRV_NOT_AVAILABLE - Not an iXon Camera - DRV_P1INVALID - Parameter is NULL - internalShutter - Status of internal shutter: - 0 - Mechanical shutter not installed. - 1 - Mechanical shutter installed. - - C++ Equiv: - unsigned int IsInternalMechanicalShutter(int * internalShutter); - - Note: Available only on iXon - - ''' - cinternalShutter = c_int() - ret = self.dll.IsInternalMechanicalShutter(byref(cinternalShutter)) - return (ret, cinternalShutter.value) - - def IsPreAmpGainAvailable(self, channel, amplifier, index, pa): - ''' - Description: - This function checks that the AD channel exists, and that the amplifier, speed and gain are available for the AD channel. - - Synopsis: - (ret, status) = IsPreAmpGainAvailable(channel, amplifier, index, pa) - - Inputs: - channel - AD channel index. - amplifier - Type of output amplifier. - index - Channel speed index. - pa - PreAmpGain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - PreAmpGain status returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - status - PreAmpGain Status: - 0 - PreAmpGain not available. - 1 - PreAmpGain available. - - C++ Equiv: - unsigned int IsPreAmpGainAvailable(int channel, int amplifier, int index, int pa, int * status); - - See Also: - GetNumberPreAmpGains GetPreAmpGain SetPreAmpGain - - Note: Available only on iXon. - - ''' - cchannel = c_int(channel) - camplifier = c_int(amplifier) - cindex = c_int(index) - cpa = c_int(pa) - cstatus = c_int() - ret = self.dll.IsPreAmpGainAvailable(cchannel, camplifier, cindex, cpa, byref(cstatus)) - return (ret, cstatus.value) - - def IsTriggerModeAvailable(self, iTriggerMode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified trigger mode. - - Synopsis: - ret = IsTriggerModeAvailable(iTriggerMode) - - Inputs: - iTriggerMode - Trigger mode to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode available - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Not a valid mode - - C++ Equiv: - unsigned int IsTriggerModeAvailable(int iTriggerMode); - - See Also: - SetTriggerMode - - ''' - ciTriggerMode = c_int(iTriggerMode) - ret = self.dll.IsTriggerModeAvailable(ciTriggerMode) - return (ret) - - def Merge(self, nOrder, nPoint, nPixel, fit, hbin): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr, coeff, output, start, step_Renamed) = Merge(nOrder, nPoint, nPixel, fit, hbin) - - Inputs: - nOrder - - nPoint - - nPixel - - fit - - hbin - - - Outputs: - ret - Function Return Code - arr - - coeff - - output - - start - - step_Renamed - - - C++ Equiv: - unsigned int Merge(const at_32 * arr, long nOrder, long nPoint, long nPixel, float * coeff, long fit, long hbin, at_32 * output, float * start, float * step_Renamed); - - ''' - carr = c_int() - cnOrder = c_int(nOrder) - cnPoint = c_int(nPoint) - cnPixel = c_int(nPixel) - ccoeff = c_float() - cfit = c_int(fit) - chbin = c_int(hbin) - coutput = c_int() - cstart = c_float() - cstep_Renamed = c_float() - ret = self.dll.Merge(byref(carr), cnOrder, cnPoint, cnPixel, byref(ccoeff), cfit, chbin, byref(coutput), byref(cstart), byref(cstep_Renamed)) - return (ret, carr.value, ccoeff.value, coutput.value, cstart.value, cstep_Renamed.value) - - def OA_AddMode(self, uiModeNameLen, pcModeDescription, uiModeDescriptionLen): - ''' - Description: - This function will add a mode name and description to memory. Note that this will not add the mode to file, a subsequent call to OA_WriteToFile must be made. - - Synopsis: - (ret, pcModeName) = OA_AddMode(uiModeNameLen, pcModeDescription, uiModeDescriptionLen) - - Inputs: - uiModeNameLen - Mode name string length. - pcModeDescription - A description of the user defined mode. - uiModeDescriptionLen - Mode Description string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_P1INVALID DRV_P3INVALID DRV_OA_INVALID_STRING_LENGTH - All parameters accepted Null mode name. Null mode description. One or more parameters have an invalid length, i.e. > 255. - DRV_OA_INVALID_NAMING - Mode and description have the same name, this is not valid. - DRV_OA_MODE_BUFFER_FULL DRV_OA_INVALID_CHARS_IN_NAME - Number of modes exceeds limit. Mode name and/or description contain invalid characters. - DRV_OA_MODE_ALREADY_EXISTS - Mode name already exists in the file. - DRV_OA_INVALID_CHARS_IN_NAME - Invalid charcters in Mode Name or Mode Description - pcModeName - A name for the mode to be defined. - - C++ Equiv: - unsigned int OA_AddMode(char * pcModeName, int uiModeNameLen, char * pcModeDescription, int uiModeDescriptionLen); - - See Also: - OA_DeleteMode OA_WriteToFile - - ''' - cpcModeName = create_string_buffer(uiModeNameLen) - cuiModeNameLen = c_int(uiModeNameLen) - cpcModeDescription = pcModeDescription - cuiModeDescriptionLen = c_int(uiModeDescriptionLen) - ret = self.dll.OA_AddMode(cpcModeName, cuiModeNameLen, cpcModeDescription, cuiModeDescriptionLen) - return (ret, cpcModeName) - - def OA_DeleteMode(self, pcModeName, uiModeNameLen): - ''' - Description: - This function will remove a mode from memory. To permanently remove a mode from file, call OA_WriteToFile after OA_DeleteMode. The Preset file will not be affected. - - Synopsis: - ret = OA_DeleteMode(pcModeName, uiModeNameLen) - - Inputs: - pcModeName - The name of the mode to be removed. - uiModeNameLen - Mode name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DRV_OA_MODE_DOES_NOT_EXIST - DRV_P1INVALID - All parameters accepted Null mode name. - DRV_OA_INVALID_STRING_LENGTH - The mode name parameter has an invalid length, i.e. > 256. - - C++ Equiv: - unsigned int OA_DeleteMode(const char * pcModeName, int uiModeNameLen); - - See Also: - OA_AddMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cuiModeNameLen = c_int(uiModeNameLen) - ret = self.dll.OA_DeleteMode(cpcModeName, cuiModeNameLen) - return (ret) - - def OA_EnableMode(self, pcModeName): - ''' - Description: - This function will set all the parameters associated with the specified mode to be used for all subsequent acquisitions. The mode specified by the user must be in either the Preset file or the User defined file. - - Synopsis: - ret = OA_EnableMode(pcModeName) - - Inputs: - pcModeName - The mode to be used for all subsequent acquisitions. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode name. - DRV_OA_MODE_DOES_NOT_EXIST - Mode name does not exist. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - - C++ Equiv: - unsigned int OA_EnableMode(const char * pcModeName); - - See Also: - OA_AddMode - - ''' - cpcModeName = pcModeName - ret = self.dll.OA_EnableMode(cpcModeName) - return (ret) - - def OA_GetFloat(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for floating point type acquisition parameters. - Values are retrieved from memory for the specified mode name. - - Synopsis: - (ret, fFloatValue) = OA_GetFloat(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode parameter. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null float value. - fFloatValue - The value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetFloat(const char * pcModeName, const char * pcModeParam, float * fFloatValue); - - See Also: - OA_SetFloat - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float() - ret = self.dll.OA_GetFloat(cpcModeName, cpcModeParam, byref(cfFloatValue)) - return (ret, cfFloatValue.value) - - def OA_GetInt(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for integer type acquisition parameters. Values are retrieved from memory for the specified mode name. - - - Synopsis: - (ret, iintValue) = OA_GetInt(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter - pcModeParam - The name of the acquisition parameter for which a value - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null integer value. - iintValue - The buffer to return the value of the acquisition. - - C++ Equiv: - unsigned int OA_GetInt(const char * pcModeName, const char * pcModeParam, int * iintValue); - - See Also: - OA_SetInt - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int() - ret = self.dll.OA_GetInt(cpcModeName, cpcModeParam, byref(ciintValue)) - return (ret, ciintValue.value) - - def OA_GetModeAcqParams(self, pcModeName): - ''' - Description: - This function will return all acquisition parameters associated with the specified mode. The mode specified by the user must be in either the Preset file or the User defined file. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfParams) = OA_GetModeAcqParams(pcModeName) - - Inputs: - pcModeName - The mode for which all acquisition parameters must be returned. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_NO_USER_DATA - No data for selected mode. - pcListOfParams - A user allocated array of characters for storage of the acquisition parameters. Parameters will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetModeAcqParams(const char * pcModeName, char * pcListOfParams); - - See Also: - OA_GetNumberOfAcqParams - - ''' - cpcModeName = pcModeName - cpcListOfParams = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetModeAcqParams(cpcModeName, cpcListOfParams) - return (ret, cpcListOfParams) - - def OA_GetNumberOfAcqParams(self, pcModeName): - ''' - Description: - This function will return the parameters associated with a specified mode. The mode must be present in either the Preset file or the User defined file. - - Synopsis: - (ret, puiNumberOfParams) = OA_GetNumberOfAcqParams(pcModeName) - - Inputs: - pcModeName - The mode to search for a list of acquisition parameters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null number of parameters. - DRV_OA_NULL_ERROR - Invalid pointer. - puiNumberOfParams - The number of acquisition parameters for the specified mode. - - C++ Equiv: - unsigned int OA_GetNumberOfAcqParams(const char * pcModeName, unsigned int * puiNumberOfParams); - - See Also: - OA_GetModeAcqParams - - ''' - cpcModeName = pcModeName - cpuiNumberOfParams = c_uint() - ret = self.dll.OA_GetNumberOfAcqParams(cpcModeName, byref(cpuiNumberOfParams)) - return (ret, cpuiNumberOfParams.value) - - def OA_GetNumberOfPreSetModes(self): - ''' - Description: - This function will return the number of modes defined in the Preset file. The Preset file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfPreSetModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the Andor file. - - C++ Equiv: - unsigned int OA_GetNumberOfPreSetModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetPreSetModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfPreSetModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetNumberOfUserModes(self): - ''' - Description: - This function will return the number of modes defined in the User file. The user defined file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfUserModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the user file. - - C++ Equiv: - unsigned int OA_GetNumberOfUserModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetUserModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfUserModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetPreSetModeNames(self): - ''' - Description: - This function will return the available mode names from the Preset file. The mode and the Preset file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetPreSetModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetPreSetModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfPreSetModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetPreSetModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_GetString(self, pcModeName, pcModeParam, uiStringLen): - ''' - Description: - This function is used to get the values for string type acquisition parameters. Values - are retrieved from memory for the specified mode name. - - Synopsis: - (ret, pcStringValue) = OA_GetString(pcModeName, pcModeParam, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - uiStringLen - The length of the buffer. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - pcStringValue - The buffer to return the value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_SetString - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = create_string_buffer(uiStringLen) - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_GetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret, cpcStringValue) - - def OA_GetUserModeNames(self): - ''' - Description: - This function will return the available mode names from a User defined file. The mode and the User defined file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetUserModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetUserModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfUserModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetUserModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_Initialize(self, pcFilename, uiFileNameLen): - ''' - Description: - This function will initialise the OptAcquire settings from a Preset file and a User defined file if it exists. - - Synopsis: - ret = OA_Initialize(pcFilename, uiFileNameLen) - - Inputs: - pcFilename - The name of a user xml file. If the file exists then data will be read from the file. If the file does not exist the file name may be used when the user calls WriteToFile(). - uiFileNameLen - The length of the filename. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - DRV_OA_GET_CAMERA_ERROR - Unable to retrieve information about the - DRV_OA_INVALID_STRING_LENGTH - model of the Camera. - DRV_OA_ANDOR_FILE_NOT_LOADED - The parameter has an invalid length, i.e. > 255. - DRV_OA_USER_FILE_NOT_LOADED - Preset Andor file failed to load. - DRV_OA_FILE_ACCESS_ERROR - Supplied User file failed to load. - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED - Failed to determine status of file. - - C++ Equiv: - unsigned int OA_Initialize(const char * pcFilename, int uiFileNameLen); - - See Also: - OA_WriteToFile - - ''' - cpcFilename = pcFilename - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_Initialize(cpcFilename, cuiFileNameLen) - return (ret) - - def OA_SetFloat(self, pcModeName, pcModeParam, fFloatValue): - ''' - Description: - This function is used to set values for floating point type acquisition parameters where - the new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetFloat(pcModeName, pcModeParam, fFloatValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - fFloatValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetFloat(const char * pcModeName, const char * pcModeParam, const float fFloatValue); - - See Also: - OA_GetFloat OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float(fFloatValue) - ret = self.dll.OA_SetFloat(cpcModeName, cpcModeParam, cfFloatValue) - return (ret) - - def OA_SetInt(self, pcModeName, pcModeParam, iintValue): - ''' - Description: - This function is used to set values for integer type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetInt(pcModeName, pcModeParam, iintValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - iintValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetInt(const char * pcModeName, const char * pcModeParam, const int iintValue); - - See Also: - OA_GetInt OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int(iintValue) - ret = self.dll.OA_SetInt(cpcModeName, cpcModeParam, ciintValue) - return (ret) - - def OA_SetString(self, pcModeName, pcModeParam, pcStringValue, uiStringLen): - ''' - Description: - This function is used to set values for string type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetString(pcModeName, pcModeParam, pcStringValue, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter is to be edited. - pcModeParam - The name of the acquisition parameter to be edited. - pcStringValue - The value to assign to the acquisition parameter. - uiStringLen - The length of the input string. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_GetString OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = pcStringValue - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_SetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret) - - def OA_WriteToFile(self, pcFileName, uiFileNameLen): - ''' - Description: - This function will write a User defined list of modes to the User file. The Preset file will not be affected. - - Synopsis: - ret = OA_WriteToFile(pcFileName, uiFileNameLen) - - Inputs: - pcFileName - The name of the file to be written to. - uiFileNameLen - File name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_INVALID_FILE - Data cannot be written to the Preset Andor file. - DRV_ERROR_FILESAVE - Failed to save data to file. - DRV_OA_FILE_HAS_BEEN_MODIFIED - File to be written to has been modified since last write, local copy of file may not be the same. - DRV_OA_INVALID_CHARS_IN_NAME - File name contains invalid characters. - - C++ Equiv: - unsigned int OA_WriteToFile(const char * pcFileName, int uiFileNameLen); - - See Also: - OA_AddMode OA_DeleteMode - - ''' - cpcFileName = pcFileName - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_WriteToFile(cpcFileName, cuiFileNameLen) - return (ret) - - def OutAuxPort(self, port, state): - ''' - Description: - This function sets the TTL Auxiliary Output port (P) on the Andor plug-in card to either ON/HIGH or OFF/LOW. - - Synopsis: - ret = OutAuxPort(port, state) - - Inputs: - port - Number of AUX out port on Andor card: - 1 - to 4 - state - state to put port in: - 0 - OFF/LOW - all - others ON/HIGH - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX port set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - - C++ Equiv: - unsigned int OutAuxPort(int port, int state); - - See Also: - InAuxPort - - ''' - cport = c_int(port) - cstate = c_int(state) - ret = self.dll.OutAuxPort(cport, cstate) - return (ret) - - def PostProcessCountConvert(self, iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to either Photons or Electrons based on the mode selected by the user. The input data should be in counts. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessCountConvert(iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The size of the output buffer.: - data - data - iNumImages - The number of images if a kinetic series is supplied as the input - iBaseline - The baseline associated with the image.: - 1 - - Convert to Electrons - 2 - - Convert to Photons - iMode - The mode to use to process the data. - iEmGain - The gain level of the input image. - fQE - The Quantum Efficiency of the sensor. - fSensitivity - The Sensitivity value used to acquire the image. - iHeight - The height of the image. - iWidth - The width of the image. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Number of images less than zero. - DRV_P5INVALID - Baseline less than zero. - DRV_P6INVALID - Invalid count convert mode. - DRV_P7INVALID - EMGain less than zero. - DRV_P8INVALID DRV_P9INVALID - QE less than zero. - DRV_P10INVALID - Sensitivity less than zero. - DRV_P11INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The output buffer to return the processed image. - - C++ Equiv: - unsigned int PostProcessCountConvert(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iBaseline, int iMode, int iEmGain, float fQE, float fSensitivity, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - ciEmGain = c_int(iEmGain) - cfQE = c_float(fQE) - cfSensitivity = c_float(fSensitivity) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessCountConvert(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciBaseline, ciMode, ciEmGain, cfQE, cfSensitivity, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessDataAveraging(self, iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessDataAveraging(iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor) - - Inputs: - iOutputBufferSize - - iNumImages - - iAveragingFilterMode - - iHeight - - iWidth - - iFrameCount - - iAveragingFactor - - - Outputs: - ret - Function Return Code - pInputImage - - pOutputImage - - - C++ Equiv: - unsigned int PostProcessDataAveraging(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iAveragingFilterMode, int iHeight, int iWidth, int iFrameCount, int iAveragingFactor); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciAveragingFilterMode = c_int(iAveragingFilterMode) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ciFrameCount = c_int(iFrameCount) - ciAveragingFactor = c_int(iAveragingFactor) - ret = self.dll.PostProcessDataAveraging(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciAveragingFilterMode, ciHeight, ciWidth, ciFrameCount, ciAveragingFactor) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessNoiseFilter(self, iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth): - ''' - Description: - This function will apply a filter to the input image and return the processed image in the output buffer. The filter applied is chosen by the user by setting Mode to a permitted value. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessNoiseFilter(iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The baseline associated with the image. - iBaseline - The mode to use to process the data.: - 1 - Use Median Filter. - 2 - Use Level Above Filter. - 3 - Use interquartile Range Filter. - 4 - Use Noise Threshold Filter. - iMode - This is the Threshold multiplier for the Median, interquartile: - and - Noise Threshold filters. For the Level Above filter this is - Threshold - count above the baseline. - fThreshold - The height of the image. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_SUPPORTED DRV_NOT_INITIALIZED - Camera does not support Noise filter processing. System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Baseline less than zero. - DRV_P5INVALID - Invalid Filter mode. - DRV_P6INVALID - Threshold value not valid for selected mode. - DRV_P7INVALID - Height less than zero. - DRV_P8INVALID DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - - C++ Equiv: - unsigned int PostProcessNoiseFilter(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iBaseline, int iMode, float fThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - cfThreshold = c_float(fThreshold) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessNoiseFilter(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciBaseline, ciMode, cfThreshold, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessPhotonCounting(self, iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to photons and return the processed image in the output buffer. - - Synopsis: - (ret, pInputImage, pOutputImage, pfThreshold) = PostProcessPhotonCounting(iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The number of images if a kinetic series is supplied as the input: - data - data - iNumImages - The number of frames per output image. - iNumframes - The number of thresholds provided by the user. - iNumberOfThresholds - The Thresholds used to define a photon. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_NOT_INITIALIZED - Acquisition prepared. - DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Number of images less than zero. - DRV_P6INVALID - Invalid Number of Frames requested. - DRV_P7INVALID - Invalid number of thresholds. - DRV_P8INVALID - Invalid pointer (i.e. NULL). - DRV_P9INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - pfThreshold - The height of the image. - - C++ Equiv: - unsigned int PostProcessPhotonCounting(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iNumframes, int iNumberOfThresholds, float * pfThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciNumframes = c_int(iNumframes) - ciNumberOfThresholds = c_int(iNumberOfThresholds) - cpfThreshold = c_float() - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessPhotonCounting(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciNumframes, ciNumberOfThresholds, byref(cpfThreshold), ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value, cpfThreshold.value) - - def PrepareAcquisition(self): - ''' - Description: - This function reads the current acquisition setup and allocates and configures any memory that will be used during the acquisition. The function call is not required as it will be called automatically by the StartAcquisition function if it has not already been called externally. - However for long kinetic series acquisitions the time to allocate and configure any memory can be quite long which can result in a long delay between calling StartAcquisition and the acquisition actually commencing. For iDus, there is an additional delay caused by the camera being set-up with any new acquisition parameters. Calling PrepareAcquisition first will reduce this delay in the StartAcquisition call. - - Synopsis: - ret = PrepareAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_IOCERROR - integrate On Chip setup error. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int PrepareAcquisition(void); - - See Also: - StartAcquisition FreeInternalMemory - - ''' - ret = self.dll.PrepareAcquisition() - return (ret) - - def SaveAsBmp(self, path, palette, ymin, ymax): - ''' - Description: - This function saves the last acquisition as a bitmap file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the bitmap. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The ymin and ymax parameters indicate which data values will map to the first and last colors in the palette: - * All data values below or equal to ymin will be colored with the first color. - * All values above or equal to ymax will be colored with the last color - * All other palette colors will be scaled across values between these limits. - - Synopsis: - ret = SaveAsBmp(path, palette, ymin, ymax) - - Inputs: - path - The filename of the bitmap. - palette - The filename of a palette file (.PAL) for applying color to the bitmap. - ymin - Min data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - ymax - Max data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as bitmap. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsBmp(const char * path, const char * palette, long ymin, long ymax); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff - - Note: If the last acquisition was in Kinetic Series mode, each image will be saved in a separate Bitmap file. The filename specified will have an index number appended to it, indicating the position in the series. - - ''' - cpath = path - cpalette = palette - cymin = c_int(ymin) - cymax = c_int(ymax) - ret = self.dll.SaveAsBmp(cpath, cpalette, cymin, cymax) - return (ret) - - def SaveAsCommentedSif(self, path, comment): - ''' - Description: - This function will save the data from the last acquisition into a file. The comment text will be added to the user text portion of the Sif file. - - Synopsis: - ret = SaveAsCommentedSif(path, comment) - - Inputs: - path - pointer to a filename specified by the user. - comment - comment text to add to the sif file - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - - C++ Equiv: - unsigned int SaveAsCommentedSif(char * path, char * comment); - - See Also: - SetSifComment SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment - - Note: The comment used in SIF files created with this function is discarded once the call completes, i.e. future calls to SaveAsSif will not use this comment. To set a persistent comment use the SetSifComment function. - - ''' - cpath = path - ccomment = comment - ret = self.dll.SaveAsCommentedSif(cpath, ccomment) - return (ret) - - def SaveAsEDF(self, szPath, iMode): - ''' - Description: - This function saves the last acquisition in the European Synchotron Radiation Facility Data Format (*.edf). - - Synopsis: - ret = SaveAsEDF(szPath, iMode) - - Inputs: - szPath - the filename to save to. - iMode - option to save to multiple files.: - 0 - Save to 1 file - 1 - Save kinetic series to multiple files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsEDF(char * szPath, int iMode); - - See Also: - SaveAsSif SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszPath = szPath - ciMode = c_int(iMode) - ret = self.dll.SaveAsEDF(cszPath, ciMode) - return (ret) - - def SaveAsFITS(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition in the FITS (Flexible Image Transport System) Data Format (*.fits) endorsed by NASA. - - Synopsis: - ret = SaveAsFITS(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 0 - Unsigned 16 - 1 - Unsigned 32 - 2 - Signed 16 - 3 - Signed 32 - 4 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsFITS(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsFITS(cszFileTitle, ctyp) - return (ret) - - def SaveAsRaw(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition as a raw data file. - - Synopsis: - ret = SaveAsRaw(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 1 - Signed 16 - 2 - Signed 32 - 3 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsRaw(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsRaw(cszFileTitle, ctyp) - return (ret) - - def SaveAsSif(self, path): - ''' - Description: - This function will save the data from the last acquisition into a file, which can be read in by the main application. User text can be added to sif files using the SaveAsCommentedSif and SetSifComment functions. - - Synopsis: - ret = SaveAsSif(path) - - Inputs: - path - pointer to a filename specified by the user. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSif(char * path); - - See Also: - SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment SaveAsCommentedSif - - ''' - cpath = path - ret = self.dll.SaveAsSif(cpath) - return (ret) - - def SaveAsSPC(self, path): - ''' - Description: - This function saves the last acquisition in the GRAMS .spc file format - - Synopsis: - ret = SaveAsSPC(path) - - Inputs: - path - the filename to save too. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSPC(char * path); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsTiff SaveAsBmp - - ''' - cpath = path - ret = self.dll.SaveAsSPC(cpath) - return (ret) - - def SaveAsTiff(self, path, palette, position, typ): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively - - Synopsis: - ret = SaveAsTiff(path, palette, position, typ) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsTiff(char * path, char * palette, int position, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsBmp SaveAsTiffEx SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - ret = self.dll.SaveAsTiff(cpath, cpalette, cposition, ctyp) - return (ret) - - def SaveAsTiffEx(self, path, palette, position, typ, mode): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. This is an extended version of the SaveAsTiff function. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively. The mode parameter specifies the mode of output. Data can be output scaled from the min and max count values across the entire range of values (mode 0) or can remain unchanged (mode 1).Of course if the count value is higher or lower than the output data range then even in mode 1 data will be scaled. - - Synopsis: - ret = SaveAsTiffEx(path, palette, position, typ, mode) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - mode - The output mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_P5INVALID - mode not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsTiffEx(char * path, char * palette, int position, int typ, int mode); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - cmode = c_int(mode) - ret = self.dll.SaveAsTiffEx(cpath, cpalette, cposition, ctyp, cmode) - return (ret) - - def SaveEEPROMToFile(self, cFileName): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveEEPROMToFile(cFileName) - - Inputs: - cFileName - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveEEPROMToFile(char * cFileName); - - ''' - ccFileName = cFileName - ret = self.dll.SaveEEPROMToFile(ccFileName) - return (ret) - - def SaveToClipBoard(self, palette): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveToClipBoard(palette) - - Inputs: - palette - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveToClipBoard(char * palette); - - ''' - cpalette = palette - ret = self.dll.SaveToClipBoard(cpalette) - return (ret) - - def SelectDevice(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SelectDevice(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SelectDevice(int devNum); - - ''' - cdevNum = c_int(devNum) - ret = self.dll.SelectDevice(cdevNum) - return (ret) - - def SendSoftwareTrigger(self): - ''' - Description: - This function sends an event to the camera to take an acquisition when in Software Trigger mode. Not all cameras have this mode available to them. To check if your camera can operate in this mode check the GetCapabilities function for the Trigger Mode AC_TRIGGERMODE_CONTINUOUS. If this mode is physically possible and other settings are suitable (IsTriggerModeAvailable) and the camera is acquiring then this command will take an acquisition. - - Synopsis: - ret = SendSoftwareTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger sent - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - Not in SoftwareTrigger mode - DRV_IDLE - Not Acquiring - DRV_ERROR_CODES - Error communicating with camera - DRV_ERROR_ACK - Previous acquisition not complete - - C++ Equiv: - unsigned int SendSoftwareTrigger(void); - - See Also: - GetCapabilities IsTriggerModeAvailable SetAcquisitionMode SetReadMode SetTriggerMode - - Note: The settings of the camera must be as follows: - ReadOut mode is full image - RunMode is Run Till Abort - TriggerMode is 10 - - - - - ''' - ret = self.dll.SendSoftwareTrigger() - return (ret) - - def SetAccumulationCycleTime(self, time): - ''' - Description: - This function will set the accumulation cycle time to the nearest valid value not less than the given value. The actual cycle time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetAccumulationCycleTime(time) - - Inputs: - time - the accumulation cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure time invalid. - - C++ Equiv: - unsigned int SetAccumulationCycleTime(float time); - - See Also: - SetNumberAccumulations GetAcquisitionTimings - - ''' - ctime = c_float(time) - ret = self.dll.SetAccumulationCycleTime(ctime) - return (ret) - - def SetAcqStatusEvent(self, statusEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the camera has started exposing or that the camera has finished exposing. To determine what event has actually occurred call the GetCameraEventStatus funtion. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. The SetPCIMode function must be called to enable/disable the events from the driver. - - Synopsis: - ret = SetAcqStatusEvent(statusEvent) - - Inputs: - statusEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetAcqStatusEvent(at_32 statusEvent); - - See Also: - GetCameraEventStatus SetPCIMode - - Note: This is only available with the CCI23 PCI card. - - ''' - cstatusEvent = c_int(statusEvent) - ret = self.dll.SetAcqStatusEvent(cstatusEvent) - return (ret) - - def SetAcquisitionMode(self, mode): - ''' - Description: - This function will set the acquisition mode to be used on the next StartAcquisitionStartAcquisition. - - Synopsis: - ret = SetAcquisitionMode(mode) - - Inputs: - mode - the acquisition mode.: - 1 - Single Scan - 2 - Accumulate - 3 - Kinetics - 4 - Fast Kinetics - 5 - Run till abort - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid. - - C++ Equiv: - unsigned int SetAcquisitionMode(int mode); - - See Also: - StartAcquisition - - Note: In Mode 5 the system uses a Run Till Abort acquisition mode. In Mode 5 only, the camera continually acquires data until the AbortAcquisitionAbortAcquisition function is called. By using the SetDriverEventSetDriverEvent function you will be notified as each acquisition is completed. - - ''' - cmode = c_int(mode) - ret = self.dll.SetAcquisitionMode(cmode) - return (ret) - - def SetAcquisitionType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetAcquisitionType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetAcquisitionType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetAcquisitionType(ctyp) - return (ret) - - def SetADChannel(self, channel): - ''' - Description: - This function will set the AD channel to one of the possible A-Ds of the system. This AD channel will be used for all subsequent operations performed by the system. - - Synopsis: - ret = SetADChannel(channel) - - Inputs: - channel - the channel to be used 0 to GetNumberADChannelsGetNumberADChannels-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AD channel set. - DRV_P1INVALID - Index is out of range. - - C++ Equiv: - unsigned int SetADChannel(int channel); - - See Also: - GetNumberADChannels - - ''' - cchannel = c_int(channel) - ret = self.dll.SetADChannel(cchannel) - return (ret) - - def SetAdvancedTriggerModeState(self, iState): - ''' - Description: - This function will set the state for the iCam functionality that some cameras are capable of. There may be some cases where we wish to prevent the software using the new functionality and just do it the way it was previously done. - - Synopsis: - ret = SetAdvancedTriggerModeState(iState) - - Inputs: - iState - 0: turn off iCam: - 1 - 1 Enable iCam. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - state invalid - - C++ Equiv: - unsigned int SetAdvancedTriggerModeState(int iState); - - See Also: - iCam - - Note: By default the advanced trigger functionality is enabled. - - ''' - ciState = c_int(iState) - ret = self.dll.SetAdvancedTriggerModeState(ciState) - return (ret) - - def SetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = SetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int SetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.SetBackground(byref(carr), csize) - return (ret, carr.value) - - def SetBaselineClamp(self, state): - ''' - Description: - This function turns on and off the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - ret = SetBaselineClamp(state) - - Inputs: - state - Enables/Disables Baseline clamp functionality: - 1 - Enable Baseline Clamp - 0 - Disable Baseline Clamp - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetBaselineClamp(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetBaselineClamp(cstate) - return (ret) - - def SetBaselineOffset(self, offset): - ''' - Description: - This function allows the user to move the baseline level by the amount selected. For example +100 will add approximately 100 counts to the default baseline value. The value entered should be a multiple of 100 between -1000 and +1000 inclusively. - - Synopsis: - ret = SetBaselineOffset(offset) - - Inputs: - offset - Amount to offset baseline by - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Baseline Clamp not available for this camera - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Offset out of range - - C++ Equiv: - unsigned int SetBaselineOffset(int offset); - - Note: Only available on iXon range - - ''' - coffset = c_int(offset) - ret = self.dll.SetBaselineOffset(coffset) - return (ret) - - def SetCameraLinkMode(self, mode): - ''' - Description: - This function allows the user to enable or disable the Camera Link functionality for the camera. Enabling this functionality will start to stream all acquired data through the camera link interface. - - Synopsis: - ret = SetCameraLinkMode(mode) - - Inputs: - mode - Enables/Disables Camera Link mode: - 1 - Enable Camera Link - 0 - Disable Camera Link - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - Camera Link not supported by this Camera - DRV_P1INVALID - Mode was not zero or one. - - C++ Equiv: - unsigned int SetCameraLinkMode(int mode); - - Note: Only available with iXon Ultra. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCameraLinkMode(cmode) - return (ret) - - def SetCameraStatusEnable(self, Enable): - ''' - Description: - Use this function to Mask out certain types of acquisition status events. The default is to notify on every type of event but this may cause missed events if different types of event occur very close together. The bits in the mask correspond to the following event types: - Use0 - Fire pulse down event - Use1 - Fire pulse up event - Set the corresponding bit to 0 to disable the event type and 1 to enable the event type. - - Synopsis: - ret = SetCameraStatusEnable(Enable) - - Inputs: - Enable - bitmask with bits set for those events about which you wish to be notified. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mask Set. - DRV_VXDNOTINSTALLED - Device Driver not installed. - - C++ Equiv: - unsigned int SetCameraStatusEnable(DWORD Enable); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: Only available with PCI systems using the CCI-23 controller card. - - Fire pulse up event not available on USB systems. - - - ''' - cEnable = (Enable) - ret = self.dll.SetCameraStatusEnable(cEnable) - return (ret) - - def SetChargeShifting(self, NumberRows, NumberRepeats): - ''' - Description: - Use this function in External Charge Shifting trigger mode to configure how many rows to shift and how many times for each frame of data. The number of repeats must be a multiple of 2. - - Synopsis: - ret = SetChargeShifting(NumberRows, NumberRepeats) - - Inputs: - NumberRows - number of rows to shift after each external trigger - NumberRepeats - number of times to shift rows - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Trigger mode not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of rows invalid. - DRV_P2INVALID - Number of repeats invalid. - - C++ Equiv: - unsigned int SetChargeShifting(unsigned int NumberRows, unsigned int NumberRepeats); - - See Also: - SetTriggerMode GetCapabilities - - Note: Only available with certain iKon-M systems. - - ''' - cNumberRows = c_uint(NumberRows) - cNumberRepeats = c_uint(NumberRepeats) - ret = self.dll.SetChargeShifting(cNumberRows, cNumberRepeats) - return (ret) - - def SetComplexImage(self, numAreas): - ''' - Description: - This is a function that allows the setting up of random tracks with more options that the SetRandomTracks function. - The minimum number of tracks is 1. The maximum number of tracks is the number of vertical pixels. - There is a further limit to the number of tracks that can be set due to memory constraints in the camera. It is not a fixed number but depends upon the combinations of the tracks. For example, 20 tracks of different heights will take up more memory than 20 tracks of the same height. - If attempting to set a series of random tracks and the return code equals DRV_RANDOM_TRACK_ERROR, change the makeup of the tracks to have more repeating heights and gaps so less memory is needed. - Each track must be defined by a group of six integers. - -The top and bottom positions of the tracks. - -The left and right positions for the area of interest within each track - -The horizontal and vertical binning for each track. - The positions of the tracks are validated to ensure that the tracks are in increasing order. - The left and right positions for each track must be the same. - For iXon the range is between 8 and CCD width, inclusive - For idus the range must be between 257 and CCD width, inclusive. - Horizontal binning must be an integer between 1 and 64 inclusive, for iXon. - Horizontal binning is not implementated for iDus and must be set to 1. - Vertical binning is used in the following way. A track of: - 1 10 1 1024 1 2 - is actually implemented as 5 tracks of height 2. . Note that a vertical binning of 1 will have the effect of vertically binning the entire track; otherwise vertical binning will operate as normal. - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 - - Synopsis: - (ret, areas) = SetComplexImage(numAreas) - - Inputs: - numAreas - int * areas: - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_RANDOM_TRACK_ERROR - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_ERROR_FILELOAD - Serious internal error - areas - - - C++ Equiv: - unsigned int SetComplexImage(int numAreas, int * areas); - - See Also: - SetRandomTracks - - Note: Only available with iXon+ and USB cameras. - - ''' - cnumAreas = c_int(numAreas) - careas = c_int() - ret = self.dll.SetComplexImage(cnumAreas, byref(careas)) - return (ret, careas.value) - - def SetCoolerMode(self, mode): - ''' - Description: - This function determines whether the cooler is switched off when the camera is shut down. - - Synopsis: - ret = SetCoolerMode(mode) - - Inputs: - mode - : - 0 - Returns to ambient temperature on ShutDown - 1 - Temperature is maintained on ShutDown - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - DRV_NOT_SUPPORTED - Camera does not support - - C++ Equiv: - unsigned int SetCoolerMode(int mode); - - Note: Mode 0 not available on Luca R cameras always cooled to -20C. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCoolerMode(cmode) - return (ret) - - def SetCountConvertMode(self, Mode): - ''' - Description: - This function configures the Count Convert mode. - - Synopsis: - ret = SetCountConvertMode(Mode) - - Inputs: - Mode - : - 0 - Data in Counts - 1 - Data in Electrons - 2 - Data in Photons - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Count Convert not available for this camera - DRV_NOT_AVAILABLE - Count Convert mode not available with current settings - DRV_P1INVALID - Mode parameter was out of range. - - C++ Equiv: - unsigned int SetCountConvertMode(int Mode); - - See Also: - GetCapabilities SetCountConvertWavelength - - Note: Only available on Clara, iXon 3 and iXon Ultra. - - Modes 1 and 2 are only available when: - * Baseline Clamp active - * Isolated crop mode off - * EM gain must be greater than or equal to 10 and the lowest pre-amp not be selected - * For Clara systems the extended infra red mode can not be used - - - ''' - cMode = c_int(Mode) - ret = self.dll.SetCountConvertMode(cMode) - return (ret) - - def SetCountConvertWavelength(self, wavelength): - ''' - Description: - This function configures the wavelength used in Count Convert mode. - - Synopsis: - ret = SetCountConvertWavelength(wavelength) - - Inputs: - wavelength - wavelength used to determine QE - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Count Convert not available for this camera - DRV_P1INVALID - Wavelength value was out of range. - - C++ Equiv: - unsigned int SetCountConvertWavelength(float wavelength); - - See Also: - GetCapabilities SetCountConvertMode - - ''' - cwavelength = c_float(wavelength) - ret = self.dll.SetCountConvertWavelength(cwavelength) - return (ret) - - def SetCropMode(self, active, cropHeight, reserved): - ''' - Description: - This function effectively reduces the height of the CCD by excluding some rows to achieve higher frame rates. This is currently only available on Newton cameras when the selected read mode is Full Vertical Binning. The cropHeight is the number of active rows measured from the bottom of the CCD. - Note: it is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetCropMode(active, cropHeight, reserved) - - Inputs: - active - Crop mode active: - 0 - Crop mode is OFF - 1 - Crop mode if ON - cropHeight - The selected crop height. This value must be between 1 and the CCD: - height - int reserved: This value should be set to 0. - reserved - This value should be set to 0 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIAILIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Active parameter is not zero or one. - DRV_P2INVALID - Cropheight parameter is less than one or greater than the CCD height. - DRV_P3INVALID - Reserved parameter is not equal to zero. - DRV_NOT_SUPPORTED - Either the camera is not a Newton or the read mode is not Full Vertical Binning. - - C++ Equiv: - unsigned int SetCropMode(int active, int cropHeight, int reserved); - - See Also: - GetDetector SetIsolatedCropMode - - Note: Available on Newton - - ''' - cactive = c_int(active) - ccropHeight = c_int(cropHeight) - creserved = c_int(reserved) - ret = self.dll.SetCropMode(cactive, ccropHeight, creserved) - return (ret) - - def SetCurrentCamera(self, cameraHandle): - ''' - Description: - When multiple Andor cameras are installed this function allows the user to select which camera is currently active. Once a camera has been selected the other functions can be called as normal but they will only apply to the selected camera. If only 1 camera is installed calling this function is not required since that camera will be selected by default. - - Synopsis: - ret = SetCurrentCamera(cameraHandle) - - Inputs: - cameraHandle - Selects the active camera - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera successfully selected. - DRV_P1INVALID - Invalid camera handle. - - C++ Equiv: - unsigned int SetCurrentCamera(long cameraHandle); - - See Also: - GetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.SetCurrentCamera(ccameraHandle) - return (ret) - - def SetCustomTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning value to be used when the readout mode is set to Random Track. - - Synopsis: - ret = SetCustomTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetCustomTrackHBin(int bin); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cbin = c_int(bin) - ret = self.dll.SetCustomTrackHBin(cbin) - return (ret) - - def SetDACOutput(self, iOption, iResolution, iValue): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to set the required voltage. - - Synopsis: - ret = SetDACOutput(iOption, iResolution, iValue) - - Inputs: - iOption - DAC Output DAC Pin 1 or 2 (1/2). - iResolution - resolution of DAC can be set from 2 to 16-bit in steps of 2 - iValue - requested DAC value (for particular resolution) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available. - DRV_P1INVALID - DAC range value invalid. - DRV_P2INVALID - Resolution unavailable. - DRV_P3INVALID - Requested value not within DAC range. - - C++ Equiv: - unsigned int SetDACOutput(int iOption, int iResolution, int iValue); - - See Also: - SetDACOutputScale - - Note: Only available on Andor Clara - - ''' - ciOption = c_int(iOption) - ciResolution = c_int(iResolution) - ciValue = c_int(iValue) - ret = self.dll.SetDACOutput(ciOption, ciResolution, ciValue) - return (ret) - - def SetDACOutputScale(self, iScale): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to select the active one. - - Synopsis: - ret = SetDACOutputScale(iScale) - - Inputs: - iScale - 5 or 10 volt DAC range (1/2). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available - DRV_P1INVALID - DAC Scale value invalid. - - C++ Equiv: - unsigned int SetDACOutputScale(int iScale); - - See Also: - SetDACOutput - - Note: Only available on Andor Clara - - ''' - ciScale = c_int(iScale) - ret = self.dll.SetDACOutputScale(ciScale) - return (ret) - - def SetDataType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDataType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDataType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetDataType(ctyp) - return (ret) - - def SetDDGAddress(self, t0, t1, t2, t3, address): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGAddress(t0, t1, t2, t3, address) - - Inputs: - t0 - - t1 - - t2 - - t3 - - address - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGAddress(BYTE t0, BYTE t1, BYTE t2, BYTE t3, BYTE address); - - ''' - ct0 = c_ubyte(t0) - ct1 = c_ubyte(t1) - ct2 = c_ubyte(t2) - ct3 = c_ubyte(t3) - caddress = c_ubyte(address) - ret = self.dll.SetDDGAddress(ct0, ct1, ct2, ct3, caddress) - return (ret) - - def SetDDGExternalOutputEnabled(self, uiIndex, uiEnabled): - ''' - Description: - This function sets the state of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputPolarity(self, uiIndex, uiPolarity): - ''' - Description: - This function sets the polarity of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputPolarity(uiIndex, uiPolarity) - - Inputs: - uiIndex - index of external output. - uiPolarity - polarity of external output (0 - Positive,1 - Negative). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 uiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputPolarity - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiPolarity = c_uint(uiPolarity) - ret = self.dll.SetDDGExternalOutputPolarity(cuiIndex, cuiPolarity) - return (ret) - - def SetDDGExternalOutputStepEnabled(self, uiIndex, uiEnabled): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to set the state of this option. - - Synopsis: - ret = SetDDGExternalOutputStepEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output track step (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputStepEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputStepEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputTime(self, uiIndex, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the timings for a particular external output. - - Synopsis: - ret = SetDDGExternalOutputTime(uiIndex, uiDelay, uiWidth) - - Inputs: - uiIndex - index of external output. - uiDelay - external output delay time in picoseconds. - uiWidth - external output width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGExternalOutputTime(at_u32 uiIndex, at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputTime - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGExternalOutputTime(cuiIndex, cuiDelay, cuiWidth) - return (ret) - - def SetDDGGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetDDGGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetDDGGain(cgain) - return (ret) - - def SetDDGGateStep(self, step): - ''' - Description: - This function will set a constant value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGGateStep(step) - - Inputs: - step - gate step in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step invalid. - - C++ Equiv: - unsigned int SetDDGGateStep(double step); - - See Also: - SetDDGTimes SetDDGVariableGateStep - - Note: Available on iStar. - - ''' - cstep = c_double(step) - ret = self.dll.SetDDGGateStep(cstep) - return (ret) - - def SetDDGGateTime(self, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the gate timings for a USB iStar. - - Synopsis: - ret = SetDDGGateTime(uiDelay, uiWidth) - - Inputs: - uiDelay - gate delay time in picoseconds. - uiWidth - gate width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGGateTime(at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGGateTime - - ''' - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGGateTime(cuiDelay, cuiWidth) - return (ret) - - def SetDDGInsertionDelay(self, state): - ''' - Description: - This function controls the length of the insertion delay. - - Synopsis: - ret = SetDDGInsertionDelay(state) - - Inputs: - state - NORMAL/FAST switch for insertion delay.: - 0 - to set normal insertion delay. - 1 - to set fast insertion delay. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for delay accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGInsertionDelay(int state); - - See Also: - GetCapabilities SetDDGIntelligate - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGInsertionDelay(cstate) - return (ret) - - def SetDDGIntelligate(self, state): - ''' - Description: - This function controls the MCP gating. Not available when the fast insertion delay option is selected. - - Synopsis: - ret = SetDDGIntelligate(state) - - Inputs: - state - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIntelligate(int state); - - See Also: - GetCapabilities SetDDGInsertionDelay - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIntelligate(cstate) - return (ret) - - def SetDDGIOC(self, state): - ''' - Description: - This function activates the integrate on chip (IOC) option. - - Synopsis: - ret = SetDDGIOC(state) - - Inputs: - state - ON/OFF switch for the IOC option.: - 0 - to switch IOC OFF. - 1 - to switch IOC ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIOC(int state); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIOC(cstate) - return (ret) - - def SetDDGIOCFrequency(self, frequency): - ''' - Description: - This function sets the frequency of the integrate on chip option. It should be called once the conditions of the experiment have been setup in order for correct operation. The frequency should be limited to 5000Hz when intelligate is activated to prevent damage to the head and 50000Hz otherwise to prevent the gater from overheating. The recommended order is - ... - Experiment setup (exposure time, readout mode, gate parameters, ...) - ... - SetDDGIOCFrequency (x) - SetDDGIOCSetDDGIOC(true) - GetDDGIOCPulses(y) - StartAcquisitionStartAcquisition() - - Synopsis: - ret = SetDDGIOCFrequency(frequency) - - Inputs: - frequency - frequency of IOC option in Hz. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for frequency accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetDDGIOCFrequency(double frequency); - - See Also: - GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cfrequency = c_double(frequency) - ret = self.dll.SetDDGIOCFrequency(cfrequency) - return (ret) - - def SetDDGIOCNumber(self, numberPulses): - ''' - Description: - This function allows the user to limit the number of pulses used in the integrate on chip option at a given frequency. It should be called once the conditions of the experiment have been setup in order for correct operation. - - Synopsis: - ret = SetDDGIOCNumber(numberPulses) - - Inputs: - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for IOC number accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - IOC not supported - DRV_ERROR_ACK - Unable to communicate with card - - C++ Equiv: - unsigned int SetDDGIOCNumber(long numberPulses); - - See Also: - SetDDGIOCFrequency GetDDGIOCFrequency GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cnumberPulses = c_int(numberPulses) - ret = self.dll.SetDDGIOCNumber(cnumberPulses) - return (ret) - - def SetDDGIOCPeriod(self, period): - ''' - Description: - This function can be used to set the IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - ret = SetDDGIOCPeriod(period) - - Inputs: - period - the period of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid period. - - C++ Equiv: - unsigned int SetDDGIOCPeriod(at_u64 period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency GetDDGIOCPeriod - - ''' - cperiod = c_ulonglong(period) - ret = self.dll.SetDDGIOCPeriod(cperiod) - return (ret) - - def SetDDGIOCTrigger(self, trigger): - ''' - Description: - This function can be used to select whether to trigger the IOC pulse train with either the rising edge of the fire pulse or an externally supplied trigger. - - Synopsis: - ret = SetDDGIOCTrigger(trigger) - - Inputs: - trigger - IOC Trigger Option: - 0 - Fire pulse - 1 - External Trigger - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC trigger set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid trigger. - - C++ Equiv: - unsigned int SetDDGIOCTrigger(at_u32 trigger); - - See Also: - GetCapabilities GetDDGIOCTrigger SetDDGIOC SetTriggerMode - - ''' - ctrigger = c_uint(trigger) - ret = self.dll.SetDDGIOCTrigger(ctrigger) - return (ret) - - def SetDDGLiteControlByte(self, channel, control): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - ret = SetDDGLiteControlByte(channel, control) - - Inputs: - channel - - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteControlByte(AT_DDGLiteChannelId channel, char control); - - ''' - cchannel = (channel) - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteControlByte(cchannel, ccontrol) - return (ret) - - def SetDDGLiteGlobalControlByte(self, control): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteGlobalControlByte(control) - - Inputs: - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteGlobalControlByte(char control); - - ''' - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteGlobalControlByte(ccontrol) - return (ret) - - def SetDDGLiteInitialDelay(self, channel, fDelay): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteInitialDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInitialDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLiteInterPulseDelay(self, channel, fDelay): - ''' - Description: - - - Synopsis: - ret = SetDDGLiteInterPulseDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInterPulseDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLitePulsesPerExposure(self, channel, ui32Pulses): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulsesPerExposure(channel, ui32Pulses) - - Inputs: - channel - - ui32Pulses - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint(ui32Pulses) - ret = self.dll.SetDDGLitePulsesPerExposure(cchannel, cui32Pulses) - return (ret) - - def SetDDGLitePulseWidth(self, channel, fWidth): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulseWidth(channel, fWidth) - - Inputs: - channel - - fWidth - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float(fWidth) - ret = self.dll.SetDDGLitePulseWidth(cchannel, cfWidth) - return (ret) - - def SetDDGOpticalWidthEnabled(self, uiEnabled): - ''' - Description: - This function can be used to configure a system to use optical gate width. - - Synopsis: - ret = SetDDGOpticalWidthEnabled(uiEnabled) - - Inputs: - uiEnabled - optical gate width option (0 - Off, 1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGOpticalWidthEnabled(at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth GetDDGOpticalWidthEnabled - - ''' - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGOpticalWidthEnabled(cuiEnabled) - return (ret) - - def SetDDGStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - StartAcquisition SetDDGStepMode GetDDGStepMode GetDDGStepCoefficients - - Note: Available on iStar and USB iStar. - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGStepMode(self, mode): - ''' - Description: - This function will set the current gate step mode. - - Synopsis: - ret = SetDDGStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGStepMode(at_u32 mode); - - See Also: - StartAcquisition GetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGStepMode(cmode) - return (ret) - - def SetDDGTimes(self, t0, t1, t2): - ''' - Description: - This function sets the properties of the gate pulse. t0 has a resolution of 16 nanoseconds whilst t1 and t2 have a resolution of 25 picoseconds. - - Synopsis: - ret = SetDDGTimes(t0, t1, t2) - - Inputs: - t0 - output A delay in nanoseconds. - t1 - gate delay in picoseconds. - t2 - pulse width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Values for gate pulse accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid output A delay. - DRV_P2INVALID - Invalid gate delay. - DRV_P3INVALID - Invalid pulse width. - - C++ Equiv: - unsigned int SetDDGTimes(double t0, double t1, double t2); - - See Also: - SetDDGGateStep - - Note: Available on iStar. - - ''' - ct0 = c_double(t0) - ct1 = c_double(t1) - ct2 = c_double(t2) - ret = self.dll.SetDDGTimes(ct0, ct1, ct2) - return (ret) - - def SetDDGTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode of the internal delay generator to either internal or External - - Synopsis: - ret = SetDDGTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetDDGTriggerMode(int mode); - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - ret = self.dll.SetDDGTriggerMode(cmode) - return (ret) - - def SetDDGVariableGateStep(self, mode, p1, p2): - ''' - Description: - This function will set a varying value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGVariableGateStep(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 1 - Exponential (p1*exp(p2*n)) - 2 - Logarithmic (p1*log(p2*n)) - 3 - Linear (p1 + p2*n) - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGVariableGateStep(int mode, double p1, double p2); - - See Also: - StartAcquisition - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGVariableGateStep(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate width step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGWidthStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - - n = 1, 2, ..., number in kinetic series - p1 - The first coefficient - p2 - The second coefficient - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGWidthStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - SetDDGWidthStepMode GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGWidthStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepMode(self, mode): - ''' - Description: - This function will set the current gate width step mode. - - Synopsis: - ret = SetDDGWidthStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGWidthStepMode(at_u32 mode); - - See Also: - SetDDGWidthStepCoefficients GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGWidthStepMode(cmode) - return (ret) - - def SetDelayGenerator(self, board, address, typ): - ''' - Description: - This function sets parameters to control the delay generator through the GPIB card in your computer. - - Synopsis: - ret = SetDelayGenerator(board, address, typ) - - Inputs: - board - The GPIB board number of the card used to interface with the Delay Generator.: - short - address: The number that allows the GPIB board to identify and send commands to the delay generator. - address - The number that allows the GPIB board to identify and send commands to the delay generator. - - typ - The type of your Delay Generator. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Delay Generator set up. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - GPIB board invalid. - DRV_P2INVALID - GPIB address invalid - DRV_P3INVALID - Delay generator type invalid. - - C++ Equiv: - unsigned int SetDelayGenerator(int board, short address, int typ); - - See Also: - SetGate - - Note: Available on ICCD. - - ''' - cboard = c_int(board) - caddress = c_short(address) - ctyp = c_int(typ) - ret = self.dll.SetDelayGenerator(cboard, caddress, ctyp) - return (ret) - - def SetDMAParameters(self, MaxImagesPerDMA, SecondsPerDMA): - ''' - Description: - In order to facilitate high image readout rates the controller card may wait for multiple images to be acquired before notifying the SDK that new data is available. Without this facility, there is a chance that hardware interrupts may be lost as the operating system does not have enough time to respond to each interrupt. The drawback to this is that you will not get the data for an image until all images for that interrupt have been acquired. - There are 3 settings involved in determining how many images will be acquired for each notification (DMA interrupt) of the controller card and they are as follows: - 1. The size of the DMA buffer gives an upper limit on the number of images that can be stored within it and is usually set to the size of one full image when installing the software. This will usually mean that if you acquire full frames there will never be more than one image per DMA. - 2. A second setting that is used is the minimum amount of time (SecondsPerDMA) that should expire between interrupts. This can be used to give an indication of the reponsiveness of the operating system to interrupts. Decreasing this value will allow more interrupts per second and should only be done for faster pcs. The default value is 0.03s (30ms), finding the optimal value for your pc can only be done through experimentation. - 3. The third setting is an overide to the number of images calculated using the previous settings. If the number of images per dma is calculated to be greater than MaxImagesPerDMA then it will be reduced to MaxImagesPerDMA. This can be used to, for example, ensure that there is never more than 1 image per DMA by setting MaxImagesPerDMA to 1. Setting MaxImagesPerDMA to zero removes this limit. Care should be taken when modifying these parameters as missed interrupts may prevent the acquisition from completing. - - Synopsis: - ret = SetDMAParameters(MaxImagesPerDMA, SecondsPerDMA) - - Inputs: - MaxImagesPerDMA - Override to the number of images per DMA if the calculated value is higher than this. (Default=0, ie. no override) - SecondsPerDMA - Minimum amount of time to elapse between interrrupts. (Default=0.03s) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DMA Parameters setup successfully. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - MaxImagesPerDMA invalid - DRV_P2INVALID - SecondsPerDMA invalid - - C++ Equiv: - unsigned int SetDMAParameters(int MaxImagesPerDMA, float SecondsPerDMA); - - ''' - cMaxImagesPerDMA = c_int(MaxImagesPerDMA) - cSecondsPerDMA = c_float(SecondsPerDMA) - ret = self.dll.SetDMAParameters(cMaxImagesPerDMA, cSecondsPerDMA) - return (ret) - - def SetDriverEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the SDK via which the the user software can be informed that something has occurred. For example the SDK can set the event when an acquisition has completed thus relieving the user code of having to continually pole to check on the status of the acquisition. - The event will be set under the follow conditions: - 1) Acquisition completed or aborted. - 2) As each scan during an acquisition is completed. - 3) Temperature as stabilized, drifted from stabilization or could not be reached. - When an event is triggered the user software can then use other SDK functions to determine what actually happened. - Condition 1 and 2 can be tested via GetStatusGetStatus function, while condition 3 checked via GetTemperatureGetTemperature function. - You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetDriverEvent with NULL as the parameter. - - Synopsis: - ret = SetDriverEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetDriverEvent(HANDLE driverEvent); - - See Also: - GetStatus GetTemperature GetAcquisitionProgress - - Note: Not all programming environments allow the use of multiple threads and WIN32 events. - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetDriverEvent(cdriverEvent) - return (ret) - - def SetDualExposureMode(self, mode): - ''' - Description: - This function turns on and off the option to acquire 2 frames for each external trigger pulse. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureMode(mode) - - Inputs: - mode - Enables/Disables dual exposure mode: - 1 - Enable mode - 0 - Disable mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode parameter was not zero or one. - - C++ Equiv: - unsigned int SetDualExposureMode(int mode); - - See Also: - GetCapabilities SetDualExposureTimes GetDualExposureTimes - - ''' - cmode = c_int(mode) - ret = self.dll.SetDualExposureMode(cmode) - return (ret) - - def SetDualExposureTimes(self, expTime1, expTime2): - ''' - Description: - This function configures the two exposure times used in dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureTimes(expTime1, expTime2) - - Inputs: - expTime1 - the exposure time in seconds for each odd numbered frame. - expTime2 - the exposure time in seconds for each even numbered frame. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - First exposure out of range. - DRV_P2INVALID - Second exposure out of range. - - C++ Equiv: - unsigned int SetDualExposureTimes(float expTime1, float expTime2); - - See Also: - GetCapabilities SetDualExposureMode GetDualExposureTimes - - ''' - cexpTime1 = c_float(expTime1) - cexpTime2 = c_float(expTime2) - ret = self.dll.SetDualExposureTimes(cexpTime1, cexpTime2) - return (ret) - - def SetEMAdvanced(self, state): - ''' - Description: - This function turns on and off access to higher EM gain levels within the SDK. Typically, optimal signal to noise ratio and dynamic range is achieved between x1 to x300 EM Gain. Higher gains of > x300 are recommended for single photon counting only. Before using higher levels, you should ensure that light levels do not exceed the regime of tens of photons per pixel, otherwise accelerated ageing of the sensor can occur. - - Synopsis: - ret = SetEMAdvanced(state) - - Inputs: - state - Enables/Disables access to higher EM gain levels: - 1 - Enable access - 1 - Disable access - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Advanced EM gain not available for this camera. - DRV_ACQUIRING. - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetEMAdvanced(int state); - - See Also: - GetCapabilities GetEMCCDGain SetEMCCDGain SetEMGainMode - - ''' - cstate = c_int(state) - ret = self.dll.SetEMAdvanced(cstate) - return (ret) - - def SetEMCCDGain(self, gain): - ''' - Description: - Allows the user to change the gain value. The valid range for the gain depends on what gain mode the camera is operating in. See SetEMGainMode to set the mode and GetEMGainRange to get the valid range to work with. To access higher gain values (>x300) see SetEMAdvanced. - - Synopsis: - ret = SetEMCCDGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetEMCCDGain(int gain); - - See Also: - GetEMCCDGain SetEMGainMode GetEMGainRange SetEMAdvanced - - Note: Only available on EMCCD sensor systems. - - ''' - cgain = c_int(gain) - ret = self.dll.SetEMCCDGain(cgain) - return (ret) - - def SetEMClockCompensation(self, EMClockCompensationFlag): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetEMClockCompensation(EMClockCompensationFlag) - - Inputs: - EMClockCompensationFlag - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetEMClockCompensation(int EMClockCompensationFlag); - - ''' - cEMClockCompensationFlag = c_int(EMClockCompensationFlag) - ret = self.dll.SetEMClockCompensation(cEMClockCompensationFlag) - return (ret) - - def SetEMGainMode(self, mode): - ''' - Description: - Set the EM Gain mode to one of the following possible settings. - Mode 0: The EM Gain is controlled by DAC settings in the range 0-255. Default mode. - 1: The EM Gain is controlled by DAC settings in the range 0-4095. - 2: Linear mode. - 3: Real EM gain - To access higher gain values (if available) it is necessary to enable advanced EM gain, see SetEMAdvanced. - - Synopsis: - ret = SetEMGainMode(mode) - - Inputs: - mode - EM Gain mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - EM Gain mode invalid. - - C++ Equiv: - unsigned int SetEMGainMode(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetEMGainMode(cmode) - return (ret) - - def SetExposureTime(self, time): - ''' - Description: - This function will set the exposure time to the nearest valid value not less than the given value. The actual exposure time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetExposureTime(time) - - Inputs: - time - the exposure time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Exposure time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure Time invalid. - - C++ Equiv: - unsigned int SetExposureTime(float time); - - See Also: - GetAcquisitionTimings - - Note: For Classics, if the current acquisition mode is Single-Track, Multi-Track or Image then this function will actually set the Shutter Time. The actual exposure time used is obtained from the GetAcquisitionTimings functionGetAcquisitionTimings. - - ''' - ctime = c_float(time) - ret = self.dll.SetExposureTime(ctime) - return (ret) - - def SetExternalTriggerTermination(self, uiTermination): - ''' - Description: - This function can be used to set the external trigger termination mode. - - Synopsis: - ret = SetExternalTriggerTermination(uiTermination) - - Inputs: - uiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetExternalTriggerTermination(at_u32 uiTermination); - - See Also: - GetCapabilities GetExternalTriggerTermination - - ''' - cuiTermination = c_uint(uiTermination) - ret = self.dll.SetExternalTriggerTermination(cuiTermination) - return (ret) - - def SetFanMode(self, mode): - ''' - Description: - Allows the user to control the mode of the camera fan. If the system is cooled, the fan should only be turned off for short periods of time. During this time the body of the camera will warm up which could compromise cooling capabilities. - If the camera body reaches too high a temperature, depends on camera, the buzzer will sound. If this happens, turn off the external power supply and allow the system to stabilize before continuing. - - Synopsis: - ret = SetFanMode(mode) - - Inputs: - mode - Fan mode setting: - 0 - Fan on full. - 1 - Fan on low. - 2 - Fan off, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Mode value invalid. - - C++ Equiv: - unsigned int SetFanMode(int mode); - - See Also: - GetCapabilities - - ''' - cmode = c_int(mode) - ret = self.dll.SetFanMode(cmode) - return (ret) - - def SetFastExtTrigger(self, mode): - ''' - Description: - This function will enable fast external triggering. When fast external triggering is enabled the system will NOT wait until a Keep Clean cycle has been completed before accepting the next trigger. This setting will only have an effect if the trigger mode has been set to External via SetTriggerMode. - - Synopsis: - ret = SetFastExtTrigger(mode) - - Inputs: - mode - 0 Disabled: - 1 - Enabled - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters accepted. - - C++ Equiv: - unsigned int SetFastExtTrigger(int mode); - - See Also: - SetTriggerMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFastExtTrigger(cmode) - return (ret) - - def SetFastKinetics(self, exposedRows, seriesLength, time, mode, hbin, vbin): - ''' - Description: - This function will set the parameters to be used when taking a fast kinetics acquisition. - - Synopsis: - ret = SetFastKinetics(exposedRows, seriesLength, time, mode, hbin, vbin) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System not initialized. - DRV_NOT_INITIALIZED - Acquisition in progress. - DRV_ACQUIRING - Invalid height. - DRV_P1INVALID - Invalid number in series. - DRV_P2INVALID DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID DRV_P5INVALID - Mode must be equal to 0 or 4. - DRV_P6INVALID - Horizontal binning. - All parameters accepted. - Vertical binning. - - C++ Equiv: - unsigned int SetFastKinetics(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin); - - See Also: - SetFKVShiftSpeed SetFastKineticsEx SetFKVShiftSpeed - - Note: For classic cameras the vertical and horizontal binning must be 1 - For non classic cameras it is recommended that you use SetFastKineticsEx - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFastKinetics(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin) - return (ret) - - def SetFastKineticsEx(self, exposedRows, seriesLength, time, mode, hbin, vbin, offset): - ''' - Description: - This function is the same as SetFastKinetics with the addition of an Offset parameter, which will inform the SDK of the first row to be used. - - Synopsis: - ret = SetFastKineticsEx(exposedRows, seriesLength, time, mode, hbin, vbin, offset) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - offset - offset of first row to be used in Fast Kinetics from the bottom of the CCD. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid height. - DRV_P2INVALID - Invalid number in series. - DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID - Mode must be equal to 0 or 4. - DRV_P5INVALID - Horizontal binning. - DRV_P6INVALID - Vertical binning. - DRV_P7INVALID - Offset not within CCD limits - - C++ Equiv: - unsigned int SetFastKineticsEx(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin, int offset); - - See Also: - SetFKVShiftSpeed SetFastKinetics SetFKVShiftSpeed - - Note: For classic cameras the offset must be 0 and the vertical and horizontal binning must be 1 - For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - coffset = c_int(offset) - ret = self.dll.SetFastKineticsEx(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin, coffset) - return (ret) - - def SetFilterMode(self, mode): - ''' - Description: - This function will set the state of the cosmic ray filter mode for future acquisitions. If the filter mode is on, consecutive scans in an accumulation will be compared and any cosmic ray-like features that are only present in one scan will be replaced with a scaled version of the corresponding pixel value in the correct scan. - - Synopsis: - ret = SetFilterMode(mode) - - Inputs: - mode - current state of filter: - 0 - OFF - 2 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is out off range. - - C++ Equiv: - unsigned int SetFilterMode(int mode); - - See Also: - GetFilterMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFilterMode(cmode) - return (ret) - - def SetFilterParameters(self, width, sensitivity, range, accept, smooth, noise): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFilterParameters(width, sensitivity, range, accept, smooth, noise) - - Inputs: - width - - sensitivity - - range - - accept - - smooth - - noise - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFilterParameters(int width, float sensitivity, int range, float accept, int smooth, int noise); - - ''' - cwidth = c_int(width) - csensitivity = c_float(sensitivity) - crange = c_int(range) - caccept = c_float(accept) - csmooth = c_int(smooth) - cnoise = c_int(noise) - ret = self.dll.SetFilterParameters(cwidth, csensitivity, crange, caccept, csmooth, cnoise) - return (ret) - - def SetFKVShiftSpeed(self, index): - ''' - Description: - This function will set the fast kinetics vertical shift speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetFKVShiftSpeed(index) - - Inputs: - index - the speed to be used: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Fast kinetics vertical shift speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetFKVShiftSpeed(int index); - - See Also: - GetNumberFKVShiftSpeeds GetFKVShiftSpeedF - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - ret = self.dll.SetFKVShiftSpeed(cindex) - return (ret) - - def SetFPDP(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFPDP(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFPDP(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetFPDP(cstate) - return (ret) - - def SetFrameTransferMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Frame Transfer Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetFrameTransferMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame transfer mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetFrameTransferMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is a Frame Transfer chip. - - ''' - cmode = c_int(mode) - ret = self.dll.SetFrameTransferMode(cmode) - return (ret) - - def SetFrontEndEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the Front End cooler has overheated or returned to a normal state. To determine what event has actually occurred call the GetFrontEndStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetFrontEndEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetFrontEndEvent(at_32 driverEvent); - - See Also: - GetFrontEndStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetFrontEndEvent(cdriverEvent) - return (ret) - - def SetFullImage(self, hbin, vbin): - ''' - Description: - Deprecated see Note: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetFullImage(hbin, vbin) - - Inputs: - hbin - number of pixels to bin horizontally - vbin - number of pixels to bin vertically - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning parameters accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Horizontal binning parameter invalid - DRV_P2INVALID - Vertical binning parameter invalid - - C++ Equiv: - unsigned int SetFullImage(int hbin, int vbin); // deprecated - - See Also: - SetReadMode - - Note: Deprecated by SetImageGetNumberHSSpeeds - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFullImage(chbin, cvbin) - return (ret) - - def SetFVBHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Full Vertical Binned read mode. - - Synopsis: - ret = SetFVBHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetFVBHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetFVBHBin(cbin) - return (ret) - - def SetGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetGain(cgain) - return (ret) - - def SetGate(self, delay, width, stepRenamed): - ''' - Description: - This function sets the Gater parameters for an ICCD system. The image intensifier of the Andor ICCD acts as a shutter on nanosecond time-scales using a process known as gating. - - Synopsis: - ret = SetGate(delay, width, stepRenamed) - - Inputs: - delay - Sets the delay(>=0) between the T0 and C outputs on the SRS box to delay nanoseconds. - width - Sets the width(>=0) of the gate in nanoseconds - stepRenamed - Sets the amount(<>0, in nanoseconds) by which the gate position is moved in time after each scan in a kinetic series. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gater parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_GPIBERROR - Error communicating with GPIB card. - DRV_P1INVALID - Invalid delay - DRV_P2INVALID - Invalid width. - DRV_P3INVALID - Invalid step. - - C++ Equiv: - unsigned int SetGate(float delay, float width, float stepRenamed); - - See Also: - SetDelayGenerator - - Note: Available on ICCD. - - ''' - cdelay = c_float(delay) - cwidth = c_float(width) - cstepRenamed = c_float(stepRenamed) - ret = self.dll.SetGate(cdelay, cwidth, cstepRenamed) - return (ret) - - def SetGateMode(self, gatemode): - ''' - Description: - Allows the user to control the photocathode gating mode. - - Synopsis: - ret = SetGateMode(gatemode) - - Inputs: - gatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gating mode invalid. - - C++ Equiv: - unsigned int SetGateMode(int gatemode); - - See Also: - GetCapabilities SetMCPGain SetMCPGating - - ''' - cgatemode = c_int(gatemode) - ret = self.dll.SetGateMode(cgatemode) - return (ret) - - def SetHighCapacity(self, state): - ''' - Description: - This function switches between high sensitivity and high capacity functionality. With high capacity enabled the output amplifier is switched to a mode of operation which reduces the responsivity thus allowing the reading of larger charge packets during binning operations. - - Synopsis: - ret = SetHighCapacity(state) - - Inputs: - state - Enables/Disables High Capacity functionality: - 1 - Enable High Capacity (Disable High Sensitivity) - 0 - Disable High Capacity (Enable High Sensitivity) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetHighCapacity(int state); - - See Also: - GetCapabilities - - ''' - cstate = c_int(state) - ret = self.dll.SetHighCapacity(cstate) - return (ret) - - def SetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the horizontal speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetHorizontalSpeed(index) - - Inputs: - index - the horizontal speed to be used: - 0 - to GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHorizontalSpeed(int index); // deprecated - - See Also: - GetNumberHorizontalSpeeds GetHorizontalSpeed - - Note: Deprecated by SetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - ret = self.dll.SetHorizontalSpeed(cindex) - return (ret) - - def SetHSSpeed(self, typ, index): - ''' - Description: - This function will set the speed at which the pixels are shifted into the output node during the readout phase of an acquisition. Typically your camera will be capable of operating at several horizontal shift speeds. To get the actual speed that an index corresponds to use the GetHSSpeed function. Ensure the desired A/D channel has been set with SetADChannel before calling SetHSSpeed. - - Synopsis: - ret = SetHSSpeed(typ, index) - - Inputs: - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR mode(clara). - index - the horizontal speed to be used: - 0 - to GetNumberHSSpeeds()GetNumberHSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is invalid. - DRV_P2INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHSSpeed(int typ, int index); - - See Also: - GetNumberHSSpeeds GetHSSpeed GetNumberAmp - - ''' - ctyp = c_int(typ) - cindex = c_int(index) - ret = self.dll.SetHSSpeed(ctyp, cindex) - return (ret) - - def SetImage(self, hbin, vbin, hstart, hend, vstart, vend): - ''' - Description: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetImage(hbin, vbin, hstart, hend, vstart, vend) - - Inputs: - hbin - number of pixels to bin horizontally. - vbin - number of pixels to bin vertically. - hstart - Start column (inclusive). - hend - End column (inclusive). - vstart - Start row (inclusive). - vend - End row (inclusive). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Binning parameters invalid. - DRV_P2INVALID - Binning parameters invalid. - DRV_P3INVALID - Sub-area co-ordinate is invalid. - DRV_P4INVALID - Sub-area co-ordinate is invalid. - DRV_P5INVALID - Sub-area co-ordinate is invalid. - DRV_P6INVALID - Sub-area co-ordinate is invalid. - - C++ Equiv: - unsigned int SetImage(int hbin, int vbin, int hstart, int hend, int vstart, int vend); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - chstart = c_int(hstart) - chend = c_int(hend) - cvstart = c_int(vstart) - cvend = c_int(vend) - ret = self.dll.SetImage(chbin, cvbin, chstart, chend, cvstart, cvend) - return (ret) - - def SetImageFlip(self, iHFlip, iVFlip): - ''' - Description: - This function will cause data output from the SDK to be flipped on one or both axes. This flip is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If flipping could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageFlip(iHFlip, iVFlip) - - Inputs: - iHFlip - Sets horizontal flipping. - iVFlip - Sets vertical flipping..: - 1 - Enables Flipping - 0 - Disables Flipping - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - - C++ Equiv: - unsigned int SetImageFlip(int iHFlip, int iVFlip); - - See Also: - SetImageRotate - - Note: If this function is used in conjunction with the SetImageRotate function the rotation will occur before the flip regardless of which order the functions are called. - - ''' - ciHFlip = c_int(iHFlip) - ciVFlip = c_int(iVFlip) - ret = self.dll.SetImageFlip(ciHFlip, ciVFlip) - return (ret) - - def SetImageRotate(self, iRotate): - ''' - Description: - This function will cause data output from the SDK to be rotated on one or both axes. This rotate is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If the rotation could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageRotate(iRotate) - - Inputs: - iRotate - Rotation setting: - 0 - No rotation. - 1 - Rotate 90 degrees clockwise. - 2 - Rotate 90 degrees anti-clockwise. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - - C++ Equiv: - unsigned int SetImageRotate(int iRotate); - - See Also: - SetImageFlip - - Note: If this function is used in conjunction with the SetImageFlip function the rotation will occur before the flip regardless of which order the functions are called. 180 degree rotation can be achieved using the SetImageFlip function by selecting both horizontal and vertical flipping. - - ''' - ciRotate = c_int(iRotate) - ret = self.dll.SetImageRotate(ciRotate) - return (ret) - - def SetIODirection(self, index, iDirection): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIODirection(index, iDirection) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iDirection - requested direction for this index.: - 0 - 0 Output - 1 - 1 Input - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid direction. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIODirection(int index, int iDirection); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int(iDirection) - ret = self.dll.SetIODirection(cindex, ciDirection) - return (ret) - - def SetIOLevel(self, index, iLevel): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIOLevel(index, iLevel) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid level. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIOLevel(int index, int iLevel); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIODirection - - ''' - cindex = c_int(index) - ciLevel = c_int(iLevel) - ret = self.dll.SetIOLevel(cindex, ciLevel) - return (ret) - - def SetIsolatedCropMode(self, active, cropheight, cropwidth, vbin, hbin): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. In isolated crop mode iXon, Newton and iKon cameras can operate in either Full Vertical Binning or Imaging read modes. iDus can operate in Full Vertical Binning read mode only. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - - Inputs: - active - Crop mode active: - 1 - Crop mode is ON. - Crop - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - The selected vertical binning. - hbin - The selected horizontal binning. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_NOT_SUPPORTED - Either the camera does not support isolated Crop mode or the read mode is invalid - - C++ Equiv: - unsigned int SetIsolatedCropMode(int active, int cropheight, int cropwidth, int vbin, int hbin); - - See Also: - GetDetector SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ret = self.dll.SetIsolatedCropMode(cactive, ccropheight, ccropwidth, cvbin, chbin) - return (ret) - - def SetIsolatedCropModeEx(self, active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. This feature is currently only available for iXon Ultra and can only be used in Image readout mode with the EM output amplifier. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - The following centralized regions of interest are recommended to be used with this mode to achieve the fastest possible frame rates. The table below shows the optimally positioned ROI coordinates recommended to be used with this mode: - ROI - Crop Left Start Position - Crop Right Position - Crop Bottom Start Position - Crop Top Position - 32 x 32 - 241 - 272 - 240 - 271 - 64 x 64 - 219 - 282 - 224 - 287 - 96 x 96 - 209 - 304 - 208 - 303 - 128 x 128 - 189 - 316 - 192 - 319 - 192 x 192 - 157 - 348 - 160 - 351 - 256 x 256 - 123 - 378 - 128 - 383 - 496 x 4 - 8 - 503 - 254 - 257 - 496 x 8 - 8 - 503 - 252 - 259 - 496 x 16 - 8 - 503 - 249 - 262 - - Synopsis: - ret = SetIsolatedCropModeEx(active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom) - - Inputs: - active - Crop mode active.: - 1 - Crop mode is ON. - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - vbinThe selected vertical binning. - hbin - hbinThe selected horizontal binning. - cropleft - The selected crop left start position - cropbottom - The selected crop bottom start position - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_P6INVALID - Invalid crop left start position - DRV_P7INVALID - Invalid crop bottom start position - DRV_NOT_SUPPORTED - The camera does not support isolated crop mode - DRV_NOT_AVAILABLE - Invalid read mode - - C++ Equiv: - unsigned int SetIsolatedCropModeEx(int active, int cropheight, int cropwidth, int vbin, int hbin, int cropleft, int cropbottom); - - See Also: - GetDetector SetReadMode - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ccropleft = c_int(cropleft) - ccropbottom = c_int(cropbottom) - ret = self.dll.SetIsolatedCropModeEx(cactive, ccropheight, ccropwidth, cvbin, chbin, ccropleft, ccropbottom) - return (ret) - - def SetKineticCycleTime(self, time): - ''' - Description: - This function will set the kinetic cycle time to the nearest valid value not less than the given value. The actual time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. . Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetKineticCycleTime(time) - - Inputs: - time - the kinetic cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Time invalid. - - C++ Equiv: - unsigned int SetKineticCycleTime(float time); - - See Also: - SetNumberKinetics - - ''' - ctime = c_float(time) - ret = self.dll.SetKineticCycleTime(ctime) - return (ret) - - def SetMCPGain(self, gain): - ''' - Description: - Allows the user to control the voltage across the microchannel plate. Increasing the gain increases the voltage and so amplifies the signal. The gain range can be returned using GetMCPGainRange. - - Synopsis: - ret = SetMCPGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with device. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetMCPGain(int gain); - - See Also: - GetMCPGainRange SetGateMode SetMCPGating - - Note: Available on iStar. - - ''' - cgain = c_int(gain) - ret = self.dll.SetMCPGain(cgain) - return (ret) - - def SetMCPGating(self, gating): - ''' - Description: - This function controls the MCP gating. - - Synopsis: - ret = SetMCPGating(gating) - - Inputs: - gating - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gating accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Value for gating invalid. - - C++ Equiv: - unsigned int SetMCPGating(int gating); - - See Also: - SetMCPGain SetGateMode - - Note: Available on some ICCD models. - - ''' - cgating = c_int(gating) - ret = self.dll.SetMCPGating(cgating) - return (ret) - - def SetMessageWindow(self, wnd): - ''' - Description: - This function is reserved. - - Synopsis: - ret = SetMessageWindow(wnd) - - Inputs: - wnd - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMessageWindow(at_32 wnd); - - ''' - cwnd = c_int(wnd) - ret = self.dll.SetMessageWindow(cwnd) - return (ret) - - def SetMetaData(self, state): - ''' - Description: - This function activates the meta data option. - - Synopsis: - ret = SetMetaData(state) - - Inputs: - state - ON/OFF switch for the meta data option.: - 0 - to switch meta data OFF. - 1 - to switch meta data ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Meta data option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid state. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetMetaData(int state); - - See Also: - GetMetaDataInfo - - ''' - cstate = c_int(state) - ret = self.dll.SetMetaData(cstate) - return (ret) - - def SetMultiTrack(self, number, height, offset): - ''' - Description: - This function will set the multi-Track parameters. The tracks are automatically spread evenly over the detector. Validation of the parameters is carried out in the following order: - * Number of tracks, - * Track height - * Offset. - The first pixels row of the first track is returned via bottom. - The number of rows between each track is returned via gap. - - Synopsis: - (ret, bottom, gap) = SetMultiTrack(number, height, offset) - - Inputs: - number - number tracks (1 to number of vertical pixels) - height - height of each track (>0 (maximum depends on number of tracks)) - offset - vertical displacement of tracks. (depends on number of tracks and track height) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track height invalid. - DRV_P3INVALID - Offset invalid. - bottom - first pixels row of the first track - gap - number of rows between each track (could be 0) - - C++ Equiv: - unsigned int SetMultiTrack(int number, int height, int offset, int * bottom, int * gap); - - See Also: - SetReadMode StartAcquisition SetRandomTracks - - ''' - cnumber = c_int(number) - cheight = c_int(height) - coffset = c_int(offset) - cbottom = c_int() - cgap = c_int() - ret = self.dll.SetMultiTrack(cnumber, cheight, coffset, byref(cbottom), byref(cgap)) - return (ret, cbottom.value, cgap.value) - - def SetMultiTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Multi-Track read mode. - - Synopsis: - ret = SetMultiTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetMultiTrackHBin(int bin); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - Note: 1) If the multitrack range is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetMultiTrackHBin(cbin) - return (ret) - - def SetMultiTrackHRange(self, iStart, iEnd): - ''' - Description: - This function sets the horizontal range used when acquiring in Multi Track read mode. - - Synopsis: - ret = SetMultiTrackHRange(iStart, iEnd) - - Inputs: - iStart - First horizontal pixel in multi track mode. - iEnd - iEndLast horizontal pixel in multi track mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Range set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available for this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid start position. - DRV_P2INVALID - Invalid end position. - - C++ Equiv: - unsigned int SetMultiTrackHRange(int iStart, int iEnd); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - ''' - ciStart = c_int(iStart) - ciEnd = c_int(iEnd) - ret = self.dll.SetMultiTrackHRange(ciStart, ciEnd) - return (ret) - - def SetMultiTrackScan(self, trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetMultiTrackScan(trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames) - - Inputs: - trackHeight - - numberTracks - - iSIHStart - - iSIHEnd - - trackHBinning - - trackVBinning - - trackGap - - trackOffset - - trackSkip - - numberSubFrames - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMultiTrackScan(int trackHeight, int numberTracks, int iSIHStart, int iSIHEnd, int trackHBinning, int trackVBinning, int trackGap, int trackOffset, int trackSkip, int numberSubFrames); - - ''' - ctrackHeight = c_int(trackHeight) - cnumberTracks = c_int(numberTracks) - ciSIHStart = c_int(iSIHStart) - ciSIHEnd = c_int(iSIHEnd) - ctrackHBinning = c_int(trackHBinning) - ctrackVBinning = c_int(trackVBinning) - ctrackGap = c_int(trackGap) - ctrackOffset = c_int(trackOffset) - ctrackSkip = c_int(trackSkip) - cnumberSubFrames = c_int(numberSubFrames) - ret = self.dll.SetMultiTrackScan(ctrackHeight, cnumberTracks, ciSIHStart, ciSIHEnd, ctrackHBinning, ctrackVBinning, ctrackGap, ctrackOffset, ctrackSkip, cnumberSubFrames) - return (ret) - - def SetNextAddress(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNextAddress16(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress16(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress16(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress16(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNumberAccumulations(self, number): - ''' - Description: - This function will set the number of scans accumulated in memory. This will only take effect if the acquisition mode is either Accumulate or Kinetic Series. - - Synopsis: - ret = SetNumberAccumulations(number) - - Inputs: - number - number of scans to accumulate - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Accumulations set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of accumulates. - - C++ Equiv: - unsigned int SetNumberAccumulations(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberKinetics - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberAccumulations(cnumber) - return (ret) - - def SetNumberKinetics(self, number): - ''' - Description: - This function will set the number of scans (possibly accumulated scans) to be taken during a single acquisition sequence. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberKinetics(number) - - Inputs: - number - number of scans to store - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number in series invalid. - - C++ Equiv: - unsigned int SetNumberKinetics(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberKinetics(cnumber) - return (ret) - - def SetNumberPrescans(self, iNumber): - ''' - Description: - This function will set the number of scans acquired before data is to be retrieved. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberPrescans(iNumber) - - Inputs: - iNumber - number of scans to ignore - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Prescans set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of prescans invalid. - - C++ Equiv: - unsigned int SetNumberPrescans(int iNumber); - - See Also: - GetAcquisitionTimings SetAcquisitionMode SetKineticCycleTime SetNumberKinetics - - ''' - ciNumber = c_int(iNumber) - ret = self.dll.SetNumberPrescans(ciNumber) - return (ret) - - def SetOutputAmplifier(self, typ): - ''' - Description: - Some EMCCD systems have the capability to use a second output amplifier. This function will set the type of output amplifier to be used when reading data from the head for these systems. - - Synopsis: - ret = SetOutputAmplifier(typ) - - Inputs: - typ - the type of output amplifier.: - 0 - Standard EMCCD gain register (default)/Conventional(clara). - 1 - Conventional CCD register/Extended NIR mode(clara). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Output amplifier type invalid. - - C++ Equiv: - unsigned int SetOutputAmplifier(int typ); - - Note: 1. Available in Clara, iXon & Newton. - 2. If the current camera HSSpeed is not available when the amplifier is set then it will default to the maximum HSSpeed that is. - - - ''' - ctyp = c_int(typ) - ret = self.dll.SetOutputAmplifier(ctyp) - return (ret) - - def SetOverlapMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Overlap Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetOverlapMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Overlap mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetOverlapMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is an Overlap sensor. - - ''' - cmode = c_int(mode) - ret = self.dll.SetOverlapMode(cmode) - return (ret) - - def SetPCIMode(self, mode, value): - ''' - Description: - With the CCI23 card, events can be sent when the camera is starting to expose and when it has finished exposing. This function will control whether those events happen or not. - - Synopsis: - ret = SetPCIMode(mode, value) - - Inputs: - mode - currently must be set to 1 - value - 0 to disable the events, 1 to enable - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid - - C++ Equiv: - unsigned int SetPCIMode(int mode, int value); - - See Also: - SetAcqStatusEvent SetCameraStatusEnable - - Note: This is only supported by the CCI23 card. The software must register its event via the SetAcqStatusEvent. To specify which event the software is interested in use the SetCameraStatusEnable. - - ''' - cmode = c_int(mode) - cvalue = c_int(value) - ret = self.dll.SetPCIMode(cmode, cvalue) - return (ret) - - def SetPhosphorEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the phosphor has saturated or returned to a normal state. To determine what event has actually occurred call the GetPhosphorStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetPhosphorEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetPhosphorEvent(at_32 driverEvent); - - See Also: - GetPhosphorStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetPhosphorEvent(cdriverEvent) - return (ret) - - def SetPhotonCounting(self, state): - ''' - Description: - This function activates the photon counting option. - - Synopsis: - ret = SetPhotonCounting(state) - - Inputs: - state - ON/OFF switch for the photon counting option.: - 0 - to switch photon counting OFF. - 1 - to switch photon counting ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - photon counting option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCounting(int state); - - See Also: - SetPhotonCountingThreshold - - ''' - cstate = c_int(state) - ret = self.dll.SetPhotonCounting(cstate) - return (ret) - - def SetPhotonCountingDivisions(self, noOfDivisions): - ''' - Description: - This function sets the thresholds for the photon counting option. - - Synopsis: - (ret, divisions) = SetPhotonCountingDivisions(noOfDivisions) - - Inputs: - noOfDivisions - number of thresholds to be used. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Number of thresholds outside valid range - DRV_P2INVALID - Thresholds outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Feature not supported. - divisions - threshold levels. - - C++ Equiv: - unsigned int SetPhotonCountingDivisions(at_u32 noOfDivisions, at_32 * divisions); - - See Also: - SetPhotonCounting GetNumberPhotonCountingDivisions - - ''' - cnoOfDivisions = c_uint(noOfDivisions) - cdivisions = c_int() - ret = self.dll.SetPhotonCountingDivisions(cnoOfDivisions, byref(cdivisions)) - return (ret, cdivisions.value) - - def SetPhotonCountingThreshold(self, min, max): - ''' - Description: - This function sets the minimum and maximum threshold for the photon counting option. - - Synopsis: - ret = SetPhotonCountingThreshold(min, max) - - Inputs: - min - minimum threshold in counts for photon counting. - max - maximum threshold in counts for photon counting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Minimum threshold outside valid range (1-65535) - DRV_P2INVALID - Maximum threshold outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCountingThreshold(long min, long max); - - See Also: - SetPhotonCounting - - ''' - cmin = c_int(min) - cmax = c_int(max) - ret = self.dll.SetPhotonCountingThreshold(cmin, cmax) - return (ret) - - def SetPixelMode(self, bitdepth, colormode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetPixelMode(bitdepth, colormode) - - Inputs: - bitdepth - - colormode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetPixelMode(int bitdepth, int colormode); - - ''' - cbitdepth = c_int(bitdepth) - ccolormode = c_int(colormode) - ret = self.dll.SetPixelMode(cbitdepth, ccolormode) - return (ret) - - def SetPreAmpGain(self, index): - ''' - Description: - This function will set the pre amp gain to be used for subsequent acquisitions. The actual gain factor that will be applied can be found through a call to the GetPreAmpGain function. - The number of Pre Amp Gains available is found by calling the GetNumberPreAmpGains function. - - Synopsis: - ret = SetPreAmpGain(index) - - Inputs: - index - index pre amp gain table: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pre amp gain set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetPreAmpGain(int index); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains GetPreAmpGain - - Note: Available on iDus, iXon & Newton. - - ''' - cindex = c_int(index) - ret = self.dll.SetPreAmpGain(cindex) - return (ret) - - def SetRandomTracks(self, numTracks): - ''' - Description: - This function will set the Random-Track parameters. The positions of the tracks are validated to ensure that the tracks are in increasing order and do not overlap. The horizontal binning is set via the SetCustomTrackHBin function. The vertical binning is set to the height of each track. - Some cameras need to have at least 1 row in between specified tracks. Ixon+ and the USB cameras allow tracks with no gaps in between. - Example: - Tracks specified as 20 30 31 40 tells the SDK that the first track starts at row 20 in the CCD and finishes at row 30. The next track starts at row 31 (no gap between tracks) and ends at row 40. - - Synopsis: - (ret, areas) = SetRandomTracks(numTracks) - - Inputs: - numTracks - number tracks: - 1 - to number of vertical pixels/2 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_RANDOM_TRACK_ERROR - Invalid combination of tracks, out of memory or mode not available. - areas - pointer to an array of track positions. The array has the form: - bottom1 - bottom1 top1, bottom2, top2 ... bottomN, topN - - C++ Equiv: - unsigned int SetRandomTracks(int numTracks, int * areas); - - See Also: - SetCustomTrackHBin SetReadMode StartAcquisition SetComplexImage - - ''' - cnumTracks = c_int(numTracks) - careas = c_int() - ret = self.dll.SetRandomTracks(cnumTracks, byref(careas)) - return (ret, careas.value) - - def SetReadMode(self, mode): - ''' - Description: - This function will set the readout mode to be used on the subsequent acquisitions. - - Synopsis: - ret = SetReadMode(mode) - - Inputs: - mode - readout mode: - 0 - Full Vertical Binning - 1 - Multi-Track - 2 - Random-Track - 3 - Single-Track - 4 - Image - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadMode(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadMode(cmode) - return (ret) - - def SetReadoutRegisterPacking(self, mode): - ''' - Description: - This function will configure whether data is packed into the readout register to improve frame rates for sub-images. - Note: It is important to ensure that no light falls outside of the sub-image area otherwise the acquired data will be corrupted. Only currently available on iXon+ and iXon3. - - Synopsis: - ret = SetReadoutRegisterPacking(mode) - - Inputs: - mode - register readout mode: - 0 - Packing Off - 1 - Packing On - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadoutRegisterPacking(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadoutRegisterPacking(cmode) - return (ret) - - def SetRegisterDump(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetRegisterDump(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetRegisterDump(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetRegisterDump(cmode) - return (ret) - - def SetRingExposureTimes(self, numTimes): - ''' - Description: - This function will send up an array of exposure times to the camera if the hardware supports the feature. See GetCapabilities. Each acquisition will then use the next exposure in the ring looping round to the start again when the end is reached. There can be a maximum of 16 exposures. - - Synopsis: - (ret, times) = SetRingExposureTimes(numTimes) - - Inputs: - numTimes - The number of exposures - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_NOTAVAILABLE - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - This mode is not available. - DRV_P1INVALID - Must be between 1 and 16 exposures inclusive - DRV_P2INVALID - The exposures times are invalid. - times - A predeclared pointer to an array of numTimes floats - - C++ Equiv: - unsigned int SetRingExposureTimes(int numTimes, float * times); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable - - ''' - cnumTimes = c_int(numTimes) - ctimes = c_float() - ret = self.dll.SetRingExposureTimes(cnumTimes, byref(ctimes)) - return (ret, ctimes.value) - - def SetSaturationEvent(self, saturationEvent): - ''' - Description: - This is only supported with the CCI-23 PCI card. USB cameras do not have this feature. - This function passes a Win32 Event handle to the driver via which the driver can inform the main software that an acquisition has saturated the sensor to a potentially damaging level. You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetEvent with NULL as the parameter. - - Synopsis: - ret = SetSaturationEvent(saturationEvent) - - Inputs: - saturationEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetSaturationEvent(HANDLE saturationEvent); - - See Also: - SetDriverEvent - - Note: The programmer must reset the event after it has been handled in order to receive additional triggers, unless the event has been created with auto-reset, e.g. event = CreateEvent(NULL, FALSE, FALSE, NULL). Also, NOT all programming environments allow the use of multiple threads and Win32 events. - Only supported with the CCI-23 card. - USB cameras do not have this feature. - - - - ''' - csaturationEvent = c_void_p(saturationEvent) - ret = self.dll.SetSaturationEvent(csaturationEvent) - return (ret) - - def SetShutter(self, typ, mode, closingtime, openingtime): - ''' - Description: - This function controls the behaviour of the shutter. - The typ parameter allows the user to control the TTL signal output to an external shutter. The mode parameter configures whether the shutter opens & closes automatically (controlled by the camera) or is permanently open or permanently closed. - The opening and closing time specify the time required to open and close the shutter (this information is required for calculating acquisition timings (see SHUTTER TRANSFER TIME). - - Synopsis: - ret = SetShutter(typ, mode, closingtime, openingtime) - - Inputs: - typ - shutter type: - 1 - Output TTL high signal to open shutter - 0 - Output TTL low signal to open shutter - mode - Shutter mode: - 0 - Automatic - 1 - Open - 2 - Close - closingtime - Time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_ERROR_ACK - Acquisition in progress. - DRV_NOT_SUPPORTED - Unable to communicate with card. - DRV_P1INVALID - Camera does not support shutter control. - DRV_P2INVALID - Invalid TTL type. - DRV_P3INVALID - Invalid mode. - DRV_P4INVALID - Invalid time to open. - - C++ Equiv: - unsigned int SetShutter(int typ, int mode, int closingtime, int openingtime); - - See Also: - SetShutterEx - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - ret = self.dll.SetShutter(ctyp, cmode, cclosingtime, copeningtime) - return (ret) - - def SetShutterEx(self, typ, mode, closingtime, openingtime, extmode): - ''' - Description: - This function expands the control offered by SetShutter to allow an external shutter and internal shutter to be controlled independently (only available on some cameras - please consult your Camera User Guide). The typ parameter allows the user to control the TTL signal output to an external shutter. The opening and closing times specify the length of time required to open and close the shutter (this information is required for calculating acquisition timings - see SHUTTER TRANSFER TIME). - The mode and extmode parameters control the behaviour of the internal and external shutters. To have an external shutter open and close automatically in an experiment, set the mode parameter to Open and set the extmode parameter to Auto. To have an internal shutter open and close automatically in an experiment, set the extmode parameter to Open and set the mode parameter to Auto. - To not use any shutter in the experiment, set both shutter modes to permanently open. - - Synopsis: - ret = SetShutterEx(typ, mode, closingtime, openingtime, extmode) - - Inputs: - typ - Shutter type: - 0 - Output TTL low signal to open shutter - 1 - Output TTL high signal to open shutter - mode - Internal shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - closingtime - time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - extmode - External shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_P5INVALID - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support shutter control. - DRV_P1INVALID - Invalid TTL type. - DRV_P2INVALID - Invalid internal mode - DRV_P3INVALID - Invalid time to open. - DRV_P4INVALID - Invalid time to close - - C++ Equiv: - unsigned int SetShutterEx(int typ, int mode, int closingtime, int openingtime, int extmode); - - See Also: - SetShutter - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cextmode = c_int(extmode) - ret = self.dll.SetShutterEx(ctyp, cmode, cclosingtime, copeningtime, cextmode) - return (ret) - - def SetShutters(self, typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetShutters(typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2) - - Inputs: - typ - - mode - - closingtime - - openingtime - - exttype - - extmode - - dummy1 - - dummy2 - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetShutters(int typ, int mode, int closingtime, int openingtime, int exttype, int extmode, int dummy1, int dummy2); - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cexttype = c_int(exttype) - cextmode = c_int(extmode) - cdummy1 = c_int(dummy1) - cdummy2 = c_int(dummy2) - ret = self.dll.SetShutters(ctyp, cmode, cclosingtime, copeningtime, cexttype, cextmode, cdummy1, cdummy2) - return (ret) - - def SetSifComment(self, comment): - ''' - Description: - This function will set the user text that will be added to any sif files created with the SaveAsSif function. The stored comment can be cleared by passing NULL or an empty text string. - - Synopsis: - ret = SetSifComment(comment) - - Inputs: - comment - The comment to add to new sif files. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sif comment set. - - C++ Equiv: - unsigned int SetSifComment(char * comment); - - See Also: - SaveAsSif SaveAsCommentedSif SaveAsSif SetReadMode - - Note: To add a comment to a SIF file that will not be used in any future SIF files that are saved, use the function SaveAsCommentedSif. - - ''' - ccomment = comment - ret = self.dll.SetSifComment(ccomment) - return (ret) - - def SetSingleTrack(self, centre, height): - ''' - Description: - This function will set the single track parameters. The parameters are validated in the following order: centre row and then track height. - - Synopsis: - ret = SetSingleTrack(centre, height) - - Inputs: - centre - centre row of track: - Valid - range 0 to number of vertical pixels. - height - height of track: - Valid - range > 1 (maximum value depends on centre row and number of vertical pixels). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Center row invalid. - DRV_P2INVALID - Track height invalid. - - C++ Equiv: - unsigned int SetSingleTrack(int centre, int height); - - See Also: - SetReadMode - - ''' - ccentre = c_int(centre) - cheight = c_int(height) - ret = self.dll.SetSingleTrack(ccentre, cheight) - return (ret) - - def SetSingleTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Single Track read mode. - - Synopsis: - ret = SetSingleTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetSingleTrackHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetSingleTrackHBin(cbin) - return (ret) - - def SetSpool(self, active, method, path, framebuffersize): - ''' - Description: - This function will enable and disable the spooling of acquired data to the hard disk or to the RAM. - With spooling method 0, each scan in the series will be saved to a separate file composed of a sequence of 32-bit integers. - With spooling method 1 the type of data in the output files depends on what type of acquisition is taking place (see below). - Spooling method 2 writes out the data to file as 16-bit integers. - Spooling method 3 creates a directory structure for storing images where multiple images may appear in each file within the directory structure and the files may be spread across multiple directories. Like method 1 the data type of the image pixels depends on whether accumulate mode is being used. - Method 4 Creates a RAM disk for storing images so you should ensure that there is enough free RAM to store the full acquisition. - Methods 5, 6 and 7 can be used to directly spool out to a particular file type, either FITS, SIF or TIFF respectively. In the case of FITS and TIFF the data will be written out as 16-bit values. - Method 8 is similar to method 3, however the data is first compressed before writing to disk. In some circumstances this may improve the maximum rate of writing images to disk, however as the compression can be very CPU intensive this option may not be suitable on slower processors. - The data is stored in row order starting with the row nearest the readout register. With the exception of methods 5, 6 and 7, the data acquired during a spooled acquisition can be retrieved through the normal functions. This is a change to previous versions; it is no longer necessary to load the data from disk from your own application. - - Synopsis: - ret = SetSpool(active, method, path, framebuffersize) - - Inputs: - active - Enable/disable spooling: - 0 - Disable spooling. - 1 - Enable spooling. - method - Indicates the format of the files written to disk: - 0 - Files contain sequence of 32-bit integers - 1 - Format of data in files depends on whether multiple accumulations are being taken for each scan. Format will be 32-bit integer if data is being accumulated each scan; otherwise the format will be 16-bit integer. - 2 - Files contain sequence of 16-bit integers. - 3 - Multiple directory structure with multiple images per file and multiple files per directory. - 4 - Spool to RAM disk. - 5 - Spool to 16-bit Fits File. - 6 - Spool to Andor Sif format. - 7 - Spool to 16-bit Tiff File. - 8 - Similar to method 3 but with data compression. - path - String containing the filename stem. May also contain the path to the directory into which the files are to be stored. - framebuffersize - This sets the size of an internal circular buffer used as temporary storage. The value is the total number images the buffer can hold, not the size in bytes. Typical value would be 10. This value would be increased in situations where the computer is not able to spool the data to disk at the required rate. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - - C++ Equiv: - unsigned int SetSpool(int active, int method, char * path, int framebuffersize); - - See Also: - GetSpoolProgress - - Note: Spooled images will not be post processed, i.e. flipped or rotated. - - ''' - cactive = c_int(active) - cmethod = c_int(method) - cpath = path - cframebuffersize = c_int(framebuffersize) - ret = self.dll.SetSpool(cactive, cmethod, cpath, cframebuffersize) - return (ret) - - def SetSpoolThreadCount(self, count): - ''' - Description: - This function sets the number of parallel threads used for writing data to disk when spooling is enabled. Increasing this to a value greater than the default of 1, can sometimes improve the data rate to the hard disk particularly with Solid State hard disks. In other cases increasing this value may actually reduce the rate at which data is written to disk. - - Synopsis: - ret = SetSpoolThreadCount(count) - - Inputs: - count - The number of threads to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread count is set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid thread count. - - C++ Equiv: - unsigned int SetSpoolThreadCount(int count); - - See Also: - SetSpool - - Note: This feature is currently only available when using the Neo camera. - - ''' - ccount = c_int(count) - ret = self.dll.SetSpoolThreadCount(ccount) - return (ret) - - def SetStorageMode(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetStorageMode(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetStorageMode(long mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetStorageMode(cmode) - return (ret) - - def SetTECEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the TEC has overheated or returned to a normal state. To determine what event has actually occurred call the GetTECStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetTECEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetTECEvent(HANDLE driverEvent); - - See Also: - GetTECStatus - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetTECEvent(cdriverEvent) - return (ret) - - def SetTemperature(self, temperature): - ''' - Description: - This function will set the desired temperature of the detector. To turn the cooling ON and OFF use the CoolerONCoolerON and CoolerOFFCoolerOFF function respectively. - - Synopsis: - ret = SetTemperature(temperature) - - Inputs: - temperature - the temperature in Centigrade.: - Valid - range is given by GetTemperatureRangeGetTemperatureRange - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Temperature invalid. - DRV_NOT_SUPPORTED - The camera does not support setting the temperature. - - C++ Equiv: - unsigned int SetTemperature(int temperature); - - See Also: - CoolerOFF CoolerON GetTemperature GetTemperatureF GetTemperatureRange - - Note: Not available on Luca R cameras - automatically cooled to -20C. - - ''' - ctemperature = c_int(temperature) - ret = self.dll.SetTemperature(ctemperature) - return (ret) - - def SetTemperatureEvent(self, temperatureEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetTemperatureEvent(temperatureEvent) - - Inputs: - temperatureEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetTemperatureEvent(at_32 temperatureEvent); - - ''' - ctemperatureEvent = c_int(temperatureEvent) - ret = self.dll.SetTemperatureEvent(ctemperatureEvent) - return (ret) - - def SetTriggerInvert(self, mode): - ''' - Description: - This function will set whether an acquisition will be triggered on a rising or falling edge external trigger. - - Synopsis: - ret = SetTriggerInvert(mode) - - Inputs: - mode - trigger mode: - 0 - Rising Edge - 1 - Falling Edge - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetTriggerInvert(int mode); - - See Also: - Trigger Modes SetTriggerMode SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerInvert(cmode) - return (ret) - - def SetTriggerLevel(self, f_level): - ''' - Description: - This function sets the trigger voltage which the system will use. - - Synopsis: - ret = SetTriggerLevel(f_level) - - Inputs: - f_level - trigger voltage - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetTriggerLevel(float f_level); - - See Also: - GetCapabilities GetTriggerLevelRange - - ''' - cf_level = c_float(f_level) - ret = self.dll.SetTriggerLevel(cf_level) - return (ret) - - def SetTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode that the camera will operate in. - - Synopsis: - ret = SetTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - 6 - External Start - 7 - External Exposure (Bulb) - 9 - External FVB EM (only valid for EM Newton models in FVB mode) 10. Software Trigger - 12 - External Charge Shifting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetTriggerMode(int mode); - - See Also: - Trigger Modes SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerMode(cmode) - return (ret) - - def SetUserEvent(self, userEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUserEvent(userEvent) - - Inputs: - userEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUserEvent(at_32 userEvent); - - ''' - cuserEvent = c_int(userEvent) - ret = self.dll.SetUserEvent(cuserEvent) - return (ret) - - def SetUSGenomics(self, width, height): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUSGenomics(width, height) - - Inputs: - width - - height - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUSGenomics(long width, long height); - - ''' - cwidth = c_int(width) - cheight = c_int(height) - ret = self.dll.SetUSGenomics(cwidth, cheight) - return (ret) - - def SetVerticalRowBuffer(self, rows): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVerticalRowBuffer(rows) - - Inputs: - rows - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVerticalRowBuffer(int rows); - - ''' - crows = c_int(rows) - ret = self.dll.SetVerticalRowBuffer(crows) - return (ret) - - def SetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVerticalSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVerticalSpeed(int index); // deprecated - - See Also: - GetNumberVerticalSpeeds GetVerticalSpeed - - Note: Deprecated by SetVSSpeedSetVSSpeed. - - ''' - cindex = c_int(index) - ret = self.dll.SetVerticalSpeed(cindex) - return (ret) - - def SetVirtualChip(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVirtualChip(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVirtualChip(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetVirtualChip(cstate) - return (ret) - - def SetVSAmplitude(self, index): - ''' - Description: - If you choose a high readout speed (a low readout time), then you should also consider increasing the amplitude of the Vertical Clock Voltage. - There are five levels of amplitude available for you to choose from: - * Normal - * +1 - * +2 - * +3 - * +4 - Exercise caution when increasing the amplitude of the vertical clock voltage, since higher clocking voltages may result in increased clock-induced charge (noise) in your signal. In general, only the very highest vertical clocking speeds are likely to benefit from an increased vertical clock voltage amplitude. - - Synopsis: - ret = SetVSAmplitude(index) - - Inputs: - index - desired Vertical Clock Voltage Amplitude: - 0 - Normal - 1 ->4 - Increasing Clock voltage Amplitude - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplitude set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Your system does not support this feature - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid amplitude parameter. - - C++ Equiv: - unsigned int SetVSAmplitude(int index); - - Note: Available in iXon, iKon and Newton - full range of amplitude levels is not available on all compatible cameras. - - ''' - cindex = c_int(index) - ret = self.dll.SetVSAmplitude(cindex) - return (ret) - - def SetVSSpeed(self, index): - ''' - Description: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVSSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVSSpeed(int index); - - See Also: - GetNumberVSSpeeds GetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - ret = self.dll.SetVSSpeed(cindex) - return (ret) - - def ShutDown(self): - ''' - Description: - This function will close the AndorMCD system down. - - Synopsis: - ret = ShutDown() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System shut down. - - C++ Equiv: - unsigned int ShutDown(void); - - See Also: - CoolerOFF CoolerON SetTemperature GetTemperature - - Note: 1. For Classic & ICCD systems, the temperature of the detector should be above -20C before shutting down the system. - 2. When dynamically loading a DLL which is statically linked to the SDK library, ShutDown MUST be called before unloading. - - ''' - ret = self.dll.ShutDown() - return (ret) - - def StartAcquisition(self): - ''' - Description: - This function starts an acquisition. The status of the acquisition can be monitored via GetStatus(). - - Synopsis: - ret = StartAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition started. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int StartAcquisition(void); - - See Also: - GetStatus GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - ret = self.dll.StartAcquisition() - return (ret) - - def UnMapPhysicalAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = UnMapPhysicalAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int UnMapPhysicalAddress(void); - - ''' - ret = self.dll.UnMapPhysicalAddress() - return (ret) - - def WaitForAcquisition(self): - ''' - Description: - WaitForAcquisition can be called after an acquisition is started using StartAcquisitionStartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. - Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWaitCancelWait. - An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - If a second event occurs before the first one has been acknowledged, the first one will be ignored. Care should be taken in this case, as you may have to use CancelWaitCancelWait to exit the function. - - Synopsis: - ret = WaitForAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred - DRV_NOT_INITIALIZED - System not initialized. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(e.g. CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisition(void); - - See Also: - StartAcquisition CancelWait - - ''' - ret = self.dll.WaitForAcquisition() - return (ret) - - def WaitForAcquisitionByHandle(self, cameraHandle): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - - Synopsis: - ret = WaitForAcquisitionByHandle(cameraHandle) - - Inputs: - cameraHandle - handle of camera to put into wait state. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandle(long cameraHandle); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionTimeOut WaitForAcquisitionByHandleTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.WaitForAcquisitionByHandle(ccameraHandle) - return (ret) - - def WaitForAcquisitionByHandleTimeOut(self, cameraHandle, iTimeOutMs): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionByHandleTimeOut(cameraHandle, iTimeOutMs) - - Inputs: - cameraHandle - handle of camera to put into wait state. - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandleTimeOut(long cameraHandle, int iTimeOutMs); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionByHandleTimeOut(ccameraHandle, ciTimeOutMs) - return (ret) - - def WaitForAcquisitionTimeOut(self, iTimeOutMs): - ''' - Description: - WaitForAcquisitionTimeOut can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - Inputs: - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionTimeOut(int iTimeOutMs); - - See Also: - CancelWait StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionByHandleTimeOut - - ''' - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionTimeOut(ciTimeOutMs) - return (ret) - - def WhiteBalance(self): - ''' - Description: - For colour sensors only - Calculates the red and blue relative to green factors to white balance a colour image using the parameters stored in info. - Before passing the address of an WhiteBalanceInfo structure to the function the iSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - nfo-> iSize = sizeof(WhiteBalanceInfo); - Below is the WhiteBalanceInfo structure definition and a description of its members: - struct WHITEBALANCEINFO { - int iSize; // Structure size. - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to used to calculate white balance. - int iROI_left; // Region Of interest from which white balance is calculated - int iROI_right; // Region Of interest from which white balance is calculated - int iROI_top; // Region Of interest from which white balance is calculated - int iROI_bottom; // Region Of interest from which white balance is calculated - WhiteBalanceInfo; - iX and iY are the image dimensions. The number of elements of the input, red, green and blue arrays are iX x iY. - iAlgorithm sets the algorithm to use. The function sums all the colour values per each colour field within the Region Of interest (ROI) and calculates the relative to green values as: 0) _fRelR = GreenSum / RedSum and _fRelB = GreenSum / BlueSum; 1) _fRelR = 2/3 GreenSum / RedSum and _fRelB = 2/3 GreenSum / BlueSum, giving more importance to the green field. - iROI_left, iROI_right, iROI_top and iROI_bottom define the ROI with the constraints: - iROI_left0 <= iROI_left < iROI_right <= iX and 0 <= iROI_ bottom < iROI_ top <= iX - - Synopsis: - (ret, wRed, wGreen, wBlue, fRelR, fRelB, info) = WhiteBalance() - - Inputs: - None - - Outputs: - ret - Function Return Code: - SUCCESS - White balance calculated. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Invalid pointer (i.e. NULL). - DRV_P6INVALID - One or more parameters in info is out of range - DRV_DIVIDE_BY_ZERO_ERROR - The sum of the green field within the ROI is zero. _fRelR and _fRelB are set to 1 - wRed - pointer to red field. - wGreen - pointer to green field. - wBlue - pointer to blue field. - fRelR - pointer to the relative to green red factor. - fRelB - pointer to the relative to green blue factor. - info - pointer to white balance information structure - - C++ Equiv: - unsigned int WhiteBalance(WORD * wRed, WORD * wGreen, WORD * wBlue, float * fRelR, float * fRelB, WhiteBalanceInfo * info); - - See Also: - DemosaicImage GetMostRecentColorImage16 - - ''' - cwRed = c_short() - cwGreen = c_short() - cwBlue = c_short() - cfRelR = c_float() - cfRelB = c_float() - cinfo = WhiteBalanceInfo() - ret = self.dll.WhiteBalance(byref(cwRed), byref(cwGreen), byref(cwBlue), byref(cfRelR), byref(cfRelB), byref(cinfo)) - return (ret, cwRed.value, cwGreen.value, cwBlue.value, cfRelR.value, cfRelB.value, cinfo) - diff --git a/Andor/andorv1/build/lib/andor/driver.py b/Andor/andorv1/build/lib/andor/driver.py deleted file mode 100644 index 4c571fb..0000000 --- a/Andor/andorv1/build/lib/andor/driver.py +++ /dev/null @@ -1,134 +0,0 @@ -from atmcd import * - -class andor(): - def __init__(self): - print("Intialising Camera") - self.cam = atmcd() #load the atmcd library - - (ret) = self.cam.Initialize("/usr/local/etc/andor") #initialise camera - print("Initialize returned",ret) - - if atmcd.DRV_SUCCESS==ret: - self.Initialize() - else: - print("Cannot continue, could not initialise camera") - - - - def Initialize(self): - - #(ret, totalCameras) = self.cam.GetAvailableCameras() - - (ret, iSerialNumber) = self.cam.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = self.cam.CoolerON() - print("Function CoolerON returned",ret) - #(ret) = self.cam.CoolerOFF() - #(ret, iCoolerStatus) = IsCoolerOn() - - - #(ret, temperature) = GetTemperature() - - #(ret, gain) = self.cam.SetEMCCDGain() - #(ret, low, high) = self.cam.GetEMGainRange() - - #(ret, noGains) = self.cam.GetNumberPreAmpGains() - #(ret, gain) = GetPreAmpGain(index) - #ret = SetPreAmpGain(index) - #ret = SetShutter(typ, mode, closingtime, openingtime) - - (ret) = self.cam.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - # Inputs: - # mode - the acquisition mode.: - # 1 - Single Scan - # 2 - Accumulate - # 3 - Kinetics - # 4 - Fast Kinetics - # 5 - Run till abort - - #ret = SetCameraLinkMode(mode) # 1 enables, 0 disables - - #ret = SetCropMode(active, cropHeight, reserved) - - #ret = SetFanMode(mode) - - # ret = SetCountConvertMode(Mode) - # Mode - : - # 0 - Data in Counts - # 1 - Data in Electrons - # 2 - Data in Photons - - #ret = SetHorizontalSpeed(index) - - - (ret) = self.cam.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = self.cam.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - #ret = SetFastExtTrigger(mode) - - (ret, xpixels, ypixels) = self.cam.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = self.cam.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - # Inputs: - # hbin - number of pixels to bin horizontally. - # vbin - number of pixels to bin vertically. - # hstart - Start column (inclusive). - # hend - End column (inclusive). - # vstart - Start row (inclusive). - # vend - End row (inclusive). - # ret = SetFullImage(hbin, vbin) - - #ret = SetImageRotate(iRotate) - #ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - #SetPhotonCounting(self, state): - - (ret) = self.cam.SetExposureTime(0.01) # seconds - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = self.cam.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - def PrepareAcquisition(self): - (ret) = self.cam.PrepareAcquisition() # reads current acquisition setup and allocates memory. Is called automatically by StartAcuiqision if not run, but can take a while. - print("Function PrepareAcquisition returned",ret) - - - def StartAcquisition(self): - #Run after PrepareAcquisition to start waiting for trigger. - (ret) = self.cam.StartAcquisition() - print("Function StartAcquisition returned",ret) - #GetStatus() - - def WaitForAcquisition(self): - - (ret) = self.cam.WaitForAcquisition() # calling thread is put to sleep until Acquisition Event occurs. - print("Function WaitForAcquisition returned",ret) - #ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - # def CancelWait(self): - # (ret) = self.cam.CancelWait() - # print("Cancel wait",ret) - - def GetImage(self): - - imageSize = xpixels*ypixels - (ret, fullFrameBuffer) = self.cam.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #(ret, arr, validfirst, validlast) = self.cam.GetImages(first, last, size) - #(ret, first, last) = self.cam.GetNumberNewImages() - #(ret, index) = GetTotalNumberImagesAcquired() - return fullFrameBuffer - - def ShutDown(self): - #Clean up - (ret) = self.cam.ShutDown() - print("Shutdown returned",ret) \ No newline at end of file diff --git a/Andor/andorv1/dist/andor-0.0.0-py3.7.egg b/Andor/andorv1/dist/andor-0.0.0-py3.7.egg deleted file mode 100644 index 5f3fd72..0000000 Binary files a/Andor/andorv1/dist/andor-0.0.0-py3.7.egg and /dev/null differ diff --git a/Andor/andorv1/doc/Makefile b/Andor/andorv1/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/Andor/andorv1/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/Andor/andorv1/doc/conf.py b/Andor/andorv1/doc/conf.py deleted file mode 100644 index f7c5161..0000000 --- a/Andor/andorv1/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'Andor' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'Novatech409Bdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'Novatech409B.tex', 'Novatech409B Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'novatech409', 'Novatech409B Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'Novatech409B', 'Novatech409B Documentation', - author, 'Novatech409B', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/Andor/andorv1/doc/index.rst b/Andor/andorv1/doc/index.rst deleted file mode 100644 index 8764c75..0000000 --- a/Andor/andorv1/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: novatech409b.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: novatech409b.aqctl_novatech409b.get_argparser - :prog: aqctl_novatech409b - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/Andor/andorv1/setup.py b/Andor/andorv1/setup.py deleted file mode 100644 index 84af854..0000000 --- a/Andor/andorv1/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="andor", - install_requires=[],#"sipyco", "asyncserial"], - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_andor = andor.aqctl_andor:main", - ], - }, -) diff --git a/Andor/andorv2/__init__.py b/Andor/andorv2/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv2/andor/SimplestScript.py b/Andor/andorv2/andor/SimplestScript.py deleted file mode 100644 index 7b126d3..0000000 --- a/Andor/andorv2/andor/SimplestScript.py +++ /dev/null @@ -1,53 +0,0 @@ - #!/usr/bin/env python - -### Section 1: Imports ### - - import sys, os - sys.path.append(r'C:/Users/hoodl/Documents/GitHub/Instruments/Andor/andorv2/andor') - from atmcd import * - import numpy as np - import matplotlib.pyplot as plt - import time - - cam = atmcd() #load the atmcd library - -### Section 2: Initializations and Settings ### - - cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK - cam.CoolerON() # Turns on TEC - cam.SetTemperature(-40) # TEC temp - cam.SetAcquisitionMode(1) # Single scan - cam.SetReadMode(4) # Image readmode - cam.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter - cam.SetExposureTime(.1) # 1 second - cam.SetTriggerMode(1) # External TTL trigger - (ret, xpixels, ypixels) = cam.GetDetector() # Returns detector properties - imagesize = xpixels*ypixels # Set image size - cam.SetImage(1, 1, 1, xpixels, 1, ypixels) # Sets ROI? - cam.StartAcquisition() # Starts acquisition cycling - -### Section 3: Acquisition, Processing, and Clean up ### - - # Begin acquisition - - print("Before WaitForAcquisition...") - cam.WaitForAcquisition() # Waits for trigger then takes image - print("Trigger received...") - - # Process and plot image - - (ret, fullFrameBuffer) = cam.GetMostRecentImage(imagesize) # Retrieves most recent image - image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array - plt.imshow(image) # Plots image - - #Clean up - - cam.CancelWait() # Cancels WaitForAcquisition - cam.AbortAcquisition() # Cancels StartAcquisition - cam.StartAcquisition() # Restarts StartAcquisition - cam.ShutDown() - - if ret == 20002: - print("Script ran correctly...") - else: - print("Script failed...") \ No newline at end of file diff --git a/Andor/andorv2/andor/SimplestScriptv2.py b/Andor/andorv2/andor/SimplestScriptv2.py deleted file mode 100644 index bede13d..0000000 --- a/Andor/andorv2/andor/SimplestScriptv2.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -### Section 1: Imports ### - -import sys, os -sys.path.append(r'C:/Users/hoodl/Documents/GitHub/Instruments/Andor/andorv2/andor') -from atmcd import * -import numpy as np -import matplotlib.pyplot as plt -import win32event - - -seriesLength = 30; - -cam = atmcd() - -error = cam.Initialize("/usr/local/etc/andor") -print("Init",error) -if (error == cam.DRV_SUCCESS): - (err, sensorWidth, sensorHeight) = cam.GetDetector() - cam.SetTriggerMode(1); - cam.SetFastExtTrigger(1); - cam.SetReadMode(4); - cam.SetExposureTime(1); - cam.SetAcquisitionMode(3); - cam.SetNumberKinetics(seriesLength); - cam.SetShutter(1, 1, 0, 0); - cam.SetVSSpeed(0); - # (error, speed) = cam.GetVSSpeed(); - # print("VSS = %g usecs\n", speed); - cam.SetHSSpeed(0, 0); # check if first input right - # cam.GetHSSpeed(0, 0, 0, speed); - # print("HSS = %g MHz\n", speed); - - cam.EnableKeepCleans(0); - cam.SetIsolatedCropMode(1, 30, 30, 1, 1); - - cam.SetImage(1, 1, 1, 30, 1, 30); - cam.PrepareAcquisition(); - cam.SetShutter(1, 1, 0, 0); - # GetAcquisitionTimings(float(exp), float(acc), float(kin)); - # print("Cycle time = %g\n", kin); - # Set up events - - print("pre") - event = 0#win32event.CreateEvent(None, False, False, None) - print(event) - - x = cam.SetDriverEvent(event) - - error = cam.StartAcquisition() - print("StartAcquisition returned", error); - -# if (error == cam.DRV_SUCCESS): -# WaitStatus = np.uint64(0); -# first, last = 0, validFirst, validLast; -# while (last < seriesLength): -# # auto start = high_resolution_clock::now(); -# WaitStatus = cam.WaitForSingleObject(event, float('inf')); -# if (WaitStatus == WAIT_FAILED): -# continue -# if (WaitStatus == WAIT_OBJECT_0): -# cam.GetNumberAvailableImages(first, last); -print(cam.GetNumberAvailableImages()) - - -(ret, xpixels, ypixels) = cam.GetDetector() # Returns detector properties -imagesize = xpixels*ypixels # Set image size -(ret, fullFrameBuffer) = cam.GetMostRecentImage(imagesize) # Retrieves most recent image -image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array -plt.imshow(image) # Plots image - -cam.SetShutter(1, 2, 0, 0); -# print("ShutDown() returned %d\n", ShutDown()); \ No newline at end of file diff --git a/Andor/andorv2/andor/SingleScan.py b/Andor/andorv2/andor/SingleScan.py deleted file mode 100644 index af5fd2b..0000000 --- a/Andor/andorv2/andor/SingleScan.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -import sys, os - -sys.path.append(r'C:/Users/hoodl/Documents/GitHub/Instruments/Andor/andorv2/andor') - -from atmcd import * -import numpy as np -import matplotlib.pyplot as plt -import time - - -print("Single Scan Example") - -print("Intialising Camera") -sdkObject = atmcd() #load the atmcd library -(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK -print("Initialize returned",ret) - - - -if atmcd.DRV_SUCCESS==ret: - - (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - # print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = sdkObject.CoolerON() - print("Function CoolerON returned",ret) - - (ret) = sdkObject.SetTemperature(-40) - print("Function CoolerON returned",ret) - - - (ret) = sdkObject.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - - (ret) = sdkObject.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = sdkObject.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter. (0,2,50,50) closes shutter. - - (ret) = sdkObject.SetExposureTime(1) - print("Function SetExposureTime returned",ret,"time = 0.5s") - - (ret) = sdkObject.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - (ret) = sdkObject.SetVSSpeed(3) - # print(sdkObject.GetAcquiredData(VSSpeed(0,0,0))) - - (ret, xpixels, ypixels) = sdkObject.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - - (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - (ret) = sdkObject.PrepareAcquisition() - print("Function PrepareAcquisition returned",ret) - - #Perform Acquisition - (ret) = sdkObject.StartAcquisition() - print("Function StartAcquisition returned",ret) - - (ret) = sdkObject.WaitForAcquisition() - print("Function WaitForAcquisition returned",ret) - - imageSize = xpixels*ypixels - (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #David's addition - image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array - print(np.sum(image),(np.max(image))) - plt.imshow(image) - - #Clean up - # (ret) = sdkObject.SetShutter(0,2,50,50) - (ret) = sdkObject.ShutDown() - # print("Shutdown returned",ret) - -# else: - # print("Cannot continue, could not initialise camera") - diff --git a/Andor/andorv2/andor/__init__.py b/Andor/andorv2/andor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Andor/andorv2/andor/andor_driver.py b/Andor/andorv2/andor/andor_driver.py deleted file mode 100644 index 6128f81..0000000 --- a/Andor/andorv2/andor/andor_driver.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python -from atmcd import * -import numpy as np -import matplotlib.pyplot as plt - - - -class ANDOR: - """Driver for ANDOR camera """ - def __init__(self): - self.cam = atmcd() #load the atmcd library - - - (ret) = self.cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK - (ret, iSerialNumber) = self.cam.GetCameraSerialNumber() - (ret) = self.cam.CoolerON() - - - (ret) = self.cam.SetTemperature(-40) #David added this - (ret) = self.cam.SetVSSpeed(3.3) #David added this - (ret) = self.cam.SetVSAmplitude(Normal) #David added this - (ret) = self.cam.SetPreAmpGain(3) #David added this - (ret) = self.cam.SetOutputAmplifier(0) # 0 is EMCCD. David added this - (ret) = self.cam.SetEMCCDGain(2) # Max is 300? David added this - #The only setting I have missed is the readout rate which I could not find. might be SetHSSpeed and SetHorizontalSpeed - - (ret) = self.cam.SetAcquisitionMode(1) - (ret) = self.cam.SetReadMode(4) - (ret) = self.cam.SetTriggerMode(0) # 0 is internal, 1 is external, 6 is external start? - (ret, self.xpixels, self.ypixels) = self.cam.GetDetector() - self.imageSize = self.xpixels*self.ypixels - (ret) = self.cam.SetImage(1, 1, 1, self.xpixels, 1, self.ypixels) - (ret) = self.cam.SetExposureTime(0.01) # Set exposure time here! - (ret, self.fminExposure, self.fAccumulate, self.fKinetic) = self.cam.GetAcquisitionTimings() - (ret) = self.cam.PrepareAcquisition() - (ret) = self.cam.StartAcquisition() - - if atmcd.DRV_SUCCESS==ret: - print("_init_() was successful...") - else: - print("_init_() failed...Try restarting Artiq and/or powercycling camera") - - - #Settings we still need: temperature(-40), shift speed (3.3), Vertical Clock Voltage Amplitude (Normal/+0), Readout Rate (17MHz at 16-bit) - # ,Pre-Amp Gain (Gain 3), Output Amplifier (Electron Multiplying), Electron Multiplier (EM) Gain (Enabled->2) - - - def await_trigger(self): - try: - (ret) = self.cam.WaitForAcquisition() - - print("Awaiting trigger...") - - except: - try: - (ret) = self.cam.ShutDown() - except: - pass - print("Error in await_trigger(), try restarting artiq...") - - - - def convert_image(self): - - try: - (ret, fullFrameBuffer) = self.cam.GetMostRecentImage(self.imageSize) # GetImages(somethinghere) might be a better command if we want to do background subtraction - image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array - # plt.imshow(image) - - - # try: - ##Acquire images - # images=[] - # for i in range(num_of_im): - # 1. Get image from buffer (c_long - # 2. Convert c_long to numpy array - # 3. Wipe image from buffer - - # 1. end acquisition - # return images - except: - try: - (ret) = self.cam.ShutDown() - except: - pass - print("Error in convert_image(), try restarting artiq...") - - - - def reset(self): - (ret) = self.cam.ShutDown() - print("Shutdown successful...") diff --git a/Andor/andorv2/andor/aqctl_andor.py b/Andor/andorv2/andor/aqctl_andor.py deleted file mode 100644 index 23b4b42..0000000 --- a/Andor/andorv2/andor/aqctl_andor.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -sys.path.append(r'C:\Users\hoodl\Documents\GitHub\Instruments\andor_repo') - -from andor.andor_driver import ANDOR -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the ANDOR camera") - common_args.simple_network_args(parser, 3210) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = ANDOR(args.device if not args.simulation else None) - - dev = ANDOR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("ANDOR server startup on port",args.port,"successful...") - simple_server_loop( - {"ANDOR": dev}, common_args.bind_address_from_args(args), args.port) - truthcounter=1 - finally: - print("Closing server...") - #dev.close() - -if __name__ == "__main__": - main() diff --git a/Andor/andorv2/andor/atmcd.py b/Andor/andorv2/andor/atmcd.py deleted file mode 100644 index 03a3281..0000000 --- a/Andor/andorv2/andor/atmcd.py +++ /dev/null @@ -1,12230 +0,0 @@ -from ctypes import * -import time -import platform -import sys - -MAX_PATH = 256 - -class ColorDemosaicInfo(Structure) : - _fields_ = [("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iXPhase", c_int), - ("iYPhase", c_int), - ("iBackground", c_int)] -class AndorCapabilities(Structure) : - _fields_ = [("ulSize", c_ulong), - ("ulAcqModes", c_ulong), - ("ulReadModes", c_ulong), - ("ulTriggerModes", c_ulong), - ("ulCameraType", c_ulong), - ("ulPixelMode", c_ulong), - ("ulSetFunctions", c_ulong), - ("ulGetFunctions", c_ulong), - ("ulFeatures", c_ulong), - ("ulPCICard", c_ulong), - ("ulEMGainCapability", c_ulong), - ("ulFTReadModes", c_ulong)] -class WhiteBalanceInfo(Structure) : - _fields_ = [("iSize", c_int), - ("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iROI_left", c_int), - ("iROI_right", c_int), - ("iROI_top", c_int), - ("iROI_bottom", c_int), - ("iOperation", c_int)] -class SYSTEMTIME(Structure) : - _fields_ = [("wYear", c_short), - ("wMonth", c_short), - ("wDayOfWeek", c_short), - ("wDay", c_short), - ("wHour", c_short), - ("wMinute", c_short), - ("wSecond", c_short), - ("wMilliseconds", c_short)] - -class atmcd: - def __init__(self): - if sys.platform == "linux2": - dllname = "/usr/local/lib/libandor.so" - self.dll = cdll.LoadLibrary(dllname) - elif sys.platform == "win32": - if platform.architecture()[0] == "64bit" : - dllname = "C:\\Program Files\\Andor SDK\\atmcd64d.dll" - else: - dllname = "C:\\Program Files\\Andor SDK\\atmcd32d.dll" - self.dll = windll.LoadLibrary(dllname) - else: - print("Cannot detect operating system, will now stop") - raise - - # Error Code Returns and Definitions - DRV_ERROR_CODES = 20001 - DRV_SUCCESS = 20002 - DRV_VXDNOTINSTALLED = 20003 - DRV_ERROR_SCAN = 20004 - DRV_ERROR_CHECK_SUM = 20005 - DRV_ERROR_FILELOAD = 20006 - DRV_UNKNOWN_FUNCTION = 20007 - DRV_ERROR_VXD_INIT = 20008 - DRV_ERROR_ADDRESS = 20009 - DRV_ERROR_PAGELOCK = 20010 - DRV_ERROR_PAGEUNLOCK = 20011 - DRV_ERROR_BOARDTEST = 20012 - DRV_ERROR_ACK = 20013 - DRV_ERROR_UP_FIFO = 20014 - DRV_ERROR_PATTERN = 20015 - DRV_ACQUISITION_ERRORS = 20017 - DRV_ACQ_BUFFER = 20018 - DRV_ACQ_DOWNFIFO_FULL = 20019 - DRV_PROC_UNKONWN_INSTRUCTION = 20020 - DRV_ILLEGAL_OP_CODE = 20021 - DRV_KINETIC_TIME_NOT_MET = 20022 - DRV_ACCUM_TIME_NOT_MET = 20023 - DRV_NO_NEW_DATA = 20024 - DRV_PCI_DMA_FAIL = 20025 - DRV_SPOOLERROR = 20026 - DRV_SPOOLSETUPERROR = 20027 - DRV_FILESIZELIMITERROR = 20028 - DRV_ERROR_FILESAVE = 20029 - DRV_TEMPERATURE_CODES = 20033 - DRV_TEMPERATURE_OFF = 20034 - DRV_TEMPERATURE_NOT_STABILIZED = 20035 - DRV_TEMPERATURE_STABILIZED = 20036 - DRV_TEMPERATURE_NOT_REACHED = 20037 - DRV_TEMPERATURE_OUT_RANGE = 20038 - DRV_TEMPERATURE_NOT_SUPPORTED = 20039 - DRV_TEMPERATURE_DRIFT = 20040 - DRV_TEMP_CODES = 20033 - DRV_TEMP_OFF = 20034 - DRV_TEMP_NOT_STABILIZED = 20035 - DRV_TEMP_STABILIZED = 20036 - DRV_TEMP_NOT_REACHED = 20037 - DRV_TEMP_OUT_RANGE = 20038 - DRV_TEMP_NOT_SUPPORTED = 20039 - DRV_TEMP_DRIFT = 20040 - DRV_GENERAL_ERRORS = 20049 - DRV_INVALID_AUX = 20050 - DRV_COF_NOTLOADED = 20051 - DRV_FPGAPROG = 20052 - DRV_FLEXERROR = 20053 - DRV_GPIBERROR = 20054 - DRV_EEPROMVERSIONERROR = 20055 - DRV_DATATYPE = 20064 - DRV_DRIVER_ERRORS = 20065 - DRV_P1INVALID = 20066 - DRV_P2INVALID = 20067 - DRV_P3INVALID = 20068 - DRV_P4INVALID = 20069 - DRV_INIERROR = 20070 - DRV_COFERROR = 20071 - DRV_ACQUIRING = 20072 - DRV_IDLE = 20073 - DRV_TEMPCYCLE = 20074 - DRV_NOT_INITIALIZED = 20075 - DRV_P5INVALID = 20076 - DRV_P6INVALID = 20077 - DRV_INVALID_MODE = 20078 - DRV_INVALID_FILTER = 20079 - DRV_I2CERRORS = 20080 - DRV_I2CDEVNOTFOUND = 20081 - DRV_I2CTIMEOUT = 20082 - DRV_P7INVALID = 20083 - DRV_P8INVALID = 20084 - DRV_P9INVALID = 20085 - DRV_P10INVALID = 20086 - DRV_P11INVALID = 20087 - DRV_USBERROR = 20089 - DRV_IOCERROR = 20090 - DRV_VRMVERSIONERROR = 20091 - DRV_GATESTEPERROR = 20092 - DRV_USB_INTERRUPT_ENDPOINT_ERROR = 20093 - DRV_RANDOM_TRACK_ERROR = 20094 - DRV_INVALID_TRIGGER_MODE = 20095 - DRV_LOAD_FIRMWARE_ERROR = 20096 - DRV_DIVIDE_BY_ZERO_ERROR = 20097 - DRV_INVALID_RINGEXPOSURES = 20098 - DRV_BINNING_ERROR = 20099 - DRV_INVALID_AMPLIFIER = 20100 - DRV_INVALID_COUNTCONVERT_MODE = 20101 - DRV_ERROR_NOCAMERA = 20990 - DRV_NOT_SUPPORTED = 20991 - DRV_NOT_AVAILABLE = 20992 - DRV_ERROR_MAP = 20115 - DRV_ERROR_UNMAP = 20116 - DRV_ERROR_MDL = 20117 - DRV_ERROR_UNMDL = 20118 - DRV_ERROR_BUFFSIZE = 20119 - DRV_ERROR_NOHANDLE = 20121 - DRV_GATING_NOT_AVAILABLE = 20130 - DRV_FPGA_VOLTAGE_ERROR = 20131 - DRV_OW_CMD_FAIL = 20150 - DRV_OWMEMORY_BAD_ADDR = 20151 - DRV_OWCMD_NOT_AVAILABLE = 20152 - DRV_OW_NO_SLAVES = 20153 - DRV_OW_NOT_INITIALIZED = 20154 - DRV_OW_ERROR_SLAVE_NUM = 20155 - DRV_MSTIMINGS_ERROR = 20156 - DRV_OA_NULL_ERROR = 20173 - DRV_OA_PARSE_DTD_ERROR = 20174 - DRV_OA_DTD_VALIDATE_ERROR = 20175 - DRV_OA_FILE_ACCESS_ERROR = 20176 - DRV_OA_FILE_DOES_NOT_EXIST = 20177 - DRV_OA_XML_INVALID_OR_NOT_FOUND_ERROR = 20178 - DRV_OA_PRESET_FILE_NOT_LOADED = 20179 - DRV_OA_USER_FILE_NOT_LOADED = 20180 - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED = 20181 - DRV_OA_INVALID_FILE = 20182 - DRV_OA_FILE_HAS_BEEN_MODIFIED = 20183 - DRV_OA_BUFFER_FULL = 20184 - DRV_OA_INVALID_STRING_LENGTH = 20185 - DRV_OA_INVALID_CHARS_IN_NAME = 20186 - DRV_OA_INVALID_NAMING = 20187 - DRV_OA_GET_CAMERA_ERROR = 20188 - DRV_OA_MODE_ALREADY_EXISTS = 20189 - DRV_OA_STRINGS_NOT_EQUAL = 20190 - DRV_OA_NO_USER_DATA = 20191 - DRV_OA_VALUE_NOT_SUPPORTED = 20192 - DRV_OA_MODE_DOES_NOT_EXIST = 20193 - DRV_OA_CAMERA_NOT_SUPPORTED = 20194 - DRV_OA_FAILED_TO_GET_MODE = 20195 - DRV_PROCESSING_FAILED = 20211 - AT_NoOfVersionInfoIds = 2 - AT_VERSION_INFO_LEN = 80 - AT_CONTROLLER_CARD_MODEL_LEN = 80 - AT_DDGLite_ControlBit_GlobalEnable = 0x01 - AT_DDGLite_ControlBit_ChannelEnable = 0x01 - AT_DDGLite_ControlBit_FreeRun = 0x02 - AT_DDGLite_ControlBit_DisableOnFrame = 0x04 - AT_DDGLite_ControlBit_RestartOnFire = 0x08 - AT_DDGLite_ControlBit_Invert = 0x10 - AT_DDGLite_ControlBit_EnableOnFire = 0x20 - AT_DDG_POLARITY_POSITIVE = 0 - AT_DDG_POLARITY_NEGATIVE = 1 - AT_DDG_TERMINATION_50OHMS = 0 - AT_DDG_TERMINATION_HIGHZ = 1 - AT_STEPMODE_CONSTANT = 0 - AT_STEPMODE_EXPONENTIAL = 1 - AT_STEPMODE_LOGARITHMIC = 2 - AT_STEPMODE_LINEAR = 3 - AT_STEPMODE_OFF = 100 - AT_GATEMODE_FIRE_AND_GATE = 0 - AT_GATEMODE_FIRE_ONLY = 1 - AT_GATEMODE_GATE_ONLY = 2 - AT_GATEMODE_CW_ON = 3 - AT_GATEMODE_CW_OFF = 4 - AT_GATEMODE_DDG = 5 - AC_ACQMODE_SINGLE = 1 - AC_ACQMODE_VIDEO = 2 - AC_ACQMODE_ACCUMULATE = 4 - AC_ACQMODE_KINETIC = 8 - AC_ACQMODE_FRAMETRANSFER = 16 - AC_ACQMODE_FASTKINETICS = 32 - AC_ACQMODE_OVERLAP = 64 - AC_READMODE_FULLIMAGE = 1 - AC_READMODE_SUBIMAGE = 2 - AC_READMODE_SINGLETRACK = 4 - AC_READMODE_FVB = 8 - AC_READMODE_MULTITRACK = 16 - AC_READMODE_RANDOMTRACK = 32 - AC_READMODE_MULTITRACKSCAN = 64 - AC_TRIGGERMODE_INTERNAL = 1 - AC_TRIGGERMODE_EXTERNAL = 2 - AC_TRIGGERMODE_EXTERNAL_FVB_EM = 4 - AC_TRIGGERMODE_CONTINUOUS = 8 - AC_TRIGGERMODE_EXTERNALSTART = 16 - AC_TRIGGERMODE_EXTERNALEXPOSURE = 32 - AC_TRIGGERMODE_INVERTED = 0x40 - AC_TRIGGERMODE_EXTERNAL_CHARGESHIFTING = 0x80 - AC_TRIGGERMODE_BULB = 32 - AC_CAMERATYPE_PDA = 0 - AC_CAMERATYPE_IXON = 1 - AC_CAMERATYPE_ICCD = 2 - AC_CAMERATYPE_EMCCD = 3 - AC_CAMERATYPE_CCD = 4 - AC_CAMERATYPE_ISTAR = 5 - AC_CAMERATYPE_VIDEO = 6 - AC_CAMERATYPE_IDUS = 7 - AC_CAMERATYPE_NEWTON = 8 - AC_CAMERATYPE_SURCAM = 9 - AC_CAMERATYPE_USBICCD = 10 - AC_CAMERATYPE_LUCA = 11 - AC_CAMERATYPE_RESERVED = 12 - AC_CAMERATYPE_IKON = 13 - AC_CAMERATYPE_INGAAS = 14 - AC_CAMERATYPE_IVAC = 15 - AC_CAMERATYPE_UNPROGRAMMED = 16 - AC_CAMERATYPE_CLARA = 17 - AC_CAMERATYPE_USBISTAR = 18 - AC_CAMERATYPE_SIMCAM = 19 - AC_CAMERATYPE_NEO = 20 - AC_CAMERATYPE_IXONULTRA = 21 - AC_CAMERATYPE_VOLMOS = 22 - AC_PIXELMODE_8BIT = 1 - AC_PIXELMODE_14BIT = 2 - AC_PIXELMODE_16BIT = 4 - AC_PIXELMODE_32BIT = 8 - AC_PIXELMODE_MONO = 0x000000 - AC_PIXELMODE_RGB = 0x010000 - AC_PIXELMODE_CMY = 0x020000 - AC_SETFUNCTION_VREADOUT = 0x01 - AC_SETFUNCTION_HREADOUT = 0x02 - AC_SETFUNCTION_TEMPERATURE = 0x04 - AC_SETFUNCTION_MCPGAIN = 0x08 - AC_SETFUNCTION_EMCCDGAIN = 0x10 - AC_SETFUNCTION_BASELINECLAMP = 0x20 - AC_SETFUNCTION_VSAMPLITUDE = 0x40 - AC_SETFUNCTION_HIGHCAPACITY = 0x80 - AC_SETFUNCTION_BASELINEOFFSET = 0x0100 - AC_SETFUNCTION_PREAMPGAIN = 0x0200 - AC_SETFUNCTION_CROPMODE = 0x0400 - AC_SETFUNCTION_DMAPARAMETERS = 0x0800 - AC_SETFUNCTION_HORIZONTALBIN = 0x1000 - AC_SETFUNCTION_MULTITRACKHRANGE = 0x2000 - AC_SETFUNCTION_RANDOMTRACKNOGAPS = 0x4000 - AC_SETFUNCTION_EMADVANCED = 0x8000 - AC_SETFUNCTION_GATEMODE = 0x010000 - AC_SETFUNCTION_DDGTIMES = 0x020000 - AC_SETFUNCTION_IOC = 0x040000 - AC_SETFUNCTION_INTELLIGATE = 0x080000 - AC_SETFUNCTION_INSERTION_DELAY = 0x100000 - AC_SETFUNCTION_GATESTEP = 0x200000 - AC_SETFUNCTION_GATEDELAYSTEP = 0x200000 - AC_SETFUNCTION_TRIGGERTERMINATION = 0x400000 - AC_SETFUNCTION_EXTENDEDNIR = 0x800000 - AC_SETFUNCTION_SPOOLTHREADCOUNT = 0x1000000 - AC_SETFUNCTION_REGISTERPACK = 0x2000000 - AC_SETFUNCTION_PRESCANS = 0x4000000 - AC_SETFUNCTION_GATEWIDTHSTEP = 0x8000000 - AC_SETFUNCTION_GAIN = 8 - AC_SETFUNCTION_ICCDGAIN = 8 - AC_GETFUNCTION_TEMPERATURE = 0x01 - AC_GETFUNCTION_TARGETTEMPERATURE = 0x02 - AC_GETFUNCTION_TEMPERATURERANGE = 0x04 - AC_GETFUNCTION_DETECTORSIZE = 0x08 - AC_GETFUNCTION_MCPGAIN = 0x10 - AC_GETFUNCTION_EMCCDGAIN = 0x20 - AC_GETFUNCTION_HVFLAG = 0x40 - AC_GETFUNCTION_GATEMODE = 0x80 - AC_GETFUNCTION_DDGTIMES = 0x0100 - AC_GETFUNCTION_IOC = 0x0200 - AC_GETFUNCTION_INTELLIGATE = 0x0400 - AC_GETFUNCTION_INSERTION_DELAY = 0x0800 - AC_GETFUNCTION_GATESTEP = 0x1000 - AC_GETFUNCTION_GATEDELAYSTEP = 0x1000 - AC_GETFUNCTION_PHOSPHORSTATUS = 0x2000 - AC_GETFUNCTION_MCPGAINTABLE = 0x4000 - AC_GETFUNCTION_BASELINECLAMP = 0x8000 - AC_GETFUNCTION_GATEWIDTHSTEP = 0x10000 - AC_GETFUNCTION_GAIN = 0x10 - AC_GETFUNCTION_ICCDGAIN = 0x10 - AC_FEATURES_POLLING = 1 - AC_FEATURES_EVENTS = 2 - AC_FEATURES_SPOOLING = 4 - AC_FEATURES_SHUTTER = 8 - AC_FEATURES_SHUTTEREX = 16 - AC_FEATURES_EXTERNAL_I2C = 32 - AC_FEATURES_SATURATIONEVENT = 64 - AC_FEATURES_FANCONTROL = 128 - AC_FEATURES_MIDFANCONTROL = 256 - AC_FEATURES_TEMPERATUREDURINGACQUISITION = 512 - AC_FEATURES_KEEPCLEANCONTROL = 1024 - AC_FEATURES_DDGLITE = 0x0800 - AC_FEATURES_FTEXTERNALEXPOSURE = 0x1000 - AC_FEATURES_KINETICEXTERNALEXPOSURE = 0x2000 - AC_FEATURES_DACCONTROL = 0x4000 - AC_FEATURES_METADATA = 0x8000 - AC_FEATURES_IOCONTROL = 0x10000 - AC_FEATURES_PHOTONCOUNTING = 0x20000 - AC_FEATURES_COUNTCONVERT = 0x40000 - AC_FEATURES_DUALMODE = 0x80000 - AC_FEATURES_OPTACQUIRE = 0x100000 - AC_FEATURES_REALTIMESPURIOUSNOISEFILTER = 0x200000 - AC_FEATURES_POSTPROCESSSPURIOUSNOISEFILTER = 0x400000 - AC_FEATURES_DUALPREAMPGAIN = 0x800000 - AC_FEATURES_DEFECT_CORRECTION = 0x1000000 - AC_FEATURES_STARTOFEXPOSURE_EVENT = 0x2000000 - AC_FEATURES_ENDOFEXPOSURE_EVENT = 0x4000000 - AC_FEATURES_CAMERALINK = 0x8000000 - AC_EMGAIN_8BIT = 1 - AC_EMGAIN_12BIT = 2 - AC_EMGAIN_LINEAR12 = 4 - AC_EMGAIN_REAL12 = 8 - def AbortAcquisition(self): - ''' - Description: - This function aborts the current acquisition if one is active. - - Synopsis: - ret = AbortAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition aborted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_IDLE - The system is not currently acquiring. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int AbortAcquisition(void); - - See Also: - GetStatus StartAcquisition - - ''' - ret = self.dll.AbortAcquisition() - return (ret) - - def CancelWait(self): - ''' - Description: - This function restarts a thread which is sleeping within the WaitForAcquisitionWaitForAcquisition function. The sleeping thread will return from WaitForAcquisition with a value not equal to DRV_SUCCESS. - - Synopsis: - ret = CancelWait() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread restarted successfully. - - C++ Equiv: - unsigned int CancelWait(void); - - See Also: - WaitForAcquisition - - ''' - ret = self.dll.CancelWait() - return (ret) - - def CoolerOFF(self): - ''' - Description: - Switches OFF the cooling. The rate of temperature change is controlled in some models until the temperature reaches 0C. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerOFF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched OFF. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support switching cooler off. - - C++ Equiv: - unsigned int CoolerOFF(void); - - See Also: - CoolerON SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: Not available on Luca R cameras - always cooled to -20C. - - NOTE: (Classic & ICCD only) 1. When the temperature control is switched off the temperature of the sensor is gradually raised to 0C to ensure no thermal stresses are set up in the sensor. 2. When closing down the program via ShutDown you must ensure that the temperature of the detector is above -20C, otherwise calling ShutDown while the detector is still cooled will cause the temperature to rise faster than certified. - - - ''' - ret = self.dll.CoolerOFF() - return (ret) - - def CoolerON(self): - ''' - Description: - Switches ON the cooling. On some systems the rate of temperature change is controlled until the temperature is within 3C of the set value. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerON() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched ON. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int CoolerON(void); - - See Also: - CoolerOFF SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: The temperature to which the detector will be cooled is set via SetTemperatureSetTemperature. The temperature stabilization is controlled via hardware, and the current temperature can be obtained via GetTemperatureGetTemperature. The temperature of the sensor is gradually brought to the desired temperature to ensure no thermal stresses are set up in the sensor. - - Can be called for certain systems during an acquisition. This can be tested for using GetCapabilities. - - - ''' - ret = self.dll.CoolerON() - return (ret) - - def DemosaicImage(self, grey, info): - ''' - Description: - For colour sensors only - Demosaics an image taken with a CYMG CCD into RGB using the parameters stored in info. Below is the ColorDemosaicInfo structure definition and a description of its members: - struct COLORDEMOSAICINFO { - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to demosaic image. - int iXPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iYPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iBackground; // Background to remove from raw data when demosaicing. - ColorDemosaicInfo; - * iX and iY are the image dimensions. The number of elements in the input red, green and blue arrays is iX x iY. - * iAlgorithm sets the algorithm to use: 0 for a 2x2 matrix demosaic algorithm or 1 for a 3x3 one. - The CYMG CCD pattern can be broken into cells of 2x4 pixels, e.g.: - * iXPhase and iYPhase store what colour is the bottom-left pixel. - * iBackground sets the numerical value to be removed from every pixel in the input image before demosaicing is done. - - Synopsis: - (ret, red, green, blue) = DemosaicImage(grey, info) - - Inputs: - grey - pointer to image to demosaic - info - pointer to demosaic information structure. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image demosaiced - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - One or more parameters in info is out of range - red - pointer to the red plane storage allocated by the user. - green - pointer to the green plane storage allocated by the user. - blue - pointer to the blue plane storage allocated by the user. - - C++ Equiv: - unsigned int DemosaicImage(WORD * grey, WORD * red, WORD * green, WORD * blue, ColorDemosaicInfo * info); - - See Also: - GetMostRecentColorImage16 WhiteBalance - - ''' - cgrey = (c_short * info.iX * info.iY)(grey) - cred = (c_short * info.iX * info.iY)() - cgreen = (c_short * info.iX * info.iY)() - cblue = (c_short * info.iX * info.iY)() - cinfo = ColorDemosaicInfo(info) - ret = self.dll.DemosaicImage(cgrey, cred, cgreen, cblue, byref(cinfo)) - return (ret, cred, cgreen, cblue) - - def EnableKeepCleans(self, mode): - ''' - Description: - This function is only available on certain cameras operating in FVB external trigger mode. It determines if the camera keep clean cycle will run between acquisitions. - When keep cleans are disabled in this way the exposure time is effectively the exposure time between triggers. - The Keep Clean cycle is enabled by default. - The feature capability AC_FEATURES_KEEPCLEANCONTROL determines if this function can be called for the camera. - - Synopsis: - ret = EnableKeepCleans(mode) - - Inputs: - mode - The keep clean mode.: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Keep clean cycle mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int EnableKeepCleans(int mode); - - See Also: - GetCapabilities - - Note: Currently only available on Newton and iKon cameras operating in FVB external trigger mode. - - ''' - cmode = c_int(mode) - ret = self.dll.EnableKeepCleans(cmode) - return (ret) - - def Filter_GetAveragingFactor(self): - ''' - Description: - Returns the current averaging factor value. - - Synopsis: - (ret, averagingFactor) = Filter_GetAveragingFactor() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid averagingFactor (i.e. NULL pointer). - averagingFactor - The current averaging factor value. - - C++ Equiv: - unsigned int Filter_GetAveragingFactor(int * averagingFactor); - - See Also: - Filter_SetAveragingFactor - - ''' - caveragingFactor = c_int() - ret = self.dll.Filter_GetAveragingFactor(byref(caveragingFactor)) - return (ret, caveragingFactor.value) - - def Filter_GetAveragingFrameCount(self): - ''' - Description: - Returns the current frame count value. - - Synopsis: - (ret, frames) = Filter_GetAveragingFrameCount() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count (i.e. NULL pointer). - frames - The current frame count value. - - C++ Equiv: - unsigned int Filter_GetAveragingFrameCount(int * frames); - - See Also: - Filter_SetAveragingFrameCount - - ''' - cframes = c_int() - ret = self.dll.Filter_GetAveragingFrameCount(byref(cframes)) - return (ret, cframes.value) - - def Filter_GetDataAveragingMode(self): - ''' - Description: - Returns the current averaging mode. - - Synopsis: - (ret, mode) = Filter_GetDataAveragingMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - mode - The current averaging mode. - - C++ Equiv: - unsigned int Filter_GetDataAveragingMode(int * mode); - - See Also: - Filter_SetDataAveragingMode - - ''' - cmode = c_int() - ret = self.dll.Filter_GetDataAveragingMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetMode(self): - ''' - Description: - Returns the current Noise Filter mode. - - Synopsis: - (ret, mode) = Filter_GetMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode (i.e. NULL pointer) - mode - Noise Filter mode. - - C++ Equiv: - unsigned int Filter_GetMode(unsigned int * mode); - - See Also: - Filter_SetMode - - ''' - cmode = c_uint() - ret = self.dll.Filter_GetMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetThreshold(self): - ''' - Description: - Returns the current Noise Filter threshold value. - - Synopsis: - (ret, threshold) = Filter_GetThreshold() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - threshold - The current threshold value. - - C++ Equiv: - unsigned int Filter_GetThreshold(float * threshold); - - See Also: - Filter_SetThreshold - - ''' - cthreshold = c_float() - ret = self.dll.Filter_GetThreshold(byref(cthreshold)) - return (ret, cthreshold.value) - - def Filter_SetAveragingFactor(self, averagingFactor): - ''' - Description: - Sets the averaging factor. - - Synopsis: - ret = Filter_SetAveragingFactor(averagingFactor) - - Inputs: - averagingFactor - The averaging factor to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging factor set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - - C++ Equiv: - unsigned int Filter_SetAveragingFactor(int averagingFactor); - - See Also: - Filter_GetAveragingFactor - - ''' - caveragingFactor = c_int(averagingFactor) - ret = self.dll.Filter_SetAveragingFactor(caveragingFactor) - return (ret) - - def Filter_SetAveragingFrameCount(self, frames): - ''' - Description: - Sets the averaging frame count. - - Synopsis: - ret = Filter_SetAveragingFrameCount(frames) - - Inputs: - frames - The averaging frame count to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging frame count set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count. - - C++ Equiv: - unsigned int Filter_SetAveragingFrameCount(int frames); - - See Also: - Filter_GetAveragingFrameCount - - ''' - cframes = c_int(frames) - ret = self.dll.Filter_SetAveragingFrameCount(cframes) - return (ret) - - def Filter_SetDataAveragingMode(self, mode): - ''' - Description: - Sets the current data averaging mode. - - Synopsis: - ret = Filter_SetDataAveragingMode(mode) - - Inputs: - mode - The averaging factor mode to use.: - 0 - No Averaging Filter - 5 - Recursive Averaging Filter - 6 - Frame Averaging Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetDataAveragingMode(int mode); - - See Also: - Filter_GetDataAveragingMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetDataAveragingMode(cmode) - return (ret) - - def Filter_SetMode(self, mode): - ''' - Description: - Set the Noise Filter to use. - - Synopsis: - ret = Filter_SetMode(mode) - - Inputs: - mode - Filter mode to use.: - 0 - No Filter - 1 - Median Filter - 2 - Level Above Filter - 3 - interquartile Range Filter - 4 - Noise Threshold Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetMode(int mode); - - See Also: - Filter_GetMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetMode(cmode) - return (ret) - - def Filter_SetThreshold(self, threshold): - ''' - Description: - Sets the threshold value for the Noise Filter. - - Synopsis: - ret = Filter_SetThreshold(threshold) - - Inputs: - threshold - Threshold value used to process image.: - 0 - 65535 for Level Above filter. - 0 - 10 for all other filters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold. - - C++ Equiv: - unsigned int Filter_SetThreshold(float threshold); - - See Also: - Filter_GetThreshold - - ''' - cthreshold = c_float(threshold) - ret = self.dll.Filter_SetThreshold(cthreshold) - return (ret) - - def FreeInternalMemory(self): - ''' - Description: - The FreeinternalMemory function will deallocate any memory used internally to store the previously acquired data. Note that once this function has been called, data from last acquisition cannot be retrieved. - - Synopsis: - ret = FreeInternalMemory() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Memory freed. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int FreeInternalMemory(void); - - See Also: - GetImages PrepareAcquisition - - ''' - ret = self.dll.FreeInternalMemory() - return (ret) - - def GetAcquiredData(self, size): - ''' - Description: - This function will return the data from the last acquisition. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData(at_32 * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData16 - - ''' - carr = c_int() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredData16(self, size): - ''' - Description: - 16-bit version of the GetAcquiredDataGetAcquiredData function. The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size isincorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData16(WORD * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData - - ''' - carr = c_short() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData16(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAcquiredFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAcquiredFloatData(float * arr, unsigned long size); - - ''' - carr = c_float() - csize = c_ulong(size) - ret = self.dll.GetAcquiredFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquisitionProgress(self): - ''' - Description: - This function will return information on the progress of the current acquisition. It can be called at any time but is best used in conjunction with SetDriverEventSetDriverEvent. - The values returned show the number of completed scans in the current acquisition. - If 0 is returned for both accum and series then either:- - * No acquisition is currently running - * The acquisition has just completed - * The very first scan of an acquisition has just started and not yet completed - GetStatus can be used to confirm if the first scan has just started, returning - DRV_ACQUIRING, otherwise it will return DRV_IDLE. - For example, if [i]accum[/i]=2 and [i]series[/i]=3 then the acquisition has completed 3 in the series and 2 accumulations in the 4 scan of the series. - - Synopsis: - (ret, acc, series) = GetAcquisitionProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of accumulation and series scans completed. - DRV_NOT_INITIALIZED - System not initialized. - acc - returns the number of accumulations completed in the current kinetic scan. - series - series the number of kinetic scans completed - - C++ Equiv: - unsigned int GetAcquisitionProgress(long * acc, long * series); - - See Also: - SetAcquisitionMode SetNumberAccumulations SetNumberKinetics SetDriverEvent - - ''' - cacc = c_int() - cseries = c_int() - ret = self.dll.GetAcquisitionProgress(byref(cacc), byref(cseries)) - return (ret, cacc.value, cseries.value) - - def GetAcquisitionTimings(self): - ''' - Description: - This function will return the current "valid" acquisition timing information. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The values returned are the actual times used in subsequent acquisitions. - This function is required as it is possible to set the exposure time to 20ms, accumulate cycle time to 30ms and then set the readout mode to full image. As it can take 250ms to read out an image it is not possible to have a cycle time of 30ms. - - Synopsis: - (ret, exposure, accumulate, kinetic) = GetAcquisitionTimings() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Acquisition or readout mode is not available. - exposure - valid exposure time in seconds - accumulate - valid accumulate cycle time in seconds - kinetic - valid kinetic cycle time in seconds - - C++ Equiv: - unsigned int GetAcquisitionTimings(float * exposure, float * accumulate, float * kinetic); - - See Also: - SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - cexposure = c_float() - caccumulate = c_float() - ckinetic = c_float() - ret = self.dll.GetAcquisitionTimings(byref(cexposure), byref(caccumulate), byref(ckinetic)) - return (ret, cexposure.value, caccumulate.value, ckinetic.value) - - def GetAdjustedRingExposureTimes(self, inumTimes): - ''' - Description: - This function will return the actual exposure times that the camera will use. There may be differences between requested exposures and the actual exposures. - - Synopsis: - (ret, fptimes) = GetAdjustedRingExposureTimes(inumTimes) - - Inputs: - inumTimes - inumTimesNumbers of times requested. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number of exposures requested - fptimes - fptimesPointer to an array large enough to hold _inumTimes floats. - - C++ Equiv: - unsigned int GetAdjustedRingExposureTimes(int inumTimes, float * fptimes); - - See Also: - GetNumberRingExposureTimes SetRingExposureTimes - - ''' - cinumTimes = c_int(inumTimes) - cfptimes = c_float() - ret = self.dll.GetAdjustedRingExposureTimes(cinumTimes, byref(cfptimes)) - return (ret, cfptimes.value) - - def GetAllDMAData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAllDMAData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAllDMAData(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetAllDMAData(byref(carr), csize) - return (ret, carr.value) - - def GetAmpDesc(self, index, length): - ''' - Description: - This function will return a string with an amplifier description. The amplifier is selected using the index. The SDK has a string associated with each of its amplifiers. The maximum number of characters needed to store the amplifier descriptions is 21. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetAmpDesc(index, length) - - Inputs: - index - The amplifier index. - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid. - DRV_P2INVALID - The desc pointer is null. - DRV_P3INVALID - The length parameter is invalid (less than 1) - name - A user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetAmpDesc(int index, char * name, int length); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetAmpDesc(cindex, cname, clength) - return (ret, cname) - - def GetAmpMaxSpeed(self, index): - ''' - Description: - This function will return the maximum available horizontal shift speed for the amplifier selected by the index parameter. - - Synopsis: - (ret, speed) = GetAmpMaxSpeed(index) - - Inputs: - index - amplifier index - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid - speed - horizontal shift speed - - C++ Equiv: - unsigned int GetAmpMaxSpeed(int index, float * speed); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetAmpMaxSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetAvailableCameras(self): - ''' - Description: - This function returns the total number of Andor cameras currently installed. It is possible to call this function before any of the cameras are initialized. - - Synopsis: - (ret, totalCameras) = GetAvailableCameras() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of available cameras returned. - DRV_GENERAL_ERRORS - An error occurred while obtaining the number of available cameras. - totalCameras - the number of cameras currently installed - - C++ Equiv: - unsigned int GetAvailableCameras(long * totalCameras); - - See Also: - SetCurrentCamera GetCurrentCamera GetCameraHandle - - ''' - ctotalCameras = c_int() - ret = self.dll.GetAvailableCameras(byref(ctotalCameras)) - return (ret, ctotalCameras.value) - - def GetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetBackground(byref(carr), csize) - return (ret, carr.value) - - def GetBaselineClamp(self): - ''' - Description: - This function returns the status of the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - (ret, state) = GetBaselineClamp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - state - Baseline clamp functionality Enabled/Disabled: - 1 - Baseline Clamp Enabled - 0 - Baseline Clamp Disabled - - C++ Equiv: - unsigned int GetBaselineClamp(int * state); - - See Also: - SetBaselineClamp SetBaselineOffset - - ''' - cstate = c_int() - ret = self.dll.GetBaselineClamp(byref(cstate)) - return (ret, cstate.value) - - def GetBitDepth(self, channel): - ''' - Description: - This function will retrieve the size in bits of the dynamic range for any available AD channel. - - Synopsis: - (ret, depth) = GetBitDepth(channel) - - Inputs: - channel - the AD channel. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Depth returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel - depth - dynamic range in bits - - C++ Equiv: - unsigned int GetBitDepth(int channel, int * depth); - - See Also: - GetNumberADChannels SetADChannel - - ''' - cchannel = c_int(channel) - cdepth = c_int() - ret = self.dll.GetBitDepth(cchannel, byref(cdepth)) - return (ret, cdepth.value) - - def GetCameraEventStatus(self): - ''' - Description: - This function will return if the system is exposing or not. - - Synopsis: - (ret, camStatus) = GetCameraEventStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - camStatus - The status of the firepulse will be returned that the firepulse is low: - 0 - Fire pulse low - 1 - Fire pulse high - - C++ Equiv: - unsigned int GetCameraEventStatus(DWORD * camStatus); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: This is only supported by the CCI23 card. - - ''' - ccamStatus = () - ret = self.dll.GetCameraEventStatus(byref(ccamStatus)) - return (ret, ccamStatus.value) - - def GetCameraHandle(self, cameraIndex): - ''' - Description: - This function returns the handle for the camera specified by cameraIndex. When multiple Andor cameras are installed the handle of each camera must be retrieved in order to select a camera using the SetCurrentCamera function. - The number of cameras can be obtained using the GetAvailableCameras function. - - Synopsis: - (ret, cameraHandle) = GetCameraHandle(cameraIndex) - - Inputs: - cameraIndex - index of any of the installed cameras. 0 to NumberCameras-1 where NumberCameras is the value returned by the GetAvailableCamerasGetAvailableCameras functionGetAvailableCamerasGetNumberVerticalSpeedsGetNumberHSSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - DRV_P1INVALID - Invalid camera index. - cameraHandle - handle of the camera. - - C++ Equiv: - unsigned int GetCameraHandle(long cameraIndex, long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCurrentCamera - - ''' - ccameraIndex = c_int(cameraIndex) - ccameraHandle = c_int() - ret = self.dll.GetCameraHandle(ccameraIndex, byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCameraInformation(self, index): - ''' - Description: - This function will return information on a particular camera denoted by the index. - - Synopsis: - (ret, information) = GetCameraInformation(index) - - Inputs: - index - (reserved) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Driver status return - DRV_VXDNOTINSTALLED - Driver not installed - DRV_USBERROR - USB device error - information - current state of camera: - Bit:1 - USB camera present - Bit:2 - All dlls loaded properly - Bit:3 - Camera Initialized correctly - - C++ Equiv: - unsigned int GetCameraInformation(int index, long * information); - - See Also: - GetCameraHandle GetHeadModel GetCameraSerialNumber GetCapabilities - - Note: Only available in iDus. The index parameter is not used at present so should be set to 0. For any camera except the iDus The value of information following a call to this function will be zero. - - ''' - cindex = c_int(index) - cinformation = c_int() - ret = self.dll.GetCameraInformation(cindex, byref(cinformation)) - return (ret, cinformation.value) - - def GetCameraSerialNumber(self): - ''' - Description: - This function will retrieve camera's serial number. - - Synopsis: - (ret, number) = GetCameraSerialNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Serial Number returned. - DRV_NOT_INITIALIZED - System not initialized. - number - Serial Number. - - C++ Equiv: - unsigned int GetCameraSerialNumber(int * number); - - See Also: - GetCameraHandle GetHeadModel GetCameraInformation GetCapabilities - - ''' - cnumber = c_int() - ret = self.dll.GetCameraSerialNumber(byref(cnumber)) - return (ret, cnumber.value) - - def GetCapabilities(self): - ''' - Description: - This function will fill in an AndorCapabilities structure with the capabilities associated with the connected camera. Before passing the address of an AndorCapabilites structure to the function the ulSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - caps->ulSize = sizeof(AndorCapabilities); - Individual capabilities are determined by examining certain bits and combinations of bits in the member variables of the AndorCapabilites structure. - - Synopsis: - (ret, caps) = GetCapabilities() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized - DRV_SUCCESS - Capabilities returned. - DRV_P1INVALID - Invalid caps parameter (i.e. NULL). - caps - the capabilities structure to be filled in. - - C++ Equiv: - unsigned int GetCapabilities(AndorCapabilities * caps); - - See Also: - GetCameraHandle GetCameraSerialNumber GetHeadModel GetCameraInformation - - ''' - caps = AndorCapabilities() - caps.ulSize = sizeof(caps) - ret = self.dll.GetCapabilities(byref(caps)) - return (ret, caps) - - def GetControllerCardModel(self): - ''' - Description: - This function will retrieve the type of PCI controller card included in your system. This function is not applicable for USB systems. The maximum number of characters that can be returned from this function is 10. - - Synopsis: - (ret, controllerCardModel) = GetControllerCardModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized - controllerCardModel - A user allocated array of characters for storage of the controller card model. - - C++ Equiv: - unsigned int GetControllerCardModel(char * controllerCardModel); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - ccontrollerCardModel = create_string_buffer(10) - ret = self.dll.GetControllerCardModel(ccontrollerCardModel) - return (ret, ccontrollerCardModel) - - def GetCountConvertWavelengthRange(self): - ''' - Description: - This function returns the valid wavelength range available in Count Convert mode. - - Synopsis: - (ret, minval, maxval) = GetCountConvertWavelengthRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - minval - minimum wavelength permited. - maxval - maximum wavelength permited. - - C++ Equiv: - unsigned int GetCountConvertWavelengthRange(float * minval, float * maxval); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cminval = c_float() - cmaxval = c_float() - ret = self.dll.GetCountConvertWavelengthRange(byref(cminval), byref(cmaxval)) - return (ret, cminval.value, cmaxval.value) - - def GetCurrentCamera(self): - ''' - Description: - When multiple Andor cameras are installed this function returns the handle of the currently selected one. - - Synopsis: - (ret, cameraHandle) = GetCurrentCamera() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - cameraHandle - handle of the currently selected camera - - C++ Equiv: - unsigned int GetCurrentCamera(long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int() - ret = self.dll.GetCurrentCamera(byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCYMGShift(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, iXshift, iYShift) = GetCYMGShift() - - Inputs: - None - - Outputs: - ret - Function Return Code - iXshift - - iYShift - - - C++ Equiv: - unsigned int GetCYMGShift(int * iXshift, int * iYShift); - - ''' - ciXshift = c_int() - ciYShift = c_int() - ret = self.dll.GetCYMGShift(byref(ciXshift), byref(ciYShift)) - return (ret, ciXshift.value, ciYShift.value) - - def GetDDGExternalOutputEnabled(self, uiIndex): - ''' - Description: - This function gets the current state of a selected external output. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputPolarity(self, uiIndex): - ''' - Description: - This function gets the current polarity of a selected external output. - - Synopsis: - (ret, puiPolarity) = GetDDGExternalOutputPolarity(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiPolarity - current polarity of external output (0 - Positive, 1 - Negative). - - C++ Equiv: - unsigned int GetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 * puiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputPolarity SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiPolarity = c_uint() - ret = self.dll.GetDDGExternalOutputPolarity(cuiIndex, byref(cpuiPolarity)) - return (ret, cpuiPolarity.value) - - def GetDDGExternalOutputStepEnabled(self, uiIndex): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to determine if this option is currently active. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputStepEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output track step (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputStepEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputStepEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputTime(self, uiIndex): - ''' - Description: - This function can be used to find the actual timings for a particular external output. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGExternalOutputTime(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Delay has invalid memory address. - puiDelay - actual external output delay time in picoseconds. - puiWidth - actual external output width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGExternalOutputTime(at_u32 uiIndex, at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputTime SetDDGGateStep - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGExternalOutputTime(cuiIndex, byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGGateTime(self): - ''' - Description: - This function can be used to get the actual gate timings for a USB iStar. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGGateTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Delay has invalid memory address. - puiDelay - gate delay time in picoseconds. - puiWidth - gate width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGGateTime(at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities SetDDGGateTimeSetDDGGateStep - - ''' - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGGateTime(byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGInsertionDelay(self): - ''' - Description: - This function gets the current state of the insertion delay. - - Synopsis: - (ret, piState) = GetDDGInsertionDelay() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Insertion delay state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Insertion delay not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the insertion delay option (0 - Normal, 1 - Ultra Fast). - - C++ Equiv: - unsigned int GetDDGInsertionDelay(int * piState); - - See Also: - GetCapabilities SetDDGInsertionDelay SetDDGIntelligate - - ''' - cpiState = c_int() - ret = self.dll.GetDDGInsertionDelay(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIntelligate(self): - ''' - Description: - This function gets the current state of intelligate. - - Synopsis: - (ret, piState) = GetDDGIntelligate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - intelligate not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the intelligate option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIntelligate(int * piState); - - See Also: - GetCapabilities SetDDGIntelligate SetDDGInsertionDelay - - ''' - cpiState = c_int() - ret = self.dll.GetDDGIntelligate(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIOC(self): - ''' - Description: - This function gets the current state of the integrate on chip (IOC) option. - - Synopsis: - (ret, state) = GetDDGIOC() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - state has invalid memory address. - state - current state of the IOC option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIOC(int * state); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency - - ''' - cstate = c_int() - ret = self.dll.GetDDGIOC(byref(cstate)) - return (ret, cstate.value) - - def GetDDGIOCFrequency(self): - ''' - Description: - This function can be used to return the actual IOC frequency that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, frequency) = GetDDGIOCFrequency() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - frequency - the frequency of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCFrequency(double * frequency); - - See Also: - GetCapabilities SetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cfrequency = c_double() - ret = self.dll.GetDDGIOCFrequency(byref(cfrequency)) - return (ret, cfrequency.value) - - def GetDDGIOCNumber(self): - ''' - Description: - This function can be used to return the actual number of pulses that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, numberPulses) = GetDDGIOCNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCNumber(unsigned long * numberPulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cnumberPulses = c_ulong() - ret = self.dll.GetDDGIOCNumber(byref(cnumberPulses)) - return (ret, cnumberPulses.value) - - def GetDDGIOCNumberRequested(self): - ''' - Description: - This function can be used to return the number of pulses that were requested by the user. - - Synopsis: - (ret, pulses) = GetDDGIOCNumberRequested() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - pulses has invalid memory address. - pulses - the number of integrate on chip pulses requested. - - C++ Equiv: - unsigned int GetDDGIOCNumberRequested(at_u32 * pulses); - - See Also: - GetCapabilities SetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_uint() - ret = self.dll.GetDDGIOCNumberRequested(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCPeriod(self): - ''' - Description: - This function can be used to return the actual IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, period) = GetDDGIOCPeriod() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - period has invalid memory address. - period - the period of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPeriod(at_u64 * period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCPeriod SetDDGIOCFrequency - - ''' - cperiod = c_ulonglong() - ret = self.dll.GetDDGIOCPeriod(byref(cperiod)) - return (ret, cperiod.value) - - def GetDDGIOCPulses(self): - ''' - Description: - This function can be used to calculate the number of pulses that will be triggered with the given exposure time, readout mode, acquisition mode and integrate on chip frequency. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, pulses) = GetDDGIOCPulses() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - pulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPulses(int * pulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_int() - ret = self.dll.GetDDGIOCPulses(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCTrigger(self): - ''' - Description: - function can be used to retrieve the active IOC trigger. - at_u32* trigger: active IOC trigger (0 - Fire pulse, 1 - External trigger). - at_u32 int - DRV_SUCCESS - DRV_NOT_INITIALIZED - DRV_NOT_SUPPORTED - DRV_ACQUIRING - DRV_ERROR_ACK - DRV_P1INVALID - IOC trigger returned. - System not initialized. - IOC not supported. - Acquisition in progress. - Unable to communicate with system. - Invalid trigger. - See also - GetCapabilities SetDDGIOC SetDDGIOCFrequency SetDDGIOCTrigger SetTriggerMode - GetDDGLiteControlByte - GetDDGLiteControlByte int WINAPI GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control) - Description - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, trigger) = GetDDGIOCTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code - trigger - - - C++ Equiv: - unsigned int GetDDGIOCTrigger(at_u32 * trigger); - - ''' - ctrigger = c_uint() - ret = self.dll.GetDDGIOCTrigger(byref(ctrigger)) - return (ret, ctrigger.value) - - def GetDDGLiteControlByte(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, control) = GetDDGLiteControlByte(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control); - - ''' - cchannel = (channel) - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteControlByte(cchannel, byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteGlobalControlByte(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, control) = GetDDGLiteGlobalControlByte() - - Inputs: - None - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteGlobalControlByte(unsigned char * control); - - ''' - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteGlobalControlByte(byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteInitialDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInitialDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInitialDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLiteInterPulseDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInterPulseDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInterPulseDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLitePulsesPerExposure(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, ui32Pulses) = GetDDGLitePulsesPerExposure(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - ui32Pulses - - - C++ Equiv: - unsigned int GetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 * ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint() - ret = self.dll.GetDDGLitePulsesPerExposure(cchannel, byref(cui32Pulses)) - return (ret, cui32Pulses.value) - - def GetDDGLitePulseWidth(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fWidth) = GetDDGLitePulseWidth(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fWidth - - - C++ Equiv: - unsigned int GetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float * fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float() - ret = self.dll.GetDDGLitePulseWidth(cchannel, byref(cfWidth)) - return (ret, cfWidth.value) - - def GetDDGOpticalWidthEnabled(self): - ''' - Description: - This function can be used to check whether optical gate widths are being used. - - Synopsis: - (ret, puiEnabled) = GetDDGOpticalWidthEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiEnabled - optical gate width option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGOpticalWidthEnabled(at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth - - ''' - cpuiEnabled = c_uint() - ret = self.dll.GetDDGOpticalWidthEnabled(byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGPulse(self, wid, resolution): - ''' - Description: - This function attempts to find a laser pulse in a user-defined region with a given resolution. The values returned will provide an estimation of the location of the pulse. - - Synopsis: - (ret, Delay, Width) = GetDDGPulse(wid, resolution) - - Inputs: - wid - the time in picoseconds of the region to be searched. - resolution - the minimum gate pulse used to locate the laser. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Location returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - Delay - the approximate start of the laser pulse. - Width - the pulse width, which encapsulated the laser pulse. - - C++ Equiv: - unsigned int GetDDGPulse(double wid, double resolution, double * Delay, double * Width); - - Note: Available in iStar. - - ''' - cwid = c_double(wid) - cresolution = c_double(resolution) - cDelay = c_double() - cWidth = c_double() - ret = self.dll.GetDDGPulse(cwid, cresolution, byref(cDelay), byref(cWidth)) - return (ret, cDelay.value, cWidth.value) - - def GetDDGStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate step mode. - - Synopsis: - (ret, p1, p2) = GetDDGStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - First coefficient - p2 - Second coefficient - - C++ Equiv: - unsigned int GetDDGStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGStepMode(self): - ''' - Description: - This function will return the current gate step mode. - - Synopsis: - (ret, mode) = GetDDGStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGStepMode(at_u32 * mode); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint() - ret = self.dll.GetDDGStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDDGTTLGateWidth(self, opticalWidth): - ''' - Description: - This function can be used to get the TTL gate width which corresponds to a particular optical gate width. - - Synopsis: - (ret, ttlWidth) = GetDDGTTLGateWidth(opticalWidth) - - Inputs: - opticalWidth - optical gate width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P2_INVALID - Unable to communicate with system. - ttlWidth - TTL gate width in picoseconds. - - C++ Equiv: - unsigned int GetDDGTTLGateWidth(at_u64 opticalWidth, at_u64 * ttlWidth); - - See Also: - GetCapabilities SetDDGOpticalWidthEnabled SetDDGGateStep - - ''' - copticalWidth = c_ulonglong(opticalWidth) - cttlWidth = c_ulonglong() - ret = self.dll.GetDDGTTLGateWidth(copticalWidth, byref(cttlWidth)) - return (ret, cttlWidth.value) - - def GetDDGWidthStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate width step mode. - - Synopsis: - (ret, p1, p2) = GetDDGWidthStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - The first coefficient. - p2 - The second coefficient. - - C++ Equiv: - unsigned int GetDDGWidthStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepMode - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGWidthStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGWidthStepMode(self): - ''' - Description: - This function will return the current gate width step mode. - - Synopsis: - (ret, mode) = GetDDGWidthStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGWidthStepMode(at_u32 * mode); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepCoefficients StartAcquisition - - ''' - cmode = c_uint() - ret = self.dll.GetDDGWidthStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDetector(self): - ''' - Description: - This function returns the size of the detector in pixels. The horizontal axis is taken to be the axis parallel to the readout register. - - Synopsis: - (ret, xpixels, ypixels) = GetDetector() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Detector size returned. - DRV_NOT_INITIALIZED - System not initialized. - xpixels - number of horizontal pixels. - ypixels - number of vertical pixels. - - C++ Equiv: - unsigned int GetDetector(int * xpixels, int * ypixels); - - ''' - cxpixels = c_int() - cypixels = c_int() - ret = self.dll.GetDetector(byref(cxpixels), byref(cypixels)) - return (ret, cxpixels.value, cypixels.value) - - def GetDICameraInfo(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, info) = GetDICameraInfo() - - Inputs: - None - - Outputs: - ret - Function Return Code - info - - - C++ Equiv: - unsigned int GetDICameraInfo(void * info); - - ''' - cinfo = c_void() - ret = self.dll.GetDICameraInfo(byref(cinfo)) - return (ret, cinfo.value) - - def GetDualExposureTimes(self): - ''' - Description: - This function will return the current valid acquisition timing information for dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - (ret, exposure1, exposure2) = GetDualExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. . - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_NOT_AVAILABLE - Dual exposure mode not configured correctly. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - exposure1 has invalid memory address. - DRV_P2INVALID - exposure2 has invalid memory address. - exposure1 - valid exposure time in seconds for each odd numbered frame. - exposure2 - valid exposure time in seconds for each even numbered frame. - - C++ Equiv: - unsigned int GetDualExposureTimes(float * exposure1, float * exposure2); - - See Also: - GetCapabilities SetDualExposureMode SetDualExposureTimes - - ''' - cexposure1 = c_float() - cexposure2 = c_float() - ret = self.dll.GetDualExposureTimes(byref(cexposure1), byref(cexposure2)) - return (ret, cexposure1.value, cexposure2.value) - - def GetEMAdvanced(self): - ''' - Description: - Returns the current Advanced gain setting. - - Synopsis: - (ret, state) = GetEMAdvanced() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Advanced state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - state has invalid memory address. - state - current EM advanced gain setting - - C++ Equiv: - unsigned int GetEMAdvanced(int * state); - - ''' - cstate = c_int() - ret = self.dll.GetEMAdvanced(byref(cstate)) - return (ret, cstate.value) - - def GetEMCCDGain(self): - ''' - Description: - Returns the current gain setting. The meaning of the value returned depends on the EM Gain mode. - - Synopsis: - (ret, gain) = GetEMCCDGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - gain - current EM gain setting - - C++ Equiv: - unsigned int GetEMCCDGain(int * gain); - - ''' - cgain = c_int() - ret = self.dll.GetEMCCDGain(byref(cgain)) - return (ret, cgain.value) - - def GetEMGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the current selected EM Gain mode and temperature of the sensor. - - Synopsis: - (ret, low, high) = GetEMGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - low - lowest gain setting - high - highest gain setting - - C++ Equiv: - unsigned int GetEMGainRange(int * low, int * high); - - ''' - clow = c_int() - chigh = c_int() - ret = self.dll.GetEMGainRange(byref(clow), byref(chigh)) - return (ret, clow.value, chigh.value) - - def GetExternalTriggerTermination(self): - ''' - Description: - This function can be used to get the current external trigger termination mode. - - Synopsis: - (ret, puiTermination) = GetExternalTriggerTermination() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - C++ Equiv: - unsigned int GetExternalTriggerTermination(at_u32 * puiTermination); - - See Also: - GetCapabilities SetExternalTriggerTermination - - ''' - cpuiTermination = c_uint() - ret = self.dll.GetExternalTriggerTermination(byref(cpuiTermination)) - return (ret, cpuiTermination.value) - - def GetFastestRecommendedVSSpeed(self): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the fastest recommended speed available. The very high readout speeds, may require an increase in the amplitude of the Vertical Clock Voltage using SetVSAmplitudeSetVSAmplitude. This function returns the fastest speed which does not require the Vertical Clock Voltage to be adjusted. The values returned are the vertical shift speed index and the actual speed in microseconds per pixel shift. - - Synopsis: - (ret, index, speed) = GetFastestRecommendedVSSpeed() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - index - index of the fastest recommended vertical shift speed - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetFastestRecommendedVSSpeed(int * index, float * speed); - - See Also: - GetVSSpeed GetNumberVSSpeeds SetVSSpeed - - ''' - cindex = c_int() - cspeed = c_float() - ret = self.dll.GetFastestRecommendedVSSpeed(byref(cindex), byref(cspeed)) - return (ret, cindex.value, cspeed.value) - - def GetFIFOUsage(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, FIFOusage) = GetFIFOUsage() - - Inputs: - None - - Outputs: - ret - Function Return Code - FIFOusage - - - C++ Equiv: - unsigned int GetFIFOUsage(int * FIFOusage); - - ''' - cFIFOusage = c_int() - ret = self.dll.GetFIFOUsage(byref(cFIFOusage)) - return (ret, cFIFOusage.value) - - def GetFilterMode(self): - ''' - Description: - This function returns the current state of the cosmic ray filtering mode. - - Synopsis: - (ret, mode) = GetFilterMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mode - current state of filter: - 0 - OFF - 2 - ON - - C++ Equiv: - unsigned int GetFilterMode(int * mode); - - See Also: - SetFilterMode - - ''' - cmode = c_int() - ret = self.dll.GetFilterMode(byref(cmode)) - return (ret, cmode.value) - - def GetFKExposureTime(self): - ''' - Description: - This function will return the current "valid" exposure time for a fast kinetics acquisition. This function should be used after all the acquisitions settings have been set, i.e. SetFastKineticsSetFastKinetics and SetFKVShiftSpeedSetFKVShiftSpeed. The value returned is the actual time used in subsequent acquisitions. - - Synopsis: - (ret, time) = GetFKExposureTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Fast kinetics is not available. - time - valid exposure time in seconds - - C++ Equiv: - unsigned int GetFKExposureTime(float * time); - - See Also: - SetFastKinetics SetFKVShiftSpeed - - ''' - ctime = c_float() - ret = self.dll.GetFKExposureTime(byref(ctime)) - return (ret, ctime.value) - - def GetFKVShiftSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Deprecated by GetFKVShiftSpeedFGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetFKVShiftSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFKVShiftSpeedF(self, index): - ''' - Description: - As your Andor system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeedF(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeedF(int index, float * speed); - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetFKVShiftSpeedF(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFrontEndStatus(self): - ''' - Description: - This function will return if the Front End cooler has overheated. - - Synopsis: - (ret, piFlag) = GetFrontEndStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Front End cooler not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the front end cooler: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetFrontEndStatus(int * piFlag); - - See Also: - SetFrontEndEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetFrontEndStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetGateMode(self): - ''' - Description: - Allows the user to get the current photocathode gating mode. - - Synopsis: - (ret, piGatemode) = GetGateMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - gatemode has invalid memory address. - piGatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - C++ Equiv: - unsigned int GetGateMode(int * piGatemode); - - See Also: - GetCapabilities SetGateMode - - ''' - cpiGatemode = c_int() - ret = self.dll.GetGateMode(byref(cpiGatemode)) - return (ret, cpiGatemode.value) - - def GetHardwareVersion(self): - ''' - Description: - This function returns the Hardware version information. - - Synopsis: - (ret, PCB, Decode, dummy1, dummy2, CameraFirmwareVersion, CameraFirmwareBuild) = GetHardwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - PCB - Plug-in card version - Decode - Flex 10K file version - dummy1 - - dummy2 - - CameraFirmwareVersion - Version number of camera firmware - CameraFirmwareBuild - Build number of camera firmware - - C++ Equiv: - unsigned int GetHardwareVersion(unsigned int * PCB, unsigned int * Decode, unsigned int * dummy1, unsigned int * dummy2, unsigned int * CameraFirmwareVersion, unsigned int * CameraFirmwareBuild); - - ''' - cPCB = c_uint() - cDecode = c_uint() - cdummy1 = c_uint() - cdummy2 = c_uint() - cCameraFirmwareVersion = c_uint() - cCameraFirmwareBuild = c_uint() - ret = self.dll.GetHardwareVersion(byref(cPCB), byref(cDecode), byref(cdummy1), byref(cdummy2), byref(cCameraFirmwareVersion), byref(cCameraFirmwareBuild)) - return (ret, cPCB.value, cDecode.value, cdummy1.value, cdummy2.value, cCameraFirmwareVersion.value, cCameraFirmwareBuild.value) - - def GetHeadModel(self): - ''' - Description: - This function will retrieve the type of CCD attached to your system. - - Synopsis: - (ret, name) = GetHeadModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized. - name - A user allocated array of characters for storage of the Head Model. This should be declared as size MAX_PATH. - - C++ Equiv: - unsigned int GetHeadModel(char * name); - - ''' - cname = create_string_buffer(MAX_PATH) - ret = self.dll.GetHeadModel(cname) - return (ret, cname.value) - - def GetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetHorizontalSpeed(index) - - Inputs: - index - speed required, 0 to NumberSpeeds-1, where NumberSpeeds is the parameter returned by GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetHorizontalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberHorizontalSpeeds SetHorizontalSpeed - - Note: Deprecated by GetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetHorizontalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHSSpeed(self, channel, typ, index): - ''' - Description: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in MHz. - - Synopsis: - (ret, speed) = GetHSSpeed(channel, typ, index) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR Mode(clara). - index - speed required Valid values: 0 to NumberSpeeds-1, where NumberSpeeds is value returned in first parameter after a call to GetNumberHSSpeedsGetNumberHSSpeeds(). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - DRV_P3INVALID - Invalid index - speed - speed in in MHz. - - C++ Equiv: - unsigned int GetHSSpeed(int channel, int typ, int index, float * speed); - - See Also: - GetNumberHSSpeeds SetHSSpeed - - Note: The speed is returned in microseconds per pixel shift for iStar and Classic systems. - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetHSSpeed(cchannel, ctyp, cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHVflag(self): - ''' - Description: - This function will retrieve the High Voltage flag from your USB iStar intensifier. A 0 value indicates that the high voltage is abnormal. - - Synopsis: - (ret, bFlag) = GetHVflag() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - HV flag returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - bFlag - pointer to High Voltage flag. - - C++ Equiv: - unsigned int GetHVflag(int * bFlag); - - Note: Available only on USB iStar. - - ''' - cbFlag = c_int() - ret = self.dll.GetHVflag(byref(cbFlag)) - return (ret, cbFlag.value) - - def GetID(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, id) = GetID(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - id - - - C++ Equiv: - unsigned int GetID(int devNum, int * id); - - ''' - cdevNum = c_int(devNum) - cid = c_int() - ret = self.dll.GetID(cdevNum, byref(cid)) - return (ret, cid.value) - - def GetImageFlip(self): - ''' - Description: - This function will obtain whether the acquired data output is flipped in either the horizontal or vertical direction. - - Synopsis: - (ret, iHFlip, iVFlip) = GetImageFlip() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - iHFlip - Gets horizontal flipping. - iVFlip - Gets vertical flipping.: - 1 - Flipping Enabled - 0 - Flipping Disabled - - C++ Equiv: - unsigned int GetImageFlip(int * iHFlip, int * iVFlip); - - See Also: - SetImageRotate SetImageFlip - - ''' - ciHFlip = c_int() - ciVFlip = c_int() - ret = self.dll.GetImageFlip(byref(ciHFlip), byref(ciVFlip)) - return (ret, ciHFlip.value, ciVFlip.value) - - def GetImageRotate(self): - ''' - Description: - This function will obtain whether the acquired data output is rotated in any direction. - - Synopsis: - (ret, iRotate) = GetImageRotate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - iRotate - Rotation setting: - 0 - - No rotation - 1 - - Rotate 90 degrees clockwise - 2 - - Rotate 90 degrees anti-clockwise - - C++ Equiv: - unsigned int GetImageRotate(int * iRotate); - - See Also: - SetImageFlip SetImageRotate SetReadMode - - ''' - ciRotate = c_int() - ret = self.dll.GetImageRotate(byref(ciRotate)) - return (ret, ciRotate.value) - - def GetImages(self, first, last, size): - ''' - Description: - This function will update the data array with the specified series of images from the circular buffer. If the specified series is out of range (i.e. the images have been overwritten or have not yet been acquired then an error will be returned. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages(long first, long last, at_32 * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages16 GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_int * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImages16(self, first, last, size): - ''' - Description: - 16-bit version of the GetImagesGetImages function. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages16(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages16(long first, long last, WORD * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_short * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages16(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImagesPerDMA(self): - ''' - Description: - This function will return the maximum number of images that can be transferred during a single DMA transaction. - - Synopsis: - (ret, images) = GetImagesPerDMA() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of images per DMA returned. - images - The maximum number of images that can be transferred during a single DMA transaction - - C++ Equiv: - unsigned int GetImagesPerDMA(unsigned long * images); - - ''' - cimages = c_ulong() - ret = self.dll.GetImagesPerDMA(byref(cimages)) - return (ret, cimages.value) - - def GetIODirection(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iDirection) = GetIODirection(index) - - Inputs: - index - IO index. Valid values: 0 to GetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iDirection - current direction for this index.: - 0 - 0 Output - 1 - 1 Input - - C++ Equiv: - unsigned int GetIODirection(int index, int * iDirection); - - See Also: - GetNumberIO GetIOLevel SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int() - ret = self.dll.GetIODirection(cindex, byref(ciDirection)) - return (ret, ciDirection.value) - - def GetIOLevel(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iLevel) = GetIOLevel(index) - - Inputs: - index - IO index: - 0 - toGetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - C++ Equiv: - unsigned int GetIOLevel(int index, int * iLevel); - - See Also: - GetNumberIO GetIODirection SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciLevel = c_int() - ret = self.dll.GetIOLevel(cindex, byref(ciLevel)) - return (ret, ciLevel.value) - - def GetIRQ(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, IRQ) = GetIRQ() - - Inputs: - None - - Outputs: - ret - Function Return Code - IRQ - - - C++ Equiv: - unsigned int GetIRQ(int * IRQ); - - ''' - cIRQ = c_int() - ret = self.dll.GetIRQ(byref(cIRQ)) - return (ret, cIRQ.value) - - def GetKeepCleanTime(self): - ''' - Description: - This function will return the time to perform a keep clean cycle. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, KeepCleanTime) = GetKeepCleanTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - KeepCleanTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetKeepCleanTime(float * KeepCleanTime); - - See Also: - GetAcquisitionTimings GetReadOutTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cKeepCleanTime = c_float() - ret = self.dll.GetKeepCleanTime(byref(cKeepCleanTime)) - return (ret, cKeepCleanTime.value) - - def GetMaximumBinning(self, ReadMode, HorzVert): - ''' - Description: - This function will return the maximum binning allowable in either the vertical or horizontal dimension for a particular readout mode. - - Synopsis: - (ret, MaxBinning) = GetMaximumBinning(ReadMode, HorzVert) - - Inputs: - ReadMode - The readout mode for which to retrieve the maximum binning (see SetReadMode for possible values). - HorzVert - 0 to retrieve horizontal binning limit, 1 to retreive limit in the vertical. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Binning returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid Readmode - DRV_P2INVALID - HorzVert not equal to 0 or 1 - DRV_P3INVALID - Invalid MaxBinning address (i.e. NULL) - MaxBinning - Will contain the Maximum binning value on return. - - C++ Equiv: - unsigned int GetMaximumBinning(int ReadMode, int HorzVert, int * MaxBinning); - - See Also: - GetMinimumImageLength SetReadMode - - ''' - cReadMode = c_int(ReadMode) - cHorzVert = c_int(HorzVert) - cMaxBinning = c_int() - ret = self.dll.GetMaximumBinning(cReadMode, cHorzVert, byref(cMaxBinning)) - return (ret, cMaxBinning.value) - - def GetMaximumExposure(self): - ''' - Description: - This function will return the maximum Exposure Time in seconds that is settable by the SetExposureTime function. - - Synopsis: - (ret, MaxExp) = GetMaximumExposure() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Exposure returned. - DRV_P1INVALID - Invalid MaxExp value (i.e. NULL) - MaxExp - Will contain the Maximum exposure value on return. - - C++ Equiv: - unsigned int GetMaximumExposure(float * MaxExp); - - See Also: - SetExposureTime - - ''' - cMaxExp = c_float() - ret = self.dll.GetMaximumExposure(byref(cMaxExp)) - return (ret, cMaxExp.value) - - def GetMaximumNumberRingExposureTimes(self): - ''' - Description: - This function will return the maximum number of exposures that can be configured in the SetRingExposureTimes SDK function. - - Synopsis: - (ret, number) = GetMaximumNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number value (ie NULL) - DRV_NOTAVAILABLE - System does not support this option - number - Will contain the maximum number of exposures on return. - - C++ Equiv: - unsigned int GetMaximumNumberRingExposureTimes(int * number); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable SetRingExposureTimes - - ''' - cnumber = c_int() - ret = self.dll.GetMaximumNumberRingExposureTimes(byref(cnumber)) - return (ret, cnumber.value) - - def GetMCPGain(self): - ''' - Description: - This function will retrieve the set value for the MCP Gain. - - Synopsis: - (ret, gain) = GetMCPGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Table returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Invalid pointer (i.e. NULL) - DRV_NOT_AVAILABLE - Not a USB iStar - gain - Returned gain value. - - C++ Equiv: - unsigned int GetMCPGain(int * gain); - - See Also: - SetMCPGain - - Note: Available only on USB iStar. - - ''' - cgain = c_int() - ret = self.dll.GetMCPGain(byref(cgain)) - return (ret, cgain.value) - - def GetMCPGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the SetMCPGain function. - - Synopsis: - (ret, iLow, iHigh) = GetMCPGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - iLow - lowest gain setting - iHigh - highest gain setting - - C++ Equiv: - unsigned int GetMCPGainRange(int * iLow, int * iHigh); - - See Also: - SetMCPGain - - Note: Available only iStar. - - ''' - ciLow = c_int() - ciHigh = c_int() - ret = self.dll.GetMCPGainRange(byref(ciLow), byref(ciHigh)) - return (ret, ciLow.value, ciHigh.value) - - def GetMCPGainTable(self, iNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, piGain, pfPhotoepc) = GetMCPGainTable(iNum) - - Inputs: - iNum - - - Outputs: - ret - Function Return Code - piGain - - pfPhotoepc - - - C++ Equiv: - unsigned int GetMCPGainTable(int iNum, int * piGain, float * pfPhotoepc); - - ''' - ciNum = c_int(iNum) - cpiGain = c_int() - cpfPhotoepc = c_float() - ret = self.dll.GetMCPGainTable(ciNum, byref(cpiGain), byref(cpfPhotoepc)) - return (ret, cpiGain.value, cpfPhotoepc.value) - - def GetMCPVoltage(self): - ''' - Description: - This function will retrieve the current Micro Channel Plate voltage. - - Synopsis: - (ret, iVoltage) = GetMCPVoltage() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Voltage returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - DRV_GENERAL_ERRORS - EEPROM not valid - iVoltage - Will contain voltage on return. The unit is in Volts and should be between the range 600 - 1100 Volts. - - C++ Equiv: - unsigned int GetMCPVoltage(int * iVoltage); - - See Also: - GetMCPGain - - Note: Available only on USB iStar. - - ''' - ciVoltage = c_int() - ret = self.dll.GetMCPVoltage(byref(ciVoltage)) - return (ret, ciVoltage.value) - - def GetMetaDataInfo(self, index): - ''' - Description: - This function will return the time of the initial frame and the time in milliseconds of further frames from this point. - - Synopsis: - (ret, TimeOfStart, pfTimeFromStart) = GetMetaDataInfo(index) - - Inputs: - index - frame for which time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - TimeOfStart - Structure with start time details. - pfTimeFromStart - time in milliseconds for a particular frame from time of start. - - C++ Equiv: - unsigned int GetMetaDataInfo(SYSTEMTIME * TimeOfStart, float * pfTimeFromStart, int index); - - See Also: - SetMetaData - - ''' - cTimeOfStart = SYSTEMTIME() - cpfTimeFromStart = c_float() - cindex = c_int(index) - ret = self.dll.GetMetaDataInfo(byref(cTimeOfStart), byref(cpfTimeFromStart), cindex) - return (ret, cTimeOfStart, cpfTimeFromStart.value) - - def GetMinimumImageLength(self): - ''' - Description: - This function will return the minimum number of pixels that can be read out from the chip at each exposure. This minimum value arises due the way in which the chip is read out and will limit the possible sub image dimensions and binning sizes that can be applied. - - Synopsis: - (ret, MinImageLength) = GetMinimumImageLength() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum Number of Pixels returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid MinImageLength value (i.e. NULL) - MinImageLength - Will contain the minimum number of super pixels on return. - - C++ Equiv: - unsigned int GetMinimumImageLength(int * MinImageLength); - - See Also: - SetImage - - ''' - cMinImageLength = c_int() - ret = self.dll.GetMinimumImageLength(byref(cMinImageLength)) - return (ret, cMinImageLength.value) - - def GetMinimumNumberInSeries(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, number) = GetMinimumNumberInSeries() - - Inputs: - None - - Outputs: - ret - Function Return Code - number - - - C++ Equiv: - unsigned int GetMinimumNumberInSeries(int * number); - - ''' - cnumber = c_int() - ret = self.dll.GetMinimumNumberInSeries(byref(cnumber)) - return (ret, cnumber.value) - - def GetMostRecentColorImage16(self, size, algorithm): - ''' - Description: - For colour sensors only. - Color version of the GetMostRecentImage16 function. The CCD is sensitive to Cyan, Yellow, Magenta and Green (CYMG). The Red, Green and Blue (RGB) are calculated and Data is stored in 3 planes/images, one for each basic color. - - Synopsis: - (ret, red, green, blue) = GetMostRecentColorImage16(size, algorithm) - - Inputs: - size - total number of pixels. - algorithm - algorithm used to extract the RGB from the original CYMG CCD.: - 0 - 0 basic algorithm combining Cyan, Yellow and Magenta. - 1 - 1 algorithm combining Cyan, Yellow, Magenta and Green. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image RGB has been copied into arrays. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Arrays size is incorrect. - DRV_P2INVALID - Invalid algorithm. - DRV_P3INVALID - Invalid red pointer (i.e. NULL).. - DRV_P4INVALID - Invalid green pointer (i.e. NULL).. - DRV_P5INVALID - Invalid bluepointer (i.e. NULL).. - DRV_NO_NEW_DATA - There is no new data yet. - red - pointer to red data storage allocated by the user. - green - pointer to red data storage allocated by the user. - blue - pointer to red data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentColorImage16(unsigned long size, int algorithm, WORD * red, WORD * green, WORD * blue); - - See Also: - GetMostRecentImage16 DemosaicImage WhiteBalance - - ''' - csize = c_ulong(size) - calgorithm = c_int(algorithm) - cred = (c_short * size)() - cgreen = (c_short * size)() - cblue = (c_short * size)() - ret = self.dll.GetMostRecentColorImage16(csize, calgorithm, cred, cgreen, cblue) - return (ret, cred, cgreen, cblue) - - def GetMostRecentImage(self, size): - ''' - Description: - This function will update the data array with the most recently acquired image in any acquisition mode. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the complete image. - - Synopsis: - (ret, arr) = GetMostRecentImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage(at_32 * arr, unsigned long size); - - See Also: - GetMostRecentImage16 GetOldestImage GetOldestImage16 GetImages - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetMostRecentImage(carr, csize) - return (ret, carr) - - def GetMostRecentImage16(self, size): - ''' - Description: - 16-bit version of the GetMostRecentImageGetMostRecentImage function. - - Synopsis: - (ret, arr) = GetMostRecentImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage16(WORD * arr, long size); - - See Also: - GetMostRecentImage GetOldestImage16 GetOldestImage GetImages - - ''' - carr = (c_short * size)() - csize = c_int(size) - ret = self.dll.GetMostRecentImage16(carr, csize) - return (ret, carr) - - def GetMSTimingsData(self, inoOfImages): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, TimeOfStart, pfDifferences) = GetMSTimingsData(inoOfImages) - - Inputs: - inoOfImages - - - Outputs: - ret - Function Return Code - TimeOfStart - - pfDifferences - - - C++ Equiv: - unsigned int GetMSTimingsData(SYSTEMTIME * TimeOfStart, float * pfDifferences, int inoOfImages); - - ''' - cTimeOfStart = SYSTEMTIME() - cpfDifferences = c_float() - cinoOfImages = c_int(inoOfImages) - ret = self.dll.GetMSTimingsData(byref(cTimeOfStart), byref(cpfDifferences), cinoOfImages) - return (ret, cTimeOfStart, cpfDifferences.value) - - def GetMSTimingsEnabled(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = GetMSTimingsEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int GetMSTimingsEnabled(void); - - ''' - ret = self.dll.GetMSTimingsEnabled() - return (ret) - - def GetNewData(self, size): - ''' - Description: - Deprecated see Note: - This function will update the data array to hold data acquired so far. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. When used in conjunction with the SetDriverEventSetDriverEvent and GetAcquisitonProgressGetAcquisitionProgress functions, the data from each scan in a kinetic series can be processed while the acquisition is taking place. - - Synopsis: - (ret, arr) = GetNewData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData(at_32 * arr, long size); // deprecated - - See Also: - SetDriverEvent GetAcquisitionProgress SetAcquisitionMode SetAcGetNewData8 GetNewData16 - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetNewData(byref(carr), csize) - return (ret, carr.value) - - def GetNewData16(self, size): - ''' - Description: - Deprecated see Note: - 16-bit version of the GetNewDataGetNewData function. - - Synopsis: - (ret, arr) = GetNewData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData16(WORD * arr, long size); // deprecated - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_short() - csize = c_int(size) - ret = self.dll.GetNewData16(byref(carr), csize) - return (ret, carr.value) - - def GetNewData8(self, size): - ''' - Description: - Deprecated see Note: - 8-bit version of the GetNewDataGetNewData function. This function will return the data in the lower 8 bits of the acquired data. - - Synopsis: - (ret, arr) = GetNewData8(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData8(unsigned char * arr, long size); - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = (c_ubyte * size)() - csize = c_int(size) - ret = self.dll.GetNewData8(carr, csize) - return (ret, carr) - - def GetNewFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetNewFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetNewFloatData(float * arr, long size); - - ''' - carr = c_float() - csize = c_int(size) - ret = self.dll.GetNewFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetNumberADChannels(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one A-D converter, this function will tell you the number available. - - Synopsis: - (ret, channels) = GetNumberADChannels() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of channels returned. - channels - number of allowed channels - - C++ Equiv: - unsigned int GetNumberADChannels(int * channels); - - See Also: - SetADChannel - - ''' - cchannels = c_int() - ret = self.dll.GetNumberADChannels(byref(cchannels)) - return (ret, cchannels.value) - - def GetNumberAmp(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one output amplifier, this function will tell you the number available. - - Synopsis: - (ret, amp) = GetNumberAmp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of output amplifiers returned. - amp - number of allowed channels - - C++ Equiv: - unsigned int GetNumberAmp(int * amp); - - See Also: - SetOutputAmplifier - - ''' - camp = c_int() - ret = self.dll.GetNumberAmp(byref(camp)) - return (ret, camp.value) - - def GetNumberAvailableImages(self): - ''' - Description: - This function will return information on the number of available images in the circular buffer. This information can be used with GetImages to retrieve a series of images. If any images are overwritten in the circular buffer they no longer can be retrieved and the information returned will treat overwritten images as not available. - - Synopsis: - (ret, first, last) = GetNumberAvailableImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - DRV_NO_NEW_DATA - There is no new data yet - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberAvailableImages(at_32 * first, at_32 * last); - - See Also: - GetImages GetImages16 GetNumberNewImages - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberAvailableImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberDDGExternalOutputs(self): - ''' - Description: - This function gets the number of available external outputs. - - Synopsis: - (ret, puiCount) = GetNumberDDGExternalOutputs() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiCount - number of available external outputs. - - C++ Equiv: - unsigned int GetNumberDDGExternalOutputs(at_u32 * puiCount); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cpuiCount = c_uint() - ret = self.dll.GetNumberDDGExternalOutputs(byref(cpuiCount)) - return (ret, cpuiCount.value) - - def GetNumberDevices(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, numDevs) = GetNumberDevices() - - Inputs: - None - - Outputs: - ret - Function Return Code - numDevs - - - C++ Equiv: - unsigned int GetNumberDevices(int * numDevs); - - ''' - cnumDevs = c_int() - ret = self.dll.GetNumberDevices(byref(cnumDevs)) - return (ret, cnumDevs.value) - - def GetNumberFKVShiftSpeeds(self): - ''' - Description: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberFKVShiftSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed speeds - - C++ Equiv: - unsigned int GetNumberFKVShiftSpeeds(int * number); - - See Also: - GetFKVShiftSpeedF SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cnumber = c_int() - ret = self.dll.GetNumberFKVShiftSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHorizontalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberHorizontalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHorizontalSpeeds(int * number); // deprecated - - See Also: - GetHorizontalSpeed SetHorizontalSpeed - - Note: Deprecated by GetNumberHSSpeedsGetNumberHSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberHorizontalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHSSpeeds(self, channel, typ): - ''' - Description: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, speeds) = GetNumberHSSpeeds(channel, typ) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication. - 1 - conventional. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - speeds - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHSSpeeds(int channel, int typ, int * speeds); - - See Also: - GetHSSpeed SetHSSpeed GetNumberADChannel - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cspeeds = c_int() - ret = self.dll.GetNumberHSSpeeds(cchannel, ctyp, byref(cspeeds)) - return (ret, cspeeds.value) - - def GetNumberIO(self): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the number of these IOs available. The functions GetIODirection, GetIOLevel, SetIODirection and SetIOLevel can be used to specify the configuration. - - Synopsis: - (ret, iNumber) = GetNumberIO() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of IOs returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iNumber - number of allowed IOs - - C++ Equiv: - unsigned int GetNumberIO(int * iNumber); - - See Also: - GetIOLevel GetIODirection SetIODirection SetIOLevel - - ''' - ciNumber = c_int() - ret = self.dll.GetNumberIO(byref(ciNumber)) - return (ret, ciNumber.value) - - def GetNumberNewImages(self): - ''' - Description: - This function will return information on the number of new images (i.e. images which have not yet been retrieved) in the circular buffer. This information can be used with GetImages to retrieve a series of the latest images. If any images are overwritten in the circular buffer they can no longer be retrieved and the information returned will treat overwritten images as having been retrieved. - - Synopsis: - (ret, first, last) = GetNumberNewImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NO_NEW_DATA - There is no new data yet. - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberNewImages(long * first, long * last); - - See Also: - GetImages GetImages16 GetNumberAvailableImages - - Note: This index will increment as soon as a single accumulation has been completed within the current acquisition. - - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberNewImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberPhotonCountingDivisions(self): - ''' - Description: - Available in some systems is photon counting mode. This function gets the number of photon counting divisions available. The functions SetPhotonCounting and SetPhotonCountingThreshold can be used to specify which of these divisions is to be used. - - Synopsis: - (ret, noOfDivisions) = GetNumberPhotonCountingDivisions() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of photon counting divisions returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Photon Counting not available - noOfDivisions - number of allowed photon counting divisions - - C++ Equiv: - unsigned int GetNumberPhotonCountingDivisions(at_u32 * noOfDivisions); - - See Also: - SetPhotonCounting IsPreAmpGainAvailable SetPhotonCountingThresholdGetPreAmpGain GetCapabilities - - ''' - cnoOfDivisions = c_uint() - ret = self.dll.GetNumberPhotonCountingDivisions(byref(cnoOfDivisions)) - return (ret, cnoOfDivisions.value) - - def GetNumberPreAmpGains(self): - ''' - Description: - Available in some systems are a number of pre amp gains that can be applied to the data as it is read out. This function gets the number of these pre amp gains available. The functions GetPreAmpGain and SetPreAmpGain can be used to specify which of these gains is to be used. - - Synopsis: - (ret, noGains) = GetNumberPreAmpGains() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of pre amp gains returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - noGains - number of allowed pre amp gains - - C++ Equiv: - unsigned int GetNumberPreAmpGains(int * noGains); - - See Also: - IsPreAmpGainAvailable GetPreAmpGain SetPreAmpGain GetCapabilities - - ''' - cnoGains = c_int() - ret = self.dll.GetNumberPreAmpGains(byref(cnoGains)) - return (ret, cnoGains.value) - - def GetNumberRingExposureTimes(self): - ''' - Description: - Gets the number of exposures in the ring at this moment. - - Synopsis: - (ret, ipnumTimes) = GetNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - ipnumTimes - Numberof exposure times. - - C++ Equiv: - unsigned int GetNumberRingExposureTimes(int * ipnumTimes); - - See Also: - SetRingExposureTimes - - ''' - cipnumTimes = c_int() - ret = self.dll.GetNumberRingExposureTimes(byref(cipnumTimes)) - return (ret, cipnumTimes.value) - - def GetNumberVerticalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberVerticalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed vertical speeds - - C++ Equiv: - unsigned int GetNumberVerticalSpeeds(int * number); // deprecated - - See Also: - GetVerticalSpeed SetVerticalSpeed - - Note: Deprecated by GetNumberVSSpeedsGetNumberVSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVerticalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSAmplitudes(self): - ''' - Description: - This function will normally return the number of vertical clock voltage amplitues that the camera has. - - Synopsis: - (ret, number) = GetNumberVSAmplitudes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters - DRV_NOT_INITIALIZED - int* speeds: number of allowed vertical speeds - DRV_NOT_AVAILABLE - Return - Number returned - Return int - System not initialized - DRV_SUCCESS - Your system does not support this feature - DRV_NOT_INITIALIZED - GetNumberVSSpeeds - DRV_ACQUIRING - GetNumberVSSpeeds int WINAPI GetNumberVSSpeeds(int* speeds) - Number of speeds returned. - Description - System not initialized. - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - Acquisition in progress. - number - Number of vertical clock voltages. - - C++ Equiv: - unsigned int GetNumberVSAmplitudes(int * number); - - See Also: - GetVSSpeed SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVSAmplitudes(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSSpeeds(self): - ''' - Description: - - - Synopsis: - (ret, speeds) = GetNumberVSSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code - speeds - - - C++ Equiv: - unsigned int GetNumberVSSpeeds(int * speeds); - - ''' - cspeeds = c_int() - ret = self.dll.GetNumberVSSpeeds(byref(cspeeds)) - return (ret, cspeeds.value) - - def GetOldestImage(self, size): - ''' - Description: - This function will update the data array with the oldest image in the circular buffer. Once the oldest image has been retrieved it no longer is available. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the full image. - - Synopsis: - (ret, arr) = GetOldestImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage(at_32 * arr, unsigned long size); - - See Also: - GetOldestImage16 GetMostRecentImage GetMostRecentImage16 - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage(carr, csize) - return (ret, carr) - - def GetOldestImage16(self, size): - ''' - Description: - 16-bit version of the GetOldestImageGetOldestImage function. - - Synopsis: - (ret, arr) = GetOldestImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage16(WORD * arr, unsigned long size); - - See Also: - GetOldestImage GetMostRecentImage16 GetMostRecentImage - - ''' - carr = (c_short * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage16(carr, csize) - return (ret, carr) - - def GetPhosphorStatus(self): - ''' - Description: - This function will return if the phosphor has saturated. - - Synopsis: - (ret, flag) = GetPhosphorStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Phosphor status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - flag - The status of the phosphor: - 0 - Normal - 1 - Saturated - - C++ Equiv: - unsigned int GetPhosphorStatus(int * flag); - - ''' - cflag = c_int() - ret = self.dll.GetPhosphorStatus(byref(cflag)) - return (ret, cflag.value) - - def GetPhysicalDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetPhysicalDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetPhysicalDMAAddress(unsigned long * Address1, unsigned long * Address2); - - ''' - cAddress1 = c_ulong() - cAddress2 = c_ulong() - ret = self.dll.GetPhysicalDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetPixelSize(self): - ''' - Description: - This function returns the dimension of the pixels in the detector in microns. - - Synopsis: - (ret, xSize, ySize) = GetPixelSize() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pixel size returned. - xSize - width of pixel. - ySize - height of pixel. - - C++ Equiv: - unsigned int GetPixelSize(float * xSize, float * ySize); - - ''' - cxSize = c_float() - cySize = c_float() - ret = self.dll.GetPixelSize(byref(cxSize), byref(cySize)) - return (ret, cxSize.value, cySize.value) - - def GetPreAmpGain(self, index): - ''' - Description: - For those systems that provide a number of pre amp gains to apply to the data as it is read out; this function retrieves the amount of gain that is stored for a particular index. The number of gains available can be obtained by calling the GetNumberPreAmpGainsGetNumberPreAmpGains function and a specific Gain can be selected using the function SetPreAmpGainSetPreAmpGain. - - Synopsis: - (ret, gain) = GetPreAmpGain(index) - - Inputs: - index - gain index: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - gain - gain factor for this index. - - C++ Equiv: - unsigned int GetPreAmpGain(int index, float * gain); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cgain = c_float() - ret = self.dll.GetPreAmpGain(cindex, byref(cgain)) - return (ret, cgain.value) - - def GetPreAmpGainText(self, index, length): - ''' - Description: - This function will return a string with a pre amp gain description. The pre amp gain is selected using the index. The SDK has a string associated with each of its pre amp gains. The maximum number of characters needed to store the pre amp gain descriptions is 30. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetPreAmpGainText(index, length) - - Inputs: - index - gain index 0 to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Array size is incorrect - DRV_NOT_SUPPORTED - Function not supported with this camera - name - nameA user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetPreAmpGainText(int index, char * name, int length); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetPreAmpGainText(cindex, cname, clength) - return (ret, cname) - - def GetQE(self, sensor, wavelength, mode): - ''' - Description: - Returns the percentage QE for a particular head model at a user specified wavelengthSetPreAmpGain. - - Synopsis: - (ret, QE) = GetQE(sensor, wavelength, mode) - - Inputs: - sensor - head model - wavelength - wavelength at which QE is required - mode - Clara mode (Normal (0) or Extended NIR (1)). 0 for all other systems - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - QE returned. - DRV_NOT_INITIALIZED - System not initialized. - QE - requested QE - - C++ Equiv: - unsigned int GetQE(char * sensor, float wavelength, int mode, float * QE); - - See Also: - GetHeadModel IsPreAmpGainAvailable SetPreAmpGain GetCapabilities - - ''' - csensor = sensor - cwavelength = c_float(wavelength) - cmode = c_int(mode) - cQE = c_float() - ret = self.dll.GetQE(csensor, cwavelength, cmode, byref(cQE)) - return (ret, cQE.value) - - def GetReadOutTime(self): - ''' - Description: - This function will return the time to readout data from a sensor. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, ReadOutTime) = GetReadOutTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - ReadOutTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetReadOutTime(float * ReadOutTime); - - See Also: - GetAcquisitionTimings GetKeepCleanTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cReadOutTime = c_float() - ret = self.dll.GetReadOutTime(byref(cReadOutTime)) - return (ret, cReadOutTime.value) - - def GetRegisterDump(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, mode) = GetRegisterDump() - - Inputs: - None - - Outputs: - ret - Function Return Code - mode - - - C++ Equiv: - unsigned int GetRegisterDump(int * mode); - - ''' - cmode = c_int() - ret = self.dll.GetRegisterDump(byref(cmode)) - return (ret, cmode.value) - - def GetRelativeImageTimes(self, first, last, size): - ''' - Description: - This function will return an array of the start times in nanoseconds of a user defined number of frames relative to the initial frame. - - Synopsis: - (ret, arr) = GetRelativeImageTimes(first, last, size) - - Inputs: - first - Index of first frame in array. - last - Index of last frame in array. - size - number of frames for which start time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - arr - array of times in nanoseconds for each frame from time of start. - - C++ Equiv: - unsigned int GetRelativeImageTimes(int first, int last, at_u64 * arr, int size); - - See Also: - GetCapabilities SetMetaData - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = c_ulonglong() - csize = c_int(size) - ret = self.dll.GetRelativeImageTimes(cfirst, clast, byref(carr), csize) - return (ret, carr.value) - - def GetRingExposureRange(self): - ''' - Description: - With the Ring Of Exposure feature there may be a case when not all exposures can be met. The ring of exposure feature will guarantee that the highest exposure will be met but this may mean that the lower exposures may not be. If the lower exposures are too low they will be increased to the lowest value possible. This function will return these upper and lower values. - - Synopsis: - (ret, fpMin, fpMax) = GetRingExposureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Min and max returned - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Trigger mode is not available - fpMin - Minimum exposure - fpMax - Maximum exposure. - - C++ Equiv: - unsigned int GetRingExposureRange(float * fpMin, float * fpMax); - - See Also: - GetCapabilities GetNumberRingExposureTimes IsTriggerModeAvailable SetRingExposureTimes - - ''' - cfpMin = c_float() - cfpMax = c_float() - ret = self.dll.GetRingExposureRange(byref(cfpMin), byref(cfpMax)) - return (ret, cfpMin.value, cfpMax.value) - - def GetSDK3Handle(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Handle) = GetSDK3Handle() - - Inputs: - None - - Outputs: - ret - Function Return Code - Handle - - - C++ Equiv: - unsigned int GetSDK3Handle(int * Handle); - - ''' - cHandle = c_int() - ret = self.dll.GetSDK3Handle(byref(cHandle)) - return (ret, cHandle.value) - - def GetSensitivity(self, channel, horzShift, amplifier, pa): - ''' - Description: - This function returns the sensitivity for a particular speed. - - Synopsis: - (ret, sensitivity) = GetSensitivity(channel, horzShift, amplifier, pa) - - Inputs: - channel - AD channel index. - horzShift - Type of output amplifier. - amplifier - Channel speed index. - pa - PreAmp gain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sensitivity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - sensitivity - requested sensitivity. - - C++ Equiv: - unsigned int GetSensitivity(int channel, int horzShift, int amplifier, int pa, float * sensitivity); - - See Also: - GetCapabilities - - Note: Available only on iXon+ and Clara. - - ''' - cchannel = c_int(channel) - chorzShift = c_int(horzShift) - camplifier = c_int(amplifier) - cpa = c_int(pa) - csensitivity = c_float() - ret = self.dll.GetSensitivity(cchannel, chorzShift, camplifier, cpa, byref(csensitivity)) - return (ret, csensitivity.value) - - def GetShutterMinTimes(self): - ''' - Description: - This function will return the minimum opening and closing times in milliseconds for the shutter on the current camera. - - Synopsis: - (ret, minclosingtime, minopeningtime) = GetShutterMinTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum times successfully returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Parameter is NULL. - DRV_P2INVALID - Parameter is NULL - minclosingtime - returns the minimum closing time in milliseconds that the shutter of the camera supports. - minopeningtime - returns the minimum opening time in milliseconds that the shutter of the camera supports. - - C++ Equiv: - unsigned int GetShutterMinTimes(int * minclosingtime, int * minopeningtime); - - ''' - cminclosingtime = c_int() - cminopeningtime = c_int() - ret = self.dll.GetShutterMinTimes(byref(cminclosingtime), byref(cminopeningtime)) - return (ret, cminclosingtime.value, cminopeningtime.value) - - def GetSizeOfCircularBuffer(self): - ''' - Description: - This function will return the maximum number of images the circular buffer can store based on the current acquisition settings. - - Synopsis: - (ret, index) = GetSizeOfCircularBuffer() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum number of images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the maximum number of images the circular buffer can store. - - C++ Equiv: - unsigned int GetSizeOfCircularBuffer(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetSizeOfCircularBuffer(byref(cindex)) - return (ret, cindex.value) - - def GetSlotBusDeviceFunction(self): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, dwslot, dwBus, dwDevice, dwFunction) = GetSlotBusDeviceFunction() - - Inputs: - None - - Outputs: - ret - Function Return Code - dwslot - - dwBus - - dwDevice - - dwFunction - - - C++ Equiv: - unsigned int GetSlotBusDeviceFunction(DWORD * dwslot, DWORD * dwBus, DWORD * dwDevice, DWORD * dwFunction); - - ''' - cdwslot = () - cdwBus = () - cdwDevice = () - cdwFunction = () - ret = self.dll.GetSlotBusDeviceFunction(byref(cdwslot), byref(cdwBus), byref(cdwDevice), byref(cdwFunction)) - return (ret, cdwslot.value, cdwBus.value, cdwDevice.value, cdwFunction.value) - - def GetSoftwareVersion(self): - ''' - Description: - This function returns the Software version information for the microprocessor code and the driver. - - Synopsis: - (ret, eprom, coffile, vxdrev, vxdver, dllrev, dllver) = GetSoftwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - eprom - EPROM version - coffile - COF file version - vxdrev - Driver revision number - vxdver - Driver version number - dllrev - DLL revision number - dllver - DLL version number - - C++ Equiv: - unsigned int GetSoftwareVersion(unsigned int * eprom, unsigned int * coffile, unsigned int * vxdrev, unsigned int * vxdver, unsigned int * dllrev, unsigned int * dllver); - - ''' - ceprom = c_uint() - ccoffile = c_uint() - cvxdrev = c_uint() - cvxdver = c_uint() - cdllrev = c_uint() - cdllver = c_uint() - ret = self.dll.GetSoftwareVersion(byref(ceprom), byref(ccoffile), byref(cvxdrev), byref(cvxdver), byref(cdllrev), byref(cdllver)) - return (ret, ceprom.value, ccoffile.value, cvxdrev.value, cvxdver.value, cdllrev.value, cdllver.value) - - def GetSpoolProgress(self): - ''' - Description: - Deprecated see Note: - This function will return information on the progress of the current spool operation. The value returned is the number of images that have been saved to disk during the current kinetic scan. - - Synopsis: - (ret, index) = GetSpoolProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Spool progress returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the number of files saved to disk in the current kinetic scan. - - C++ Equiv: - unsigned int GetSpoolProgress(long * index); // deprecated - - See Also: - SetSpool - - Note: Deprecated by GetTotalNumberImagesAcquiredGetNumberHSSpeeds - - ''' - cindex = c_int() - ret = self.dll.GetSpoolProgress(byref(cindex)) - return (ret, cindex.value) - - def GetStartUpTime(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, time) = GetStartUpTime() - - Inputs: - None - - Outputs: - ret - Function Return Code - time - - - C++ Equiv: - unsigned int GetStartUpTime(float * time); - - ''' - ctime = c_float() - ret = self.dll.GetStartUpTime(byref(ctime)) - return (ret, ctime.value) - - def GetStatus(self): - ''' - Description: - This function will return the current status of the Andor SDK system. This function should be called before an acquisition is started to ensure that it is IDLE and during an acquisition to monitor the process. - - Synopsis: - (ret, status) = GetStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - status - current status: - DRV_IDLE - waiting on instructions. - DRV_TEMPCYCLE - Executing temperature cycle. - DRV_ACQUIRING - Acquisition in progress. - DRV_ACCUM_TIME_NOT_MET - Unable to meet Accumulate cycle time. - DRV_KINETIC_TIME_NOT_MET - Unable to meet Kinetic cycle time. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQ_BUFFER - Computer unable to read the data via the ISA slot at the required rate. - DRV_SPOOLERROR - Overflow of the spool buffer. - - C++ Equiv: - unsigned int GetStatus(int * status); - - See Also: - SetTemperature StartAcquisition - - Note: If the status is one of the following: - - ''' - cstatus = c_int() - ret = self.dll.GetStatus(byref(cstatus)) - return (ret, cstatus.value) - - def GetTECStatus(self): - ''' - Description: - This function will return if the TEC has overheated. - - Synopsis: - (ret, piFlag) = GetTECStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - TEC status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the TEC: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetTECStatus(int * piFlag); - - See Also: - SetTECEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetTECStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetTemperature(self): - ''' - Description: - This function returns the temperature of the detector to the nearest degree. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperature() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilized but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperature(int * temperature); - - See Also: - GetTemperatureF SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_int() - ret = self.dll.GetTemperature(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureF(self): - ''' - Description: - This function returns the temperature in degrees of the detector. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperatureF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilised but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperatureF(float * temperature); - - See Also: - GetTemperature SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_float() - ret = self.dll.GetTemperatureF(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureRange(self): - ''' - Description: - This function returns the valid range of temperatures in centigrade to which the detector can be cooled. - - Synopsis: - (ret, mintemp, maxtemp) = GetTemperatureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature range returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mintemp - minimum temperature - maxtemp - maximum temperature - - C++ Equiv: - unsigned int GetTemperatureRange(int * mintemp, int * maxtemp); - - See Also: - GetTemperature GetTemperatureF SetTemperature CoolerON CoolerOFF - - ''' - cmintemp = c_int() - cmaxtemp = c_int() - ret = self.dll.GetTemperatureRange(byref(cmintemp), byref(cmaxtemp)) - return (ret, cmintemp.value, cmaxtemp.value) - - def GetTemperatureStatus(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, SensorTemp, TargetTemp, AmbientTemp, CoolerVolts) = GetTemperatureStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code - SensorTemp - - TargetTemp - - AmbientTemp - - CoolerVolts - - - C++ Equiv: - unsigned int GetTemperatureStatus(float * SensorTemp, float * TargetTemp, float * AmbientTemp, float * CoolerVolts); - - ''' - cSensorTemp = c_float() - cTargetTemp = c_float() - cAmbientTemp = c_float() - cCoolerVolts = c_float() - ret = self.dll.GetTemperatureStatus(byref(cSensorTemp), byref(cTargetTemp), byref(cAmbientTemp), byref(cCoolerVolts)) - return (ret, cSensorTemp.value, cTargetTemp.value, cAmbientTemp.value, cCoolerVolts.value) - - def GetTotalNumberImagesAcquired(self): - ''' - Description: - This function will return the total number of images acquired since the current acquisition started. If the camera is idle the value returned is the number of images acquired during the last acquisition. - - Synopsis: - (ret, index) = GetTotalNumberImagesAcquired() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the total number of images acquired since the acquisition started. - - C++ Equiv: - unsigned int GetTotalNumberImagesAcquired(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetTotalNumberImagesAcquired(byref(cindex)) - return (ret, cindex.value) - - def GetTriggerLevelRange(self): - ''' - Description: - This function returns the valid range of triggers in volts which the system can use. - - Synopsis: - (ret, minimum, maximum) = GetTriggerLevelRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Levels returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - minimum has invalid memory address. - minimum - minimum trigger voltage - maximum - maximum trigger voltage - - C++ Equiv: - unsigned int GetTriggerLevelRange(float * minimum, float * maximum); - - See Also: - GetCapabilities SetTriggerLevel - - ''' - cminimum = c_float() - cmaximum = c_float() - ret = self.dll.GetTriggerLevelRange(byref(cminimum), byref(cmaximum)) - return (ret, cminimum.value, cmaximum.value) - - def GetVersionInfo(self, arr, ui32BufferLen): - ''' - Description: - This function retrieves version information about different aspects of the Andor system. The information is copied into a passed string buffer. Currently, the version of the SDK and the Device Driver (USB or PCI) is supported. - - Synopsis: - (ret, szVersionInfo) = GetVersionInfo(arr, ui32BufferLen) - - Inputs: - arr - : - AT_SDKVersion - requests the SDK version information - AT_DeviceDriverVersion - requests the device driver version - ui32BufferLen - The size of the passed character array, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS Information returned - Information returned - DRV_NOT_INITIALIZED System not initialized - System not initialized - DRV_P1INVALID - Invalid information type requested - DRV_P2INVALID - Storage array pointer is NULL - DRV_P3INVALID - Size of the storage array is zero - szVersionInfo - A user allocated array of characters for storage of the information - - C++ Equiv: - unsigned int GetVersionInfo(AT_VersionInfoId arr, char * szVersionInfo, at_u32 ui32BufferLen); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - carr = (arr) - cszVersionInfo = create_string_buffer(ui32BufferLen) - cui32BufferLen = c_uint(ui32BufferLen) - ret = self.dll.GetVersionInfo(carr, cszVersionInfo, cui32BufferLen) - return (ret, cszVersionInfo) - - def GetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetVerticalSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING DRV_P1INVALID - Acquisition in progress. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVerticalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberVerticalSpeeds SetVerticalSpeed - - Note: Deprecated by GetVSSpeedGetVSSpeed. - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetVerticalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetVirtualDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetVirtualDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetVirtualDMAAddress(void * Address1, void * Address2); - - ''' - cAddress1 = c_void() - cAddress2 = c_void() - ret = self.dll.GetVirtualDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetVSAmplitudeFromString(self, text): - ''' - Description: - This Function is used to get the index of the Vertical Clock Amplitude that corresponds to the string passed in. - - Synopsis: - (ret, index) = GetVSAmplitudeFromString(text) - - Inputs: - text - String to test "Normal" , "+1" , "+2" , "+3" , "+4" - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string Index returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid text. - DRV_P2INVALID - Invalid index pointer. - index - Returns the Index of the VSAmplitude that matches string passed in - - C++ Equiv: - unsigned int GetVSAmplitudeFromString(char * text, int * index); - - See Also: - GetVSAmplitudeString GetVSAmplitudeValue - - ''' - ctext = text - cindex = c_int() - ret = self.dll.GetVSAmplitudeFromString(ctext, byref(cindex)) - return (ret, cindex.value) - - def GetVSAmplitudeString(self, index): - ''' - Description: - This Function is used to get the Vertical Clock Amplitude string that corresponds to the index passed in. - - Synopsis: - (ret, text) = GetVSAmplitudeString(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid text pointer. - text - Returns string value of the VS Amplitude found at the index supplied - - C++ Equiv: - unsigned int GetVSAmplitudeString(int index, char * text); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeValue - - ''' - cindex = c_int(index) - ctext = create_string_buffer(64) - ret = self.dll.GetVSAmplitudeString(cindex, ctext) - return (ret, ctext) - - def GetVSAmplitudeValue(self, index): - ''' - Description: - This Function is used to get the value of the Vertical Clock Amplitude found at the index passed in. - - Synopsis: - (ret, value) = GetVSAmplitudeValue(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude value returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid value pointer. - value - Returns Value of Vertical Clock Amplitude that matches index passed in - - C++ Equiv: - unsigned int GetVSAmplitudeValue(int index, int * value); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeString - - ''' - cindex = c_int(index) - cvalue = c_int() - ret = self.dll.GetVSAmplitudeValue(cindex, byref(cvalue)) - return (ret, cvalue.value) - - def GetVSSpeed(self, index): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds. - - Synopsis: - (ret, speed) = GetVSSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVSSpeed(int index, float * speed); - - See Also: - GetNumberVSSpeeds SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetVSSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GPIBReceive(self, id, address, size): - ''' - Description: - This function reads data from a device until a byte is received with the EOI line asserted or until size bytes have been read. - - Synopsis: - (ret, text) = GPIBReceive(id, address, size) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The address to send the data to - size - Number of characters to read - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data received. - DRV_P3INVALID - Invalid pointer (e.g. NULL). .Other errors may be returned by the GPIB device. Consult the help documentation supplied with these devices. - text - The data to be sent - - C++ Equiv: - unsigned int GPIBReceive(int id, short address, char * text, int size); - - See Also: - GPIBSend - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = create_string_buffer(size) - csize = c_int(size) - ret = self.dll.GPIBReceive(cid, caddress, ctext, csize) - return (ret, ctext) - - def GPIBSend(self, id, address, text): - ''' - Description: - This function initializes the GPIB by sending interface clear. Then the device described by address is put in a listen-active state. Finally the string of characters, text, is sent to the device with a newline character and with the EOI line asserted after the final character. - - Synopsis: - ret = GPIBSend(id, address, text) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The GPIB address to send data to - text - The data to send - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data sent. - DRV_P3INVALID - Invalid pointer (e.g. NULL). The GPIB device may return other errors. Consult the help documentation supplied with these devices. - - C++ Equiv: - unsigned int GPIBSend(int id, short address, char * text); - - See Also: - GPIBReceive - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = text - ret = self.dll.GPIBSend(cid, caddress, ctext) - return (ret) - - def I2CBurstRead(self, i2cAddress, nBytes): - ''' - Description: - This function will read a specified number of bytes from a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstRead(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to read from. - nBytes - The number of bytes to read from the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data read from the device. - - C++ Equiv: - unsigned int I2CBurstRead(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstWrite I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstRead(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CBurstWrite(self, i2cAddress, nBytes): - ''' - Description: - This function will write a specified number of bytes to a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstWrite(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to write to. - nBytes - The number of bytes to write to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data to write to the device. - - C++ Equiv: - unsigned int I2CBurstWrite(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstRead I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstWrite(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CRead(self, deviceID, intAddress): - ''' - Description: - This function will read a single byte from the chosen device. - - Synopsis: - (ret, pdata) = I2CRead(deviceID, intAddress) - - Inputs: - deviceID - The device to read from. - intAddress - The internal address of the device to be read from. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - pdata - The byte read from the device. - - C++ Equiv: - unsigned int I2CRead(BYTE deviceID, BYTE intAddress, BYTE * pdata); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cpdata = c_ubyte() - ret = self.dll.I2CRead(cdeviceID, cintAddress, byref(cpdata)) - return (ret, cpdata.value) - - def I2CReset(self): - ''' - Description: - This function will reset the I2C data bus. - - Synopsis: - ret = I2CReset() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Reset successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CReset(void); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite - - ''' - ret = self.dll.I2CReset() - return (ret) - - def I2CWrite(self, deviceID, intAddress, data): - ''' - Description: - This function will write a single byte to the chosen device. - - Synopsis: - ret = I2CWrite(deviceID, intAddress, data) - - Inputs: - deviceID - The device to write to. - intAddress - The internal address of the device to write to. - data - The byte to be written to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CWrite(BYTE deviceID, BYTE intAddress, BYTE data); - - See Also: - I2CBurstWrite I2CBurstRead I2CRead I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cdata = c_ubyte(data) - ret = self.dll.I2CWrite(cdeviceID, cintAddress, cdata) - return (ret) - - def IdAndorDll(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = IdAndorDll() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int IdAndorDll(void); - - ''' - ret = self.dll.IdAndorDll() - return (ret) - - def InAuxPort(self, port): - ''' - Description: - This function returns the state of the TTL Auxiliary Input Port on the Andor plug-in card. - - Synopsis: - (ret, state) = InAuxPort(port) - - Inputs: - port - Number of AUX in port on Andor card. Valid Values: 1 to 4 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX read. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - state - current state of port: - 0 - OFF/LOW - all others - ON/HIGH - - C++ Equiv: - unsigned int InAuxPort(int port, int * state); - - See Also: - OutAuxPort - - ''' - cport = c_int(port) - cstate = c_int() - ret = self.dll.InAuxPort(cport, byref(cstate)) - return (ret, cstate.value) - - def Initialize(self, dir): - ''' - Description: - This function will initialize the Andor SDK System. As part of the initialization procedure on some cameras (i.e. Classic, iStar and earlier iXion) the DLL will need access to a DETECTOR.INI which contains information relating to the detector head, number pixels, readout speeds etc. If your system has multiple cameras then see the section Controlling multiple cameras - - Synopsis: - ret = Initialize(dir) - - Inputs: - dir - Path to the directory containing the files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_VXDNOTINSTALLED - Initialisation successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ERROR_FILELOAD - Unable to load *.COF or *.RBF files. - DRV_ERROR_PAGELOCK - Unable to acquire lock on requested memory. - DRV_USBERROR - Unable to detect USB device or not USB2.0. - DRV_ERROR_NOCAMERA - No camera found - - C++ Equiv: - unsigned int Initialize(char * dir); - - See Also: - GetAvailableCameras SetCurrentCamera GetCurrentCamera - - ''' - cdir = dir - ret = self.dll.Initialize(cdir) - return (ret) - - def InitializeDevice(self, dir): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = InitializeDevice(dir) - - Inputs: - dir - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int InitializeDevice(char * dir); - - ''' - cdir = dir - ret = self.dll.InitializeDevice(cdir) - return (ret) - - def IsAmplifierAvailable(self, iamp): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified amplifier. - - Synopsis: - ret = IsAmplifierAvailable(iamp) - - Inputs: - iamp - amplifier to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplifier available - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_AMPLIFIER - Not a valid amplifier - - C++ Equiv: - unsigned int IsAmplifierAvailable(int iamp); - - See Also: - SetHSSpeed - - ''' - ciamp = c_int(iamp) - ret = self.dll.IsAmplifierAvailable(ciamp) - return (ret) - - def IsCoolerOn(self): - ''' - Description: - This function checks the status of the cooler. - - Synopsis: - (ret, iCoolerStatus) = IsCoolerOn() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Parameter is NULL - iCoolerStatus - iCoolerStatus0: Cooler is OFF.: - 1 - 1 Cooler is ON. - - C++ Equiv: - unsigned int IsCoolerOn(int * iCoolerStatus); - - See Also: - CoolerON CoolerOFF - - ''' - ciCoolerStatus = c_int() - ret = self.dll.IsCoolerOn(byref(ciCoolerStatus)) - return (ret, ciCoolerStatus.value) - - def IsCountConvertModeAvailable(self, mode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified Count Convert mode. - - Synopsis: - ret = IsCountConvertModeAvailable(mode) - - Inputs: - mode - Count Convert mode to be checked - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode available. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - DRV_INVALID_COUNTCONVERT_MODE - Count Convert mode not available with current acquisition settings - - C++ Equiv: - unsigned int IsCountConvertModeAvailable(int mode); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cmode = c_int(mode) - ret = self.dll.IsCountConvertModeAvailable(cmode) - return (ret) - - def IsInternalMechanicalShutter(self): - ''' - Description: - This function checks if an iXon camera has a mechanical shutter installed. - - - Synopsis: - (ret, internalShutter) = IsInternalMechanicalShutter() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Internal shutter state returned - DRV_NOT_AVAILABLE - Not an iXon Camera - DRV_P1INVALID - Parameter is NULL - internalShutter - Status of internal shutter: - 0 - Mechanical shutter not installed. - 1 - Mechanical shutter installed. - - C++ Equiv: - unsigned int IsInternalMechanicalShutter(int * internalShutter); - - Note: Available only on iXon - - ''' - cinternalShutter = c_int() - ret = self.dll.IsInternalMechanicalShutter(byref(cinternalShutter)) - return (ret, cinternalShutter.value) - - def IsPreAmpGainAvailable(self, channel, amplifier, index, pa): - ''' - Description: - This function checks that the AD channel exists, and that the amplifier, speed and gain are available for the AD channel. - - Synopsis: - (ret, status) = IsPreAmpGainAvailable(channel, amplifier, index, pa) - - Inputs: - channel - AD channel index. - amplifier - Type of output amplifier. - index - Channel speed index. - pa - PreAmpGain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - PreAmpGain status returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - status - PreAmpGain Status: - 0 - PreAmpGain not available. - 1 - PreAmpGain available. - - C++ Equiv: - unsigned int IsPreAmpGainAvailable(int channel, int amplifier, int index, int pa, int * status); - - See Also: - GetNumberPreAmpGains GetPreAmpGain SetPreAmpGain - - Note: Available only on iXon. - - ''' - cchannel = c_int(channel) - camplifier = c_int(amplifier) - cindex = c_int(index) - cpa = c_int(pa) - cstatus = c_int() - ret = self.dll.IsPreAmpGainAvailable(cchannel, camplifier, cindex, cpa, byref(cstatus)) - return (ret, cstatus.value) - - def IsTriggerModeAvailable(self, iTriggerMode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified trigger mode. - - Synopsis: - ret = IsTriggerModeAvailable(iTriggerMode) - - Inputs: - iTriggerMode - Trigger mode to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode available - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Not a valid mode - - C++ Equiv: - unsigned int IsTriggerModeAvailable(int iTriggerMode); - - See Also: - SetTriggerMode - - ''' - ciTriggerMode = c_int(iTriggerMode) - ret = self.dll.IsTriggerModeAvailable(ciTriggerMode) - return (ret) - - def Merge(self, nOrder, nPoint, nPixel, fit, hbin): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr, coeff, output, start, step_Renamed) = Merge(nOrder, nPoint, nPixel, fit, hbin) - - Inputs: - nOrder - - nPoint - - nPixel - - fit - - hbin - - - Outputs: - ret - Function Return Code - arr - - coeff - - output - - start - - step_Renamed - - - C++ Equiv: - unsigned int Merge(const at_32 * arr, long nOrder, long nPoint, long nPixel, float * coeff, long fit, long hbin, at_32 * output, float * start, float * step_Renamed); - - ''' - carr = c_int() - cnOrder = c_int(nOrder) - cnPoint = c_int(nPoint) - cnPixel = c_int(nPixel) - ccoeff = c_float() - cfit = c_int(fit) - chbin = c_int(hbin) - coutput = c_int() - cstart = c_float() - cstep_Renamed = c_float() - ret = self.dll.Merge(byref(carr), cnOrder, cnPoint, cnPixel, byref(ccoeff), cfit, chbin, byref(coutput), byref(cstart), byref(cstep_Renamed)) - return (ret, carr.value, ccoeff.value, coutput.value, cstart.value, cstep_Renamed.value) - - def OA_AddMode(self, uiModeNameLen, pcModeDescription, uiModeDescriptionLen): - ''' - Description: - This function will add a mode name and description to memory. Note that this will not add the mode to file, a subsequent call to OA_WriteToFile must be made. - - Synopsis: - (ret, pcModeName) = OA_AddMode(uiModeNameLen, pcModeDescription, uiModeDescriptionLen) - - Inputs: - uiModeNameLen - Mode name string length. - pcModeDescription - A description of the user defined mode. - uiModeDescriptionLen - Mode Description string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_P1INVALID DRV_P3INVALID DRV_OA_INVALID_STRING_LENGTH - All parameters accepted Null mode name. Null mode description. One or more parameters have an invalid length, i.e. > 255. - DRV_OA_INVALID_NAMING - Mode and description have the same name, this is not valid. - DRV_OA_MODE_BUFFER_FULL DRV_OA_INVALID_CHARS_IN_NAME - Number of modes exceeds limit. Mode name and/or description contain invalid characters. - DRV_OA_MODE_ALREADY_EXISTS - Mode name already exists in the file. - DRV_OA_INVALID_CHARS_IN_NAME - Invalid charcters in Mode Name or Mode Description - pcModeName - A name for the mode to be defined. - - C++ Equiv: - unsigned int OA_AddMode(char * pcModeName, int uiModeNameLen, char * pcModeDescription, int uiModeDescriptionLen); - - See Also: - OA_DeleteMode OA_WriteToFile - - ''' - cpcModeName = create_string_buffer(uiModeNameLen) - cuiModeNameLen = c_int(uiModeNameLen) - cpcModeDescription = pcModeDescription - cuiModeDescriptionLen = c_int(uiModeDescriptionLen) - ret = self.dll.OA_AddMode(cpcModeName, cuiModeNameLen, cpcModeDescription, cuiModeDescriptionLen) - return (ret, cpcModeName) - - def OA_DeleteMode(self, pcModeName, uiModeNameLen): - ''' - Description: - This function will remove a mode from memory. To permanently remove a mode from file, call OA_WriteToFile after OA_DeleteMode. The Preset file will not be affected. - - Synopsis: - ret = OA_DeleteMode(pcModeName, uiModeNameLen) - - Inputs: - pcModeName - The name of the mode to be removed. - uiModeNameLen - Mode name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DRV_OA_MODE_DOES_NOT_EXIST - DRV_P1INVALID - All parameters accepted Null mode name. - DRV_OA_INVALID_STRING_LENGTH - The mode name parameter has an invalid length, i.e. > 256. - - C++ Equiv: - unsigned int OA_DeleteMode(const char * pcModeName, int uiModeNameLen); - - See Also: - OA_AddMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cuiModeNameLen = c_int(uiModeNameLen) - ret = self.dll.OA_DeleteMode(cpcModeName, cuiModeNameLen) - return (ret) - - def OA_EnableMode(self, pcModeName): - ''' - Description: - This function will set all the parameters associated with the specified mode to be used for all subsequent acquisitions. The mode specified by the user must be in either the Preset file or the User defined file. - - Synopsis: - ret = OA_EnableMode(pcModeName) - - Inputs: - pcModeName - The mode to be used for all subsequent acquisitions. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode name. - DRV_OA_MODE_DOES_NOT_EXIST - Mode name does not exist. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - - C++ Equiv: - unsigned int OA_EnableMode(const char * pcModeName); - - See Also: - OA_AddMode - - ''' - cpcModeName = pcModeName - ret = self.dll.OA_EnableMode(cpcModeName) - return (ret) - - def OA_GetFloat(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for floating point type acquisition parameters. - Values are retrieved from memory for the specified mode name. - - Synopsis: - (ret, fFloatValue) = OA_GetFloat(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode parameter. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null float value. - fFloatValue - The value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetFloat(const char * pcModeName, const char * pcModeParam, float * fFloatValue); - - See Also: - OA_SetFloat - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float() - ret = self.dll.OA_GetFloat(cpcModeName, cpcModeParam, byref(cfFloatValue)) - return (ret, cfFloatValue.value) - - def OA_GetInt(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for integer type acquisition parameters. Values are retrieved from memory for the specified mode name. - - - Synopsis: - (ret, iintValue) = OA_GetInt(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter - pcModeParam - The name of the acquisition parameter for which a value - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null integer value. - iintValue - The buffer to return the value of the acquisition. - - C++ Equiv: - unsigned int OA_GetInt(const char * pcModeName, const char * pcModeParam, int * iintValue); - - See Also: - OA_SetInt - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int() - ret = self.dll.OA_GetInt(cpcModeName, cpcModeParam, byref(ciintValue)) - return (ret, ciintValue.value) - - def OA_GetModeAcqParams(self, pcModeName): - ''' - Description: - This function will return all acquisition parameters associated with the specified mode. The mode specified by the user must be in either the Preset file or the User defined file. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfParams) = OA_GetModeAcqParams(pcModeName) - - Inputs: - pcModeName - The mode for which all acquisition parameters must be returned. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_NO_USER_DATA - No data for selected mode. - pcListOfParams - A user allocated array of characters for storage of the acquisition parameters. Parameters will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetModeAcqParams(const char * pcModeName, char * pcListOfParams); - - See Also: - OA_GetNumberOfAcqParams - - ''' - cpcModeName = pcModeName - cpcListOfParams = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetModeAcqParams(cpcModeName, cpcListOfParams) - return (ret, cpcListOfParams) - - def OA_GetNumberOfAcqParams(self, pcModeName): - ''' - Description: - This function will return the parameters associated with a specified mode. The mode must be present in either the Preset file or the User defined file. - - Synopsis: - (ret, puiNumberOfParams) = OA_GetNumberOfAcqParams(pcModeName) - - Inputs: - pcModeName - The mode to search for a list of acquisition parameters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null number of parameters. - DRV_OA_NULL_ERROR - Invalid pointer. - puiNumberOfParams - The number of acquisition parameters for the specified mode. - - C++ Equiv: - unsigned int OA_GetNumberOfAcqParams(const char * pcModeName, unsigned int * puiNumberOfParams); - - See Also: - OA_GetModeAcqParams - - ''' - cpcModeName = pcModeName - cpuiNumberOfParams = c_uint() - ret = self.dll.OA_GetNumberOfAcqParams(cpcModeName, byref(cpuiNumberOfParams)) - return (ret, cpuiNumberOfParams.value) - - def OA_GetNumberOfPreSetModes(self): - ''' - Description: - This function will return the number of modes defined in the Preset file. The Preset file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfPreSetModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the Andor file. - - C++ Equiv: - unsigned int OA_GetNumberOfPreSetModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetPreSetModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfPreSetModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetNumberOfUserModes(self): - ''' - Description: - This function will return the number of modes defined in the User file. The user defined file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfUserModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the user file. - - C++ Equiv: - unsigned int OA_GetNumberOfUserModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetUserModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfUserModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetPreSetModeNames(self): - ''' - Description: - This function will return the available mode names from the Preset file. The mode and the Preset file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetPreSetModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetPreSetModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfPreSetModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetPreSetModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_GetString(self, pcModeName, pcModeParam, uiStringLen): - ''' - Description: - This function is used to get the values for string type acquisition parameters. Values - are retrieved from memory for the specified mode name. - - Synopsis: - (ret, pcStringValue) = OA_GetString(pcModeName, pcModeParam, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - uiStringLen - The length of the buffer. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - pcStringValue - The buffer to return the value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_SetString - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = create_string_buffer(uiStringLen) - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_GetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret, cpcStringValue) - - def OA_GetUserModeNames(self): - ''' - Description: - This function will return the available mode names from a User defined file. The mode and the User defined file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetUserModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetUserModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfUserModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetUserModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_Initialize(self, pcFilename, uiFileNameLen): - ''' - Description: - This function will initialise the OptAcquire settings from a Preset file and a User defined file if it exists. - - Synopsis: - ret = OA_Initialize(pcFilename, uiFileNameLen) - - Inputs: - pcFilename - The name of a user xml file. If the file exists then data will be read from the file. If the file does not exist the file name may be used when the user calls WriteToFile(). - uiFileNameLen - The length of the filename. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - DRV_OA_GET_CAMERA_ERROR - Unable to retrieve information about the - DRV_OA_INVALID_STRING_LENGTH - model of the Camera. - DRV_OA_ANDOR_FILE_NOT_LOADED - The parameter has an invalid length, i.e. > 255. - DRV_OA_USER_FILE_NOT_LOADED - Preset Andor file failed to load. - DRV_OA_FILE_ACCESS_ERROR - Supplied User file failed to load. - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED - Failed to determine status of file. - - C++ Equiv: - unsigned int OA_Initialize(const char * pcFilename, int uiFileNameLen); - - See Also: - OA_WriteToFile - - ''' - cpcFilename = pcFilename - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_Initialize(cpcFilename, cuiFileNameLen) - return (ret) - - def OA_SetFloat(self, pcModeName, pcModeParam, fFloatValue): - ''' - Description: - This function is used to set values for floating point type acquisition parameters where - the new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetFloat(pcModeName, pcModeParam, fFloatValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - fFloatValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetFloat(const char * pcModeName, const char * pcModeParam, const float fFloatValue); - - See Also: - OA_GetFloat OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float(fFloatValue) - ret = self.dll.OA_SetFloat(cpcModeName, cpcModeParam, cfFloatValue) - return (ret) - - def OA_SetInt(self, pcModeName, pcModeParam, iintValue): - ''' - Description: - This function is used to set values for integer type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetInt(pcModeName, pcModeParam, iintValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - iintValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetInt(const char * pcModeName, const char * pcModeParam, const int iintValue); - - See Also: - OA_GetInt OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int(iintValue) - ret = self.dll.OA_SetInt(cpcModeName, cpcModeParam, ciintValue) - return (ret) - - def OA_SetString(self, pcModeName, pcModeParam, pcStringValue, uiStringLen): - ''' - Description: - This function is used to set values for string type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetString(pcModeName, pcModeParam, pcStringValue, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter is to be edited. - pcModeParam - The name of the acquisition parameter to be edited. - pcStringValue - The value to assign to the acquisition parameter. - uiStringLen - The length of the input string. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_GetString OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = pcStringValue - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_SetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret) - - def OA_WriteToFile(self, pcFileName, uiFileNameLen): - ''' - Description: - This function will write a User defined list of modes to the User file. The Preset file will not be affected. - - Synopsis: - ret = OA_WriteToFile(pcFileName, uiFileNameLen) - - Inputs: - pcFileName - The name of the file to be written to. - uiFileNameLen - File name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_INVALID_FILE - Data cannot be written to the Preset Andor file. - DRV_ERROR_FILESAVE - Failed to save data to file. - DRV_OA_FILE_HAS_BEEN_MODIFIED - File to be written to has been modified since last write, local copy of file may not be the same. - DRV_OA_INVALID_CHARS_IN_NAME - File name contains invalid characters. - - C++ Equiv: - unsigned int OA_WriteToFile(const char * pcFileName, int uiFileNameLen); - - See Also: - OA_AddMode OA_DeleteMode - - ''' - cpcFileName = pcFileName - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_WriteToFile(cpcFileName, cuiFileNameLen) - return (ret) - - def OutAuxPort(self, port, state): - ''' - Description: - This function sets the TTL Auxiliary Output port (P) on the Andor plug-in card to either ON/HIGH or OFF/LOW. - - Synopsis: - ret = OutAuxPort(port, state) - - Inputs: - port - Number of AUX out port on Andor card: - 1 - to 4 - state - state to put port in: - 0 - OFF/LOW - all - others ON/HIGH - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX port set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - - C++ Equiv: - unsigned int OutAuxPort(int port, int state); - - See Also: - InAuxPort - - ''' - cport = c_int(port) - cstate = c_int(state) - ret = self.dll.OutAuxPort(cport, cstate) - return (ret) - - def PostProcessCountConvert(self, iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to either Photons or Electrons based on the mode selected by the user. The input data should be in counts. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessCountConvert(iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The size of the output buffer.: - data - data - iNumImages - The number of images if a kinetic series is supplied as the input - iBaseline - The baseline associated with the image.: - 1 - - Convert to Electrons - 2 - - Convert to Photons - iMode - The mode to use to process the data. - iEmGain - The gain level of the input image. - fQE - The Quantum Efficiency of the sensor. - fSensitivity - The Sensitivity value used to acquire the image. - iHeight - The height of the image. - iWidth - The width of the image. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Number of images less than zero. - DRV_P5INVALID - Baseline less than zero. - DRV_P6INVALID - Invalid count convert mode. - DRV_P7INVALID - EMGain less than zero. - DRV_P8INVALID DRV_P9INVALID - QE less than zero. - DRV_P10INVALID - Sensitivity less than zero. - DRV_P11INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The output buffer to return the processed image. - - C++ Equiv: - unsigned int PostProcessCountConvert(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iBaseline, int iMode, int iEmGain, float fQE, float fSensitivity, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - ciEmGain = c_int(iEmGain) - cfQE = c_float(fQE) - cfSensitivity = c_float(fSensitivity) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessCountConvert(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciBaseline, ciMode, ciEmGain, cfQE, cfSensitivity, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessDataAveraging(self, iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessDataAveraging(iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor) - - Inputs: - iOutputBufferSize - - iNumImages - - iAveragingFilterMode - - iHeight - - iWidth - - iFrameCount - - iAveragingFactor - - - Outputs: - ret - Function Return Code - pInputImage - - pOutputImage - - - C++ Equiv: - unsigned int PostProcessDataAveraging(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iAveragingFilterMode, int iHeight, int iWidth, int iFrameCount, int iAveragingFactor); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciAveragingFilterMode = c_int(iAveragingFilterMode) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ciFrameCount = c_int(iFrameCount) - ciAveragingFactor = c_int(iAveragingFactor) - ret = self.dll.PostProcessDataAveraging(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciAveragingFilterMode, ciHeight, ciWidth, ciFrameCount, ciAveragingFactor) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessNoiseFilter(self, iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth): - ''' - Description: - This function will apply a filter to the input image and return the processed image in the output buffer. The filter applied is chosen by the user by setting Mode to a permitted value. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessNoiseFilter(iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The baseline associated with the image. - iBaseline - The mode to use to process the data.: - 1 - Use Median Filter. - 2 - Use Level Above Filter. - 3 - Use interquartile Range Filter. - 4 - Use Noise Threshold Filter. - iMode - This is the Threshold multiplier for the Median, interquartile: - and - Noise Threshold filters. For the Level Above filter this is - Threshold - count above the baseline. - fThreshold - The height of the image. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_SUPPORTED DRV_NOT_INITIALIZED - Camera does not support Noise filter processing. System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Baseline less than zero. - DRV_P5INVALID - Invalid Filter mode. - DRV_P6INVALID - Threshold value not valid for selected mode. - DRV_P7INVALID - Height less than zero. - DRV_P8INVALID DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - - C++ Equiv: - unsigned int PostProcessNoiseFilter(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iBaseline, int iMode, float fThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - cfThreshold = c_float(fThreshold) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessNoiseFilter(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciBaseline, ciMode, cfThreshold, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessPhotonCounting(self, iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to photons and return the processed image in the output buffer. - - Synopsis: - (ret, pInputImage, pOutputImage, pfThreshold) = PostProcessPhotonCounting(iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The number of images if a kinetic series is supplied as the input: - data - data - iNumImages - The number of frames per output image. - iNumframes - The number of thresholds provided by the user. - iNumberOfThresholds - The Thresholds used to define a photon. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_NOT_INITIALIZED - Acquisition prepared. - DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Number of images less than zero. - DRV_P6INVALID - Invalid Number of Frames requested. - DRV_P7INVALID - Invalid number of thresholds. - DRV_P8INVALID - Invalid pointer (i.e. NULL). - DRV_P9INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - pfThreshold - The height of the image. - - C++ Equiv: - unsigned int PostProcessPhotonCounting(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iNumframes, int iNumberOfThresholds, float * pfThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciNumframes = c_int(iNumframes) - ciNumberOfThresholds = c_int(iNumberOfThresholds) - cpfThreshold = c_float() - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessPhotonCounting(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciNumframes, ciNumberOfThresholds, byref(cpfThreshold), ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value, cpfThreshold.value) - - def PrepareAcquisition(self): - ''' - Description: - This function reads the current acquisition setup and allocates and configures any memory that will be used during the acquisition. The function call is not required as it will be called automatically by the StartAcquisition function if it has not already been called externally. - However for long kinetic series acquisitions the time to allocate and configure any memory can be quite long which can result in a long delay between calling StartAcquisition and the acquisition actually commencing. For iDus, there is an additional delay caused by the camera being set-up with any new acquisition parameters. Calling PrepareAcquisition first will reduce this delay in the StartAcquisition call. - - Synopsis: - ret = PrepareAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_IOCERROR - integrate On Chip setup error. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int PrepareAcquisition(void); - - See Also: - StartAcquisition FreeInternalMemory - - ''' - ret = self.dll.PrepareAcquisition() - return (ret) - - def SaveAsBmp(self, path, palette, ymin, ymax): - ''' - Description: - This function saves the last acquisition as a bitmap file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the bitmap. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The ymin and ymax parameters indicate which data values will map to the first and last colors in the palette: - * All data values below or equal to ymin will be colored with the first color. - * All values above or equal to ymax will be colored with the last color - * All other palette colors will be scaled across values between these limits. - - Synopsis: - ret = SaveAsBmp(path, palette, ymin, ymax) - - Inputs: - path - The filename of the bitmap. - palette - The filename of a palette file (.PAL) for applying color to the bitmap. - ymin - Min data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - ymax - Max data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as bitmap. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsBmp(const char * path, const char * palette, long ymin, long ymax); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff - - Note: If the last acquisition was in Kinetic Series mode, each image will be saved in a separate Bitmap file. The filename specified will have an index number appended to it, indicating the position in the series. - - ''' - cpath = path - cpalette = palette - cymin = c_int(ymin) - cymax = c_int(ymax) - ret = self.dll.SaveAsBmp(cpath, cpalette, cymin, cymax) - return (ret) - - def SaveAsCommentedSif(self, path, comment): - ''' - Description: - This function will save the data from the last acquisition into a file. The comment text will be added to the user text portion of the Sif file. - - Synopsis: - ret = SaveAsCommentedSif(path, comment) - - Inputs: - path - pointer to a filename specified by the user. - comment - comment text to add to the sif file - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - - C++ Equiv: - unsigned int SaveAsCommentedSif(char * path, char * comment); - - See Also: - SetSifComment SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment - - Note: The comment used in SIF files created with this function is discarded once the call completes, i.e. future calls to SaveAsSif will not use this comment. To set a persistent comment use the SetSifComment function. - - ''' - cpath = path - ccomment = comment - ret = self.dll.SaveAsCommentedSif(cpath, ccomment) - return (ret) - - def SaveAsEDF(self, szPath, iMode): - ''' - Description: - This function saves the last acquisition in the European Synchotron Radiation Facility Data Format (*.edf). - - Synopsis: - ret = SaveAsEDF(szPath, iMode) - - Inputs: - szPath - the filename to save to. - iMode - option to save to multiple files.: - 0 - Save to 1 file - 1 - Save kinetic series to multiple files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsEDF(char * szPath, int iMode); - - See Also: - SaveAsSif SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszPath = szPath - ciMode = c_int(iMode) - ret = self.dll.SaveAsEDF(cszPath, ciMode) - return (ret) - - def SaveAsFITS(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition in the FITS (Flexible Image Transport System) Data Format (*.fits) endorsed by NASA. - - Synopsis: - ret = SaveAsFITS(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 0 - Unsigned 16 - 1 - Unsigned 32 - 2 - Signed 16 - 3 - Signed 32 - 4 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsFITS(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsFITS(cszFileTitle, ctyp) - return (ret) - - def SaveAsRaw(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition as a raw data file. - - Synopsis: - ret = SaveAsRaw(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 1 - Signed 16 - 2 - Signed 32 - 3 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsRaw(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsRaw(cszFileTitle, ctyp) - return (ret) - - def SaveAsSif(self, path): - ''' - Description: - This function will save the data from the last acquisition into a file, which can be read in by the main application. User text can be added to sif files using the SaveAsCommentedSif and SetSifComment functions. - - Synopsis: - ret = SaveAsSif(path) - - Inputs: - path - pointer to a filename specified by the user. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSif(char * path); - - See Also: - SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment SaveAsCommentedSif - - ''' - cpath = path - ret = self.dll.SaveAsSif(cpath) - return (ret) - - def SaveAsSPC(self, path): - ''' - Description: - This function saves the last acquisition in the GRAMS .spc file format - - Synopsis: - ret = SaveAsSPC(path) - - Inputs: - path - the filename to save too. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSPC(char * path); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsTiff SaveAsBmp - - ''' - cpath = path - ret = self.dll.SaveAsSPC(cpath) - return (ret) - - def SaveAsTiff(self, path, palette, position, typ): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively - - Synopsis: - ret = SaveAsTiff(path, palette, position, typ) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsTiff(char * path, char * palette, int position, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsBmp SaveAsTiffEx SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - ret = self.dll.SaveAsTiff(cpath, cpalette, cposition, ctyp) - return (ret) - - def SaveAsTiffEx(self, path, palette, position, typ, mode): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. This is an extended version of the SaveAsTiff function. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively. The mode parameter specifies the mode of output. Data can be output scaled from the min and max count values across the entire range of values (mode 0) or can remain unchanged (mode 1).Of course if the count value is higher or lower than the output data range then even in mode 1 data will be scaled. - - Synopsis: - ret = SaveAsTiffEx(path, palette, position, typ, mode) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - mode - The output mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_P5INVALID - mode not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsTiffEx(char * path, char * palette, int position, int typ, int mode); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - cmode = c_int(mode) - ret = self.dll.SaveAsTiffEx(cpath, cpalette, cposition, ctyp, cmode) - return (ret) - - def SaveEEPROMToFile(self, cFileName): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveEEPROMToFile(cFileName) - - Inputs: - cFileName - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveEEPROMToFile(char * cFileName); - - ''' - ccFileName = cFileName - ret = self.dll.SaveEEPROMToFile(ccFileName) - return (ret) - - def SaveToClipBoard(self, palette): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveToClipBoard(palette) - - Inputs: - palette - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveToClipBoard(char * palette); - - ''' - cpalette = palette - ret = self.dll.SaveToClipBoard(cpalette) - return (ret) - - def SelectDevice(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SelectDevice(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SelectDevice(int devNum); - - ''' - cdevNum = c_int(devNum) - ret = self.dll.SelectDevice(cdevNum) - return (ret) - - def SendSoftwareTrigger(self): - ''' - Description: - This function sends an event to the camera to take an acquisition when in Software Trigger mode. Not all cameras have this mode available to them. To check if your camera can operate in this mode check the GetCapabilities function for the Trigger Mode AC_TRIGGERMODE_CONTINUOUS. If this mode is physically possible and other settings are suitable (IsTriggerModeAvailable) and the camera is acquiring then this command will take an acquisition. - - Synopsis: - ret = SendSoftwareTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger sent - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - Not in SoftwareTrigger mode - DRV_IDLE - Not Acquiring - DRV_ERROR_CODES - Error communicating with camera - DRV_ERROR_ACK - Previous acquisition not complete - - C++ Equiv: - unsigned int SendSoftwareTrigger(void); - - See Also: - GetCapabilities IsTriggerModeAvailable SetAcquisitionMode SetReadMode SetTriggerMode - - Note: The settings of the camera must be as follows: - ReadOut mode is full image - RunMode is Run Till Abort - TriggerMode is 10 - - - - - ''' - ret = self.dll.SendSoftwareTrigger() - return (ret) - - def SetAccumulationCycleTime(self, time): - ''' - Description: - This function will set the accumulation cycle time to the nearest valid value not less than the given value. The actual cycle time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetAccumulationCycleTime(time) - - Inputs: - time - the accumulation cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure time invalid. - - C++ Equiv: - unsigned int SetAccumulationCycleTime(float time); - - See Also: - SetNumberAccumulations GetAcquisitionTimings - - ''' - ctime = c_float(time) - ret = self.dll.SetAccumulationCycleTime(ctime) - return (ret) - - def SetAcqStatusEvent(self, statusEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the camera has started exposing or that the camera has finished exposing. To determine what event has actually occurred call the GetCameraEventStatus funtion. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. The SetPCIMode function must be called to enable/disable the events from the driver. - - Synopsis: - ret = SetAcqStatusEvent(statusEvent) - - Inputs: - statusEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetAcqStatusEvent(at_32 statusEvent); - - See Also: - GetCameraEventStatus SetPCIMode - - Note: This is only available with the CCI23 PCI card. - - ''' - cstatusEvent = c_int(statusEvent) - ret = self.dll.SetAcqStatusEvent(cstatusEvent) - return (ret) - - def SetAcquisitionMode(self, mode): - ''' - Description: - This function will set the acquisition mode to be used on the next StartAcquisitionStartAcquisition. - - Synopsis: - ret = SetAcquisitionMode(mode) - - Inputs: - mode - the acquisition mode.: - 1 - Single Scan - 2 - Accumulate - 3 - Kinetics - 4 - Fast Kinetics - 5 - Run till abort - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid. - - C++ Equiv: - unsigned int SetAcquisitionMode(int mode); - - See Also: - StartAcquisition - - Note: In Mode 5 the system uses a Run Till Abort acquisition mode. In Mode 5 only, the camera continually acquires data until the AbortAcquisitionAbortAcquisition function is called. By using the SetDriverEventSetDriverEvent function you will be notified as each acquisition is completed. - - ''' - cmode = c_int(mode) - ret = self.dll.SetAcquisitionMode(cmode) - return (ret) - - def SetAcquisitionType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetAcquisitionType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetAcquisitionType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetAcquisitionType(ctyp) - return (ret) - - def SetADChannel(self, channel): - ''' - Description: - This function will set the AD channel to one of the possible A-Ds of the system. This AD channel will be used for all subsequent operations performed by the system. - - Synopsis: - ret = SetADChannel(channel) - - Inputs: - channel - the channel to be used 0 to GetNumberADChannelsGetNumberADChannels-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AD channel set. - DRV_P1INVALID - Index is out of range. - - C++ Equiv: - unsigned int SetADChannel(int channel); - - See Also: - GetNumberADChannels - - ''' - cchannel = c_int(channel) - ret = self.dll.SetADChannel(cchannel) - return (ret) - - def SetAdvancedTriggerModeState(self, iState): - ''' - Description: - This function will set the state for the iCam functionality that some cameras are capable of. There may be some cases where we wish to prevent the software using the new functionality and just do it the way it was previously done. - - Synopsis: - ret = SetAdvancedTriggerModeState(iState) - - Inputs: - iState - 0: turn off iCam: - 1 - 1 Enable iCam. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - state invalid - - C++ Equiv: - unsigned int SetAdvancedTriggerModeState(int iState); - - See Also: - iCam - - Note: By default the advanced trigger functionality is enabled. - - ''' - ciState = c_int(iState) - ret = self.dll.SetAdvancedTriggerModeState(ciState) - return (ret) - - def SetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = SetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int SetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.SetBackground(byref(carr), csize) - return (ret, carr.value) - - def SetBaselineClamp(self, state): - ''' - Description: - This function turns on and off the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - ret = SetBaselineClamp(state) - - Inputs: - state - Enables/Disables Baseline clamp functionality: - 1 - Enable Baseline Clamp - 0 - Disable Baseline Clamp - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetBaselineClamp(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetBaselineClamp(cstate) - return (ret) - - def SetBaselineOffset(self, offset): - ''' - Description: - This function allows the user to move the baseline level by the amount selected. For example +100 will add approximately 100 counts to the default baseline value. The value entered should be a multiple of 100 between -1000 and +1000 inclusively. - - Synopsis: - ret = SetBaselineOffset(offset) - - Inputs: - offset - Amount to offset baseline by - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Baseline Clamp not available for this camera - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Offset out of range - - C++ Equiv: - unsigned int SetBaselineOffset(int offset); - - Note: Only available on iXon range - - ''' - coffset = c_int(offset) - ret = self.dll.SetBaselineOffset(coffset) - return (ret) - - def SetCameraLinkMode(self, mode): - ''' - Description: - This function allows the user to enable or disable the Camera Link functionality for the camera. Enabling this functionality will start to stream all acquired data through the camera link interface. - - Synopsis: - ret = SetCameraLinkMode(mode) - - Inputs: - mode - Enables/Disables Camera Link mode: - 1 - Enable Camera Link - 0 - Disable Camera Link - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - Camera Link not supported by this Camera - DRV_P1INVALID - Mode was not zero or one. - - C++ Equiv: - unsigned int SetCameraLinkMode(int mode); - - Note: Only available with iXon Ultra. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCameraLinkMode(cmode) - return (ret) - - def SetCameraStatusEnable(self, Enable): - ''' - Description: - Use this function to Mask out certain types of acquisition status events. The default is to notify on every type of event but this may cause missed events if different types of event occur very close together. The bits in the mask correspond to the following event types: - Use0 - Fire pulse down event - Use1 - Fire pulse up event - Set the corresponding bit to 0 to disable the event type and 1 to enable the event type. - - Synopsis: - ret = SetCameraStatusEnable(Enable) - - Inputs: - Enable - bitmask with bits set for those events about which you wish to be notified. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mask Set. - DRV_VXDNOTINSTALLED - Device Driver not installed. - - C++ Equiv: - unsigned int SetCameraStatusEnable(DWORD Enable); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: Only available with PCI systems using the CCI-23 controller card. - - Fire pulse up event not available on USB systems. - - - ''' - cEnable = (Enable) - ret = self.dll.SetCameraStatusEnable(cEnable) - return (ret) - - def SetChargeShifting(self, NumberRows, NumberRepeats): - ''' - Description: - Use this function in External Charge Shifting trigger mode to configure how many rows to shift and how many times for each frame of data. The number of repeats must be a multiple of 2. - - Synopsis: - ret = SetChargeShifting(NumberRows, NumberRepeats) - - Inputs: - NumberRows - number of rows to shift after each external trigger - NumberRepeats - number of times to shift rows - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Trigger mode not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of rows invalid. - DRV_P2INVALID - Number of repeats invalid. - - C++ Equiv: - unsigned int SetChargeShifting(unsigned int NumberRows, unsigned int NumberRepeats); - - See Also: - SetTriggerMode GetCapabilities - - Note: Only available with certain iKon-M systems. - - ''' - cNumberRows = c_uint(NumberRows) - cNumberRepeats = c_uint(NumberRepeats) - ret = self.dll.SetChargeShifting(cNumberRows, cNumberRepeats) - return (ret) - - def SetComplexImage(self, numAreas): - ''' - Description: - This is a function that allows the setting up of random tracks with more options that the SetRandomTracks function. - The minimum number of tracks is 1. The maximum number of tracks is the number of vertical pixels. - There is a further limit to the number of tracks that can be set due to memory constraints in the camera. It is not a fixed number but depends upon the combinations of the tracks. For example, 20 tracks of different heights will take up more memory than 20 tracks of the same height. - If attempting to set a series of random tracks and the return code equals DRV_RANDOM_TRACK_ERROR, change the makeup of the tracks to have more repeating heights and gaps so less memory is needed. - Each track must be defined by a group of six integers. - -The top and bottom positions of the tracks. - -The left and right positions for the area of interest within each track - -The horizontal and vertical binning for each track. - The positions of the tracks are validated to ensure that the tracks are in increasing order. - The left and right positions for each track must be the same. - For iXon the range is between 8 and CCD width, inclusive - For idus the range must be between 257 and CCD width, inclusive. - Horizontal binning must be an integer between 1 and 64 inclusive, for iXon. - Horizontal binning is not implementated for iDus and must be set to 1. - Vertical binning is used in the following way. A track of: - 1 10 1 1024 1 2 - is actually implemented as 5 tracks of height 2. . Note that a vertical binning of 1 will have the effect of vertically binning the entire track; otherwise vertical binning will operate as normal. - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 - - Synopsis: - (ret, areas) = SetComplexImage(numAreas) - - Inputs: - numAreas - int * areas: - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_RANDOM_TRACK_ERROR - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_ERROR_FILELOAD - Serious internal error - areas - - - C++ Equiv: - unsigned int SetComplexImage(int numAreas, int * areas); - - See Also: - SetRandomTracks - - Note: Only available with iXon+ and USB cameras. - - ''' - cnumAreas = c_int(numAreas) - careas = c_int() - ret = self.dll.SetComplexImage(cnumAreas, byref(careas)) - return (ret, careas.value) - - def SetCoolerMode(self, mode): - ''' - Description: - This function determines whether the cooler is switched off when the camera is shut down. - - Synopsis: - ret = SetCoolerMode(mode) - - Inputs: - mode - : - 0 - Returns to ambient temperature on ShutDown - 1 - Temperature is maintained on ShutDown - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - DRV_NOT_SUPPORTED - Camera does not support - - C++ Equiv: - unsigned int SetCoolerMode(int mode); - - Note: Mode 0 not available on Luca R cameras always cooled to -20C. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCoolerMode(cmode) - return (ret) - - def SetCountConvertMode(self, Mode): - ''' - Description: - This function configures the Count Convert mode. - - Synopsis: - ret = SetCountConvertMode(Mode) - - Inputs: - Mode - : - 0 - Data in Counts - 1 - Data in Electrons - 2 - Data in Photons - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Count Convert not available for this camera - DRV_NOT_AVAILABLE - Count Convert mode not available with current settings - DRV_P1INVALID - Mode parameter was out of range. - - C++ Equiv: - unsigned int SetCountConvertMode(int Mode); - - See Also: - GetCapabilities SetCountConvertWavelength - - Note: Only available on Clara, iXon 3 and iXon Ultra. - - Modes 1 and 2 are only available when: - * Baseline Clamp active - * Isolated crop mode off - * EM gain must be greater than or equal to 10 and the lowest pre-amp not be selected - * For Clara systems the extended infra red mode can not be used - - - ''' - cMode = c_int(Mode) - ret = self.dll.SetCountConvertMode(cMode) - return (ret) - - def SetCountConvertWavelength(self, wavelength): - ''' - Description: - This function configures the wavelength used in Count Convert mode. - - Synopsis: - ret = SetCountConvertWavelength(wavelength) - - Inputs: - wavelength - wavelength used to determine QE - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Count Convert not available for this camera - DRV_P1INVALID - Wavelength value was out of range. - - C++ Equiv: - unsigned int SetCountConvertWavelength(float wavelength); - - See Also: - GetCapabilities SetCountConvertMode - - ''' - cwavelength = c_float(wavelength) - ret = self.dll.SetCountConvertWavelength(cwavelength) - return (ret) - - def SetCropMode(self, active, cropHeight, reserved): - ''' - Description: - This function effectively reduces the height of the CCD by excluding some rows to achieve higher frame rates. This is currently only available on Newton cameras when the selected read mode is Full Vertical Binning. The cropHeight is the number of active rows measured from the bottom of the CCD. - Note: it is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetCropMode(active, cropHeight, reserved) - - Inputs: - active - Crop mode active: - 0 - Crop mode is OFF - 1 - Crop mode if ON - cropHeight - The selected crop height. This value must be between 1 and the CCD: - height - int reserved: This value should be set to 0. - reserved - This value should be set to 0 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIAILIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Active parameter is not zero or one. - DRV_P2INVALID - Cropheight parameter is less than one or greater than the CCD height. - DRV_P3INVALID - Reserved parameter is not equal to zero. - DRV_NOT_SUPPORTED - Either the camera is not a Newton or the read mode is not Full Vertical Binning. - - C++ Equiv: - unsigned int SetCropMode(int active, int cropHeight, int reserved); - - See Also: - GetDetector SetIsolatedCropMode - - Note: Available on Newton - - ''' - cactive = c_int(active) - ccropHeight = c_int(cropHeight) - creserved = c_int(reserved) - ret = self.dll.SetCropMode(cactive, ccropHeight, creserved) - return (ret) - - def SetCurrentCamera(self, cameraHandle): - ''' - Description: - When multiple Andor cameras are installed this function allows the user to select which camera is currently active. Once a camera has been selected the other functions can be called as normal but they will only apply to the selected camera. If only 1 camera is installed calling this function is not required since that camera will be selected by default. - - Synopsis: - ret = SetCurrentCamera(cameraHandle) - - Inputs: - cameraHandle - Selects the active camera - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera successfully selected. - DRV_P1INVALID - Invalid camera handle. - - C++ Equiv: - unsigned int SetCurrentCamera(long cameraHandle); - - See Also: - GetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.SetCurrentCamera(ccameraHandle) - return (ret) - - def SetCustomTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning value to be used when the readout mode is set to Random Track. - - Synopsis: - ret = SetCustomTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetCustomTrackHBin(int bin); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cbin = c_int(bin) - ret = self.dll.SetCustomTrackHBin(cbin) - return (ret) - - def SetDACOutput(self, iOption, iResolution, iValue): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to set the required voltage. - - Synopsis: - ret = SetDACOutput(iOption, iResolution, iValue) - - Inputs: - iOption - DAC Output DAC Pin 1 or 2 (1/2). - iResolution - resolution of DAC can be set from 2 to 16-bit in steps of 2 - iValue - requested DAC value (for particular resolution) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available. - DRV_P1INVALID - DAC range value invalid. - DRV_P2INVALID - Resolution unavailable. - DRV_P3INVALID - Requested value not within DAC range. - - C++ Equiv: - unsigned int SetDACOutput(int iOption, int iResolution, int iValue); - - See Also: - SetDACOutputScale - - Note: Only available on Andor Clara - - ''' - ciOption = c_int(iOption) - ciResolution = c_int(iResolution) - ciValue = c_int(iValue) - ret = self.dll.SetDACOutput(ciOption, ciResolution, ciValue) - return (ret) - - def SetDACOutputScale(self, iScale): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to select the active one. - - Synopsis: - ret = SetDACOutputScale(iScale) - - Inputs: - iScale - 5 or 10 volt DAC range (1/2). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available - DRV_P1INVALID - DAC Scale value invalid. - - C++ Equiv: - unsigned int SetDACOutputScale(int iScale); - - See Also: - SetDACOutput - - Note: Only available on Andor Clara - - ''' - ciScale = c_int(iScale) - ret = self.dll.SetDACOutputScale(ciScale) - return (ret) - - def SetDataType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDataType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDataType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetDataType(ctyp) - return (ret) - - def SetDDGAddress(self, t0, t1, t2, t3, address): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGAddress(t0, t1, t2, t3, address) - - Inputs: - t0 - - t1 - - t2 - - t3 - - address - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGAddress(BYTE t0, BYTE t1, BYTE t2, BYTE t3, BYTE address); - - ''' - ct0 = c_ubyte(t0) - ct1 = c_ubyte(t1) - ct2 = c_ubyte(t2) - ct3 = c_ubyte(t3) - caddress = c_ubyte(address) - ret = self.dll.SetDDGAddress(ct0, ct1, ct2, ct3, caddress) - return (ret) - - def SetDDGExternalOutputEnabled(self, uiIndex, uiEnabled): - ''' - Description: - This function sets the state of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputPolarity(self, uiIndex, uiPolarity): - ''' - Description: - This function sets the polarity of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputPolarity(uiIndex, uiPolarity) - - Inputs: - uiIndex - index of external output. - uiPolarity - polarity of external output (0 - Positive,1 - Negative). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 uiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputPolarity - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiPolarity = c_uint(uiPolarity) - ret = self.dll.SetDDGExternalOutputPolarity(cuiIndex, cuiPolarity) - return (ret) - - def SetDDGExternalOutputStepEnabled(self, uiIndex, uiEnabled): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to set the state of this option. - - Synopsis: - ret = SetDDGExternalOutputStepEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output track step (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputStepEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputStepEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputTime(self, uiIndex, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the timings for a particular external output. - - Synopsis: - ret = SetDDGExternalOutputTime(uiIndex, uiDelay, uiWidth) - - Inputs: - uiIndex - index of external output. - uiDelay - external output delay time in picoseconds. - uiWidth - external output width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGExternalOutputTime(at_u32 uiIndex, at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputTime - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGExternalOutputTime(cuiIndex, cuiDelay, cuiWidth) - return (ret) - - def SetDDGGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetDDGGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetDDGGain(cgain) - return (ret) - - def SetDDGGateStep(self, step): - ''' - Description: - This function will set a constant value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGGateStep(step) - - Inputs: - step - gate step in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step invalid. - - C++ Equiv: - unsigned int SetDDGGateStep(double step); - - See Also: - SetDDGTimes SetDDGVariableGateStep - - Note: Available on iStar. - - ''' - cstep = c_double(step) - ret = self.dll.SetDDGGateStep(cstep) - return (ret) - - def SetDDGGateTime(self, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the gate timings for a USB iStar. - - Synopsis: - ret = SetDDGGateTime(uiDelay, uiWidth) - - Inputs: - uiDelay - gate delay time in picoseconds. - uiWidth - gate width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGGateTime(at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGGateTime - - ''' - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGGateTime(cuiDelay, cuiWidth) - return (ret) - - def SetDDGInsertionDelay(self, state): - ''' - Description: - This function controls the length of the insertion delay. - - Synopsis: - ret = SetDDGInsertionDelay(state) - - Inputs: - state - NORMAL/FAST switch for insertion delay.: - 0 - to set normal insertion delay. - 1 - to set fast insertion delay. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for delay accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGInsertionDelay(int state); - - See Also: - GetCapabilities SetDDGIntelligate - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGInsertionDelay(cstate) - return (ret) - - def SetDDGIntelligate(self, state): - ''' - Description: - This function controls the MCP gating. Not available when the fast insertion delay option is selected. - - Synopsis: - ret = SetDDGIntelligate(state) - - Inputs: - state - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIntelligate(int state); - - See Also: - GetCapabilities SetDDGInsertionDelay - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIntelligate(cstate) - return (ret) - - def SetDDGIOC(self, state): - ''' - Description: - This function activates the integrate on chip (IOC) option. - - Synopsis: - ret = SetDDGIOC(state) - - Inputs: - state - ON/OFF switch for the IOC option.: - 0 - to switch IOC OFF. - 1 - to switch IOC ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIOC(int state); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIOC(cstate) - return (ret) - - def SetDDGIOCFrequency(self, frequency): - ''' - Description: - This function sets the frequency of the integrate on chip option. It should be called once the conditions of the experiment have been setup in order for correct operation. The frequency should be limited to 5000Hz when intelligate is activated to prevent damage to the head and 50000Hz otherwise to prevent the gater from overheating. The recommended order is - ... - Experiment setup (exposure time, readout mode, gate parameters, ...) - ... - SetDDGIOCFrequency (x) - SetDDGIOCSetDDGIOC(true) - GetDDGIOCPulses(y) - StartAcquisitionStartAcquisition() - - Synopsis: - ret = SetDDGIOCFrequency(frequency) - - Inputs: - frequency - frequency of IOC option in Hz. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for frequency accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetDDGIOCFrequency(double frequency); - - See Also: - GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cfrequency = c_double(frequency) - ret = self.dll.SetDDGIOCFrequency(cfrequency) - return (ret) - - def SetDDGIOCNumber(self, numberPulses): - ''' - Description: - This function allows the user to limit the number of pulses used in the integrate on chip option at a given frequency. It should be called once the conditions of the experiment have been setup in order for correct operation. - - Synopsis: - ret = SetDDGIOCNumber(numberPulses) - - Inputs: - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for IOC number accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - IOC not supported - DRV_ERROR_ACK - Unable to communicate with card - - C++ Equiv: - unsigned int SetDDGIOCNumber(long numberPulses); - - See Also: - SetDDGIOCFrequency GetDDGIOCFrequency GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cnumberPulses = c_int(numberPulses) - ret = self.dll.SetDDGIOCNumber(cnumberPulses) - return (ret) - - def SetDDGIOCPeriod(self, period): - ''' - Description: - This function can be used to set the IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - ret = SetDDGIOCPeriod(period) - - Inputs: - period - the period of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid period. - - C++ Equiv: - unsigned int SetDDGIOCPeriod(at_u64 period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency GetDDGIOCPeriod - - ''' - cperiod = c_ulonglong(period) - ret = self.dll.SetDDGIOCPeriod(cperiod) - return (ret) - - def SetDDGIOCTrigger(self, trigger): - ''' - Description: - This function can be used to select whether to trigger the IOC pulse train with either the rising edge of the fire pulse or an externally supplied trigger. - - Synopsis: - ret = SetDDGIOCTrigger(trigger) - - Inputs: - trigger - IOC Trigger Option: - 0 - Fire pulse - 1 - External Trigger - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC trigger set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid trigger. - - C++ Equiv: - unsigned int SetDDGIOCTrigger(at_u32 trigger); - - See Also: - GetCapabilities GetDDGIOCTrigger SetDDGIOC SetTriggerMode - - ''' - ctrigger = c_uint(trigger) - ret = self.dll.SetDDGIOCTrigger(ctrigger) - return (ret) - - def SetDDGLiteControlByte(self, channel, control): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - ret = SetDDGLiteControlByte(channel, control) - - Inputs: - channel - - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteControlByte(AT_DDGLiteChannelId channel, char control); - - ''' - cchannel = (channel) - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteControlByte(cchannel, ccontrol) - return (ret) - - def SetDDGLiteGlobalControlByte(self, control): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteGlobalControlByte(control) - - Inputs: - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteGlobalControlByte(char control); - - ''' - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteGlobalControlByte(ccontrol) - return (ret) - - def SetDDGLiteInitialDelay(self, channel, fDelay): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteInitialDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInitialDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLiteInterPulseDelay(self, channel, fDelay): - ''' - Description: - - - Synopsis: - ret = SetDDGLiteInterPulseDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInterPulseDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLitePulsesPerExposure(self, channel, ui32Pulses): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulsesPerExposure(channel, ui32Pulses) - - Inputs: - channel - - ui32Pulses - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint(ui32Pulses) - ret = self.dll.SetDDGLitePulsesPerExposure(cchannel, cui32Pulses) - return (ret) - - def SetDDGLitePulseWidth(self, channel, fWidth): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulseWidth(channel, fWidth) - - Inputs: - channel - - fWidth - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float(fWidth) - ret = self.dll.SetDDGLitePulseWidth(cchannel, cfWidth) - return (ret) - - def SetDDGOpticalWidthEnabled(self, uiEnabled): - ''' - Description: - This function can be used to configure a system to use optical gate width. - - Synopsis: - ret = SetDDGOpticalWidthEnabled(uiEnabled) - - Inputs: - uiEnabled - optical gate width option (0 - Off, 1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGOpticalWidthEnabled(at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth GetDDGOpticalWidthEnabled - - ''' - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGOpticalWidthEnabled(cuiEnabled) - return (ret) - - def SetDDGStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - StartAcquisition SetDDGStepMode GetDDGStepMode GetDDGStepCoefficients - - Note: Available on iStar and USB iStar. - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGStepMode(self, mode): - ''' - Description: - This function will set the current gate step mode. - - Synopsis: - ret = SetDDGStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGStepMode(at_u32 mode); - - See Also: - StartAcquisition GetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGStepMode(cmode) - return (ret) - - def SetDDGTimes(self, t0, t1, t2): - ''' - Description: - This function sets the properties of the gate pulse. t0 has a resolution of 16 nanoseconds whilst t1 and t2 have a resolution of 25 picoseconds. - - Synopsis: - ret = SetDDGTimes(t0, t1, t2) - - Inputs: - t0 - output A delay in nanoseconds. - t1 - gate delay in picoseconds. - t2 - pulse width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Values for gate pulse accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid output A delay. - DRV_P2INVALID - Invalid gate delay. - DRV_P3INVALID - Invalid pulse width. - - C++ Equiv: - unsigned int SetDDGTimes(double t0, double t1, double t2); - - See Also: - SetDDGGateStep - - Note: Available on iStar. - - ''' - ct0 = c_double(t0) - ct1 = c_double(t1) - ct2 = c_double(t2) - ret = self.dll.SetDDGTimes(ct0, ct1, ct2) - return (ret) - - def SetDDGTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode of the internal delay generator to either internal or External - - Synopsis: - ret = SetDDGTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetDDGTriggerMode(int mode); - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - ret = self.dll.SetDDGTriggerMode(cmode) - return (ret) - - def SetDDGVariableGateStep(self, mode, p1, p2): - ''' - Description: - This function will set a varying value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGVariableGateStep(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 1 - Exponential (p1*exp(p2*n)) - 2 - Logarithmic (p1*log(p2*n)) - 3 - Linear (p1 + p2*n) - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGVariableGateStep(int mode, double p1, double p2); - - See Also: - StartAcquisition - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGVariableGateStep(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate width step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGWidthStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - - n = 1, 2, ..., number in kinetic series - p1 - The first coefficient - p2 - The second coefficient - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGWidthStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - SetDDGWidthStepMode GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGWidthStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepMode(self, mode): - ''' - Description: - This function will set the current gate width step mode. - - Synopsis: - ret = SetDDGWidthStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGWidthStepMode(at_u32 mode); - - See Also: - SetDDGWidthStepCoefficients GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGWidthStepMode(cmode) - return (ret) - - def SetDelayGenerator(self, board, address, typ): - ''' - Description: - This function sets parameters to control the delay generator through the GPIB card in your computer. - - Synopsis: - ret = SetDelayGenerator(board, address, typ) - - Inputs: - board - The GPIB board number of the card used to interface with the Delay Generator.: - short - address: The number that allows the GPIB board to identify and send commands to the delay generator. - address - The number that allows the GPIB board to identify and send commands to the delay generator. - - typ - The type of your Delay Generator. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Delay Generator set up. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - GPIB board invalid. - DRV_P2INVALID - GPIB address invalid - DRV_P3INVALID - Delay generator type invalid. - - C++ Equiv: - unsigned int SetDelayGenerator(int board, short address, int typ); - - See Also: - SetGate - - Note: Available on ICCD. - - ''' - cboard = c_int(board) - caddress = c_short(address) - ctyp = c_int(typ) - ret = self.dll.SetDelayGenerator(cboard, caddress, ctyp) - return (ret) - - def SetDMAParameters(self, MaxImagesPerDMA, SecondsPerDMA): - ''' - Description: - In order to facilitate high image readout rates the controller card may wait for multiple images to be acquired before notifying the SDK that new data is available. Without this facility, there is a chance that hardware interrupts may be lost as the operating system does not have enough time to respond to each interrupt. The drawback to this is that you will not get the data for an image until all images for that interrupt have been acquired. - There are 3 settings involved in determining how many images will be acquired for each notification (DMA interrupt) of the controller card and they are as follows: - 1. The size of the DMA buffer gives an upper limit on the number of images that can be stored within it and is usually set to the size of one full image when installing the software. This will usually mean that if you acquire full frames there will never be more than one image per DMA. - 2. A second setting that is used is the minimum amount of time (SecondsPerDMA) that should expire between interrupts. This can be used to give an indication of the reponsiveness of the operating system to interrupts. Decreasing this value will allow more interrupts per second and should only be done for faster pcs. The default value is 0.03s (30ms), finding the optimal value for your pc can only be done through experimentation. - 3. The third setting is an overide to the number of images calculated using the previous settings. If the number of images per dma is calculated to be greater than MaxImagesPerDMA then it will be reduced to MaxImagesPerDMA. This can be used to, for example, ensure that there is never more than 1 image per DMA by setting MaxImagesPerDMA to 1. Setting MaxImagesPerDMA to zero removes this limit. Care should be taken when modifying these parameters as missed interrupts may prevent the acquisition from completing. - - Synopsis: - ret = SetDMAParameters(MaxImagesPerDMA, SecondsPerDMA) - - Inputs: - MaxImagesPerDMA - Override to the number of images per DMA if the calculated value is higher than this. (Default=0, ie. no override) - SecondsPerDMA - Minimum amount of time to elapse between interrrupts. (Default=0.03s) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DMA Parameters setup successfully. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - MaxImagesPerDMA invalid - DRV_P2INVALID - SecondsPerDMA invalid - - C++ Equiv: - unsigned int SetDMAParameters(int MaxImagesPerDMA, float SecondsPerDMA); - - ''' - cMaxImagesPerDMA = c_int(MaxImagesPerDMA) - cSecondsPerDMA = c_float(SecondsPerDMA) - ret = self.dll.SetDMAParameters(cMaxImagesPerDMA, cSecondsPerDMA) - return (ret) - - def SetDriverEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the SDK via which the the user software can be informed that something has occurred. For example the SDK can set the event when an acquisition has completed thus relieving the user code of having to continually pole to check on the status of the acquisition. - The event will be set under the follow conditions: - 1) Acquisition completed or aborted. - 2) As each scan during an acquisition is completed. - 3) Temperature as stabilized, drifted from stabilization or could not be reached. - When an event is triggered the user software can then use other SDK functions to determine what actually happened. - Condition 1 and 2 can be tested via GetStatusGetStatus function, while condition 3 checked via GetTemperatureGetTemperature function. - You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetDriverEvent with NULL as the parameter. - - Synopsis: - ret = SetDriverEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetDriverEvent(HANDLE driverEvent); - - See Also: - GetStatus GetTemperature GetAcquisitionProgress - - Note: Not all programming environments allow the use of multiple threads and WIN32 events. - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetDriverEvent(cdriverEvent) - return (ret) - - def SetDualExposureMode(self, mode): - ''' - Description: - This function turns on and off the option to acquire 2 frames for each external trigger pulse. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureMode(mode) - - Inputs: - mode - Enables/Disables dual exposure mode: - 1 - Enable mode - 0 - Disable mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode parameter was not zero or one. - - C++ Equiv: - unsigned int SetDualExposureMode(int mode); - - See Also: - GetCapabilities SetDualExposureTimes GetDualExposureTimes - - ''' - cmode = c_int(mode) - ret = self.dll.SetDualExposureMode(cmode) - return (ret) - - def SetDualExposureTimes(self, expTime1, expTime2): - ''' - Description: - This function configures the two exposure times used in dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureTimes(expTime1, expTime2) - - Inputs: - expTime1 - the exposure time in seconds for each odd numbered frame. - expTime2 - the exposure time in seconds for each even numbered frame. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - First exposure out of range. - DRV_P2INVALID - Second exposure out of range. - - C++ Equiv: - unsigned int SetDualExposureTimes(float expTime1, float expTime2); - - See Also: - GetCapabilities SetDualExposureMode GetDualExposureTimes - - ''' - cexpTime1 = c_float(expTime1) - cexpTime2 = c_float(expTime2) - ret = self.dll.SetDualExposureTimes(cexpTime1, cexpTime2) - return (ret) - - def SetEMAdvanced(self, state): - ''' - Description: - This function turns on and off access to higher EM gain levels within the SDK. Typically, optimal signal to noise ratio and dynamic range is achieved between x1 to x300 EM Gain. Higher gains of > x300 are recommended for single photon counting only. Before using higher levels, you should ensure that light levels do not exceed the regime of tens of photons per pixel, otherwise accelerated ageing of the sensor can occur. - - Synopsis: - ret = SetEMAdvanced(state) - - Inputs: - state - Enables/Disables access to higher EM gain levels: - 1 - Enable access - 1 - Disable access - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Advanced EM gain not available for this camera. - DRV_ACQUIRING. - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetEMAdvanced(int state); - - See Also: - GetCapabilities GetEMCCDGain SetEMCCDGain SetEMGainMode - - ''' - cstate = c_int(state) - ret = self.dll.SetEMAdvanced(cstate) - return (ret) - - def SetEMCCDGain(self, gain): - ''' - Description: - Allows the user to change the gain value. The valid range for the gain depends on what gain mode the camera is operating in. See SetEMGainMode to set the mode and GetEMGainRange to get the valid range to work with. To access higher gain values (>x300) see SetEMAdvanced. - - Synopsis: - ret = SetEMCCDGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetEMCCDGain(int gain); - - See Also: - GetEMCCDGain SetEMGainMode GetEMGainRange SetEMAdvanced - - Note: Only available on EMCCD sensor systems. - - ''' - cgain = c_int(gain) - ret = self.dll.SetEMCCDGain(cgain) - return (ret) - - def SetEMClockCompensation(self, EMClockCompensationFlag): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetEMClockCompensation(EMClockCompensationFlag) - - Inputs: - EMClockCompensationFlag - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetEMClockCompensation(int EMClockCompensationFlag); - - ''' - cEMClockCompensationFlag = c_int(EMClockCompensationFlag) - ret = self.dll.SetEMClockCompensation(cEMClockCompensationFlag) - return (ret) - - def SetEMGainMode(self, mode): - ''' - Description: - Set the EM Gain mode to one of the following possible settings. - Mode 0: The EM Gain is controlled by DAC settings in the range 0-255. Default mode. - 1: The EM Gain is controlled by DAC settings in the range 0-4095. - 2: Linear mode. - 3: Real EM gain - To access higher gain values (if available) it is necessary to enable advanced EM gain, see SetEMAdvanced. - - Synopsis: - ret = SetEMGainMode(mode) - - Inputs: - mode - EM Gain mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - EM Gain mode invalid. - - C++ Equiv: - unsigned int SetEMGainMode(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetEMGainMode(cmode) - return (ret) - - def SetExposureTime(self, time): - ''' - Description: - This function will set the exposure time to the nearest valid value not less than the given value. The actual exposure time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetExposureTime(time) - - Inputs: - time - the exposure time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Exposure time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure Time invalid. - - C++ Equiv: - unsigned int SetExposureTime(float time); - - See Also: - GetAcquisitionTimings - - Note: For Classics, if the current acquisition mode is Single-Track, Multi-Track or Image then this function will actually set the Shutter Time. The actual exposure time used is obtained from the GetAcquisitionTimings functionGetAcquisitionTimings. - - ''' - ctime = c_float(time) - ret = self.dll.SetExposureTime(ctime) - return (ret) - - def SetExternalTriggerTermination(self, uiTermination): - ''' - Description: - This function can be used to set the external trigger termination mode. - - Synopsis: - ret = SetExternalTriggerTermination(uiTermination) - - Inputs: - uiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetExternalTriggerTermination(at_u32 uiTermination); - - See Also: - GetCapabilities GetExternalTriggerTermination - - ''' - cuiTermination = c_uint(uiTermination) - ret = self.dll.SetExternalTriggerTermination(cuiTermination) - return (ret) - - def SetFanMode(self, mode): - ''' - Description: - Allows the user to control the mode of the camera fan. If the system is cooled, the fan should only be turned off for short periods of time. During this time the body of the camera will warm up which could compromise cooling capabilities. - If the camera body reaches too high a temperature, depends on camera, the buzzer will sound. If this happens, turn off the external power supply and allow the system to stabilize before continuing. - - Synopsis: - ret = SetFanMode(mode) - - Inputs: - mode - Fan mode setting: - 0 - Fan on full. - 1 - Fan on low. - 2 - Fan off, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Mode value invalid. - - C++ Equiv: - unsigned int SetFanMode(int mode); - - See Also: - GetCapabilities - - ''' - cmode = c_int(mode) - ret = self.dll.SetFanMode(cmode) - return (ret) - - def SetFastExtTrigger(self, mode): - ''' - Description: - This function will enable fast external triggering. When fast external triggering is enabled the system will NOT wait until a Keep Clean cycle has been completed before accepting the next trigger. This setting will only have an effect if the trigger mode has been set to External via SetTriggerMode. - - Synopsis: - ret = SetFastExtTrigger(mode) - - Inputs: - mode - 0 Disabled: - 1 - Enabled - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters accepted. - - C++ Equiv: - unsigned int SetFastExtTrigger(int mode); - - See Also: - SetTriggerMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFastExtTrigger(cmode) - return (ret) - - def SetFastKinetics(self, exposedRows, seriesLength, time, mode, hbin, vbin): - ''' - Description: - This function will set the parameters to be used when taking a fast kinetics acquisition. - - Synopsis: - ret = SetFastKinetics(exposedRows, seriesLength, time, mode, hbin, vbin) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System not initialized. - DRV_NOT_INITIALIZED - Acquisition in progress. - DRV_ACQUIRING - Invalid height. - DRV_P1INVALID - Invalid number in series. - DRV_P2INVALID DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID DRV_P5INVALID - Mode must be equal to 0 or 4. - DRV_P6INVALID - Horizontal binning. - All parameters accepted. - Vertical binning. - - C++ Equiv: - unsigned int SetFastKinetics(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin); - - See Also: - SetFKVShiftSpeed SetFastKineticsEx SetFKVShiftSpeed - - Note: For classic cameras the vertical and horizontal binning must be 1 - For non classic cameras it is recommended that you use SetFastKineticsEx - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFastKinetics(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin) - return (ret) - - def SetFastKineticsEx(self, exposedRows, seriesLength, time, mode, hbin, vbin, offset): - ''' - Description: - This function is the same as SetFastKinetics with the addition of an Offset parameter, which will inform the SDK of the first row to be used. - - Synopsis: - ret = SetFastKineticsEx(exposedRows, seriesLength, time, mode, hbin, vbin, offset) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - offset - offset of first row to be used in Fast Kinetics from the bottom of the CCD. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid height. - DRV_P2INVALID - Invalid number in series. - DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID - Mode must be equal to 0 or 4. - DRV_P5INVALID - Horizontal binning. - DRV_P6INVALID - Vertical binning. - DRV_P7INVALID - Offset not within CCD limits - - C++ Equiv: - unsigned int SetFastKineticsEx(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin, int offset); - - See Also: - SetFKVShiftSpeed SetFastKinetics SetFKVShiftSpeed - - Note: For classic cameras the offset must be 0 and the vertical and horizontal binning must be 1 - For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - coffset = c_int(offset) - ret = self.dll.SetFastKineticsEx(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin, coffset) - return (ret) - - def SetFilterMode(self, mode): - ''' - Description: - This function will set the state of the cosmic ray filter mode for future acquisitions. If the filter mode is on, consecutive scans in an accumulation will be compared and any cosmic ray-like features that are only present in one scan will be replaced with a scaled version of the corresponding pixel value in the correct scan. - - Synopsis: - ret = SetFilterMode(mode) - - Inputs: - mode - current state of filter: - 0 - OFF - 2 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is out off range. - - C++ Equiv: - unsigned int SetFilterMode(int mode); - - See Also: - GetFilterMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFilterMode(cmode) - return (ret) - - def SetFilterParameters(self, width, sensitivity, range, accept, smooth, noise): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFilterParameters(width, sensitivity, range, accept, smooth, noise) - - Inputs: - width - - sensitivity - - range - - accept - - smooth - - noise - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFilterParameters(int width, float sensitivity, int range, float accept, int smooth, int noise); - - ''' - cwidth = c_int(width) - csensitivity = c_float(sensitivity) - crange = c_int(range) - caccept = c_float(accept) - csmooth = c_int(smooth) - cnoise = c_int(noise) - ret = self.dll.SetFilterParameters(cwidth, csensitivity, crange, caccept, csmooth, cnoise) - return (ret) - - def SetFKVShiftSpeed(self, index): - ''' - Description: - This function will set the fast kinetics vertical shift speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetFKVShiftSpeed(index) - - Inputs: - index - the speed to be used: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Fast kinetics vertical shift speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetFKVShiftSpeed(int index); - - See Also: - GetNumberFKVShiftSpeeds GetFKVShiftSpeedF - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - ret = self.dll.SetFKVShiftSpeed(cindex) - return (ret) - - def SetFPDP(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFPDP(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFPDP(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetFPDP(cstate) - return (ret) - - def SetFrameTransferMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Frame Transfer Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetFrameTransferMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame transfer mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetFrameTransferMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is a Frame Transfer chip. - - ''' - cmode = c_int(mode) - ret = self.dll.SetFrameTransferMode(cmode) - return (ret) - - def SetFrontEndEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the Front End cooler has overheated or returned to a normal state. To determine what event has actually occurred call the GetFrontEndStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetFrontEndEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetFrontEndEvent(at_32 driverEvent); - - See Also: - GetFrontEndStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetFrontEndEvent(cdriverEvent) - return (ret) - - def SetFullImage(self, hbin, vbin): - ''' - Description: - Deprecated see Note: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetFullImage(hbin, vbin) - - Inputs: - hbin - number of pixels to bin horizontally - vbin - number of pixels to bin vertically - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning parameters accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Horizontal binning parameter invalid - DRV_P2INVALID - Vertical binning parameter invalid - - C++ Equiv: - unsigned int SetFullImage(int hbin, int vbin); // deprecated - - See Also: - SetReadMode - - Note: Deprecated by SetImageGetNumberHSSpeeds - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFullImage(chbin, cvbin) - return (ret) - - def SetFVBHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Full Vertical Binned read mode. - - Synopsis: - ret = SetFVBHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetFVBHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetFVBHBin(cbin) - return (ret) - - def SetGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetGain(cgain) - return (ret) - - def SetGate(self, delay, width, stepRenamed): - ''' - Description: - This function sets the Gater parameters for an ICCD system. The image intensifier of the Andor ICCD acts as a shutter on nanosecond time-scales using a process known as gating. - - Synopsis: - ret = SetGate(delay, width, stepRenamed) - - Inputs: - delay - Sets the delay(>=0) between the T0 and C outputs on the SRS box to delay nanoseconds. - width - Sets the width(>=0) of the gate in nanoseconds - stepRenamed - Sets the amount(<>0, in nanoseconds) by which the gate position is moved in time after each scan in a kinetic series. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gater parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_GPIBERROR - Error communicating with GPIB card. - DRV_P1INVALID - Invalid delay - DRV_P2INVALID - Invalid width. - DRV_P3INVALID - Invalid step. - - C++ Equiv: - unsigned int SetGate(float delay, float width, float stepRenamed); - - See Also: - SetDelayGenerator - - Note: Available on ICCD. - - ''' - cdelay = c_float(delay) - cwidth = c_float(width) - cstepRenamed = c_float(stepRenamed) - ret = self.dll.SetGate(cdelay, cwidth, cstepRenamed) - return (ret) - - def SetGateMode(self, gatemode): - ''' - Description: - Allows the user to control the photocathode gating mode. - - Synopsis: - ret = SetGateMode(gatemode) - - Inputs: - gatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gating mode invalid. - - C++ Equiv: - unsigned int SetGateMode(int gatemode); - - See Also: - GetCapabilities SetMCPGain SetMCPGating - - ''' - cgatemode = c_int(gatemode) - ret = self.dll.SetGateMode(cgatemode) - return (ret) - - def SetHighCapacity(self, state): - ''' - Description: - This function switches between high sensitivity and high capacity functionality. With high capacity enabled the output amplifier is switched to a mode of operation which reduces the responsivity thus allowing the reading of larger charge packets during binning operations. - - Synopsis: - ret = SetHighCapacity(state) - - Inputs: - state - Enables/Disables High Capacity functionality: - 1 - Enable High Capacity (Disable High Sensitivity) - 0 - Disable High Capacity (Enable High Sensitivity) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetHighCapacity(int state); - - See Also: - GetCapabilities - - ''' - cstate = c_int(state) - ret = self.dll.SetHighCapacity(cstate) - return (ret) - - def SetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the horizontal speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetHorizontalSpeed(index) - - Inputs: - index - the horizontal speed to be used: - 0 - to GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHorizontalSpeed(int index); // deprecated - - See Also: - GetNumberHorizontalSpeeds GetHorizontalSpeed - - Note: Deprecated by SetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - ret = self.dll.SetHorizontalSpeed(cindex) - return (ret) - - def SetHSSpeed(self, typ, index): - ''' - Description: - This function will set the speed at which the pixels are shifted into the output node during the readout phase of an acquisition. Typically your camera will be capable of operating at several horizontal shift speeds. To get the actual speed that an index corresponds to use the GetHSSpeed function. Ensure the desired A/D channel has been set with SetADChannel before calling SetHSSpeed. - - Synopsis: - ret = SetHSSpeed(typ, index) - - Inputs: - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR mode(clara). - index - the horizontal speed to be used: - 0 - to GetNumberHSSpeeds()GetNumberHSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is invalid. - DRV_P2INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHSSpeed(int typ, int index); - - See Also: - GetNumberHSSpeeds GetHSSpeed GetNumberAmp - - ''' - ctyp = c_int(typ) - cindex = c_int(index) - ret = self.dll.SetHSSpeed(ctyp, cindex) - return (ret) - - def SetImage(self, hbin, vbin, hstart, hend, vstart, vend): - ''' - Description: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetImage(hbin, vbin, hstart, hend, vstart, vend) - - Inputs: - hbin - number of pixels to bin horizontally. - vbin - number of pixels to bin vertically. - hstart - Start column (inclusive). - hend - End column (inclusive). - vstart - Start row (inclusive). - vend - End row (inclusive). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Binning parameters invalid. - DRV_P2INVALID - Binning parameters invalid. - DRV_P3INVALID - Sub-area co-ordinate is invalid. - DRV_P4INVALID - Sub-area co-ordinate is invalid. - DRV_P5INVALID - Sub-area co-ordinate is invalid. - DRV_P6INVALID - Sub-area co-ordinate is invalid. - - C++ Equiv: - unsigned int SetImage(int hbin, int vbin, int hstart, int hend, int vstart, int vend); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - chstart = c_int(hstart) - chend = c_int(hend) - cvstart = c_int(vstart) - cvend = c_int(vend) - ret = self.dll.SetImage(chbin, cvbin, chstart, chend, cvstart, cvend) - return (ret) - - def SetImageFlip(self, iHFlip, iVFlip): - ''' - Description: - This function will cause data output from the SDK to be flipped on one or both axes. This flip is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If flipping could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageFlip(iHFlip, iVFlip) - - Inputs: - iHFlip - Sets horizontal flipping. - iVFlip - Sets vertical flipping..: - 1 - Enables Flipping - 0 - Disables Flipping - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - - C++ Equiv: - unsigned int SetImageFlip(int iHFlip, int iVFlip); - - See Also: - SetImageRotate - - Note: If this function is used in conjunction with the SetImageRotate function the rotation will occur before the flip regardless of which order the functions are called. - - ''' - ciHFlip = c_int(iHFlip) - ciVFlip = c_int(iVFlip) - ret = self.dll.SetImageFlip(ciHFlip, ciVFlip) - return (ret) - - def SetImageRotate(self, iRotate): - ''' - Description: - This function will cause data output from the SDK to be rotated on one or both axes. This rotate is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If the rotation could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageRotate(iRotate) - - Inputs: - iRotate - Rotation setting: - 0 - No rotation. - 1 - Rotate 90 degrees clockwise. - 2 - Rotate 90 degrees anti-clockwise. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - - C++ Equiv: - unsigned int SetImageRotate(int iRotate); - - See Also: - SetImageFlip - - Note: If this function is used in conjunction with the SetImageFlip function the rotation will occur before the flip regardless of which order the functions are called. 180 degree rotation can be achieved using the SetImageFlip function by selecting both horizontal and vertical flipping. - - ''' - ciRotate = c_int(iRotate) - ret = self.dll.SetImageRotate(ciRotate) - return (ret) - - def SetIODirection(self, index, iDirection): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIODirection(index, iDirection) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iDirection - requested direction for this index.: - 0 - 0 Output - 1 - 1 Input - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid direction. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIODirection(int index, int iDirection); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int(iDirection) - ret = self.dll.SetIODirection(cindex, ciDirection) - return (ret) - - def SetIOLevel(self, index, iLevel): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIOLevel(index, iLevel) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid level. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIOLevel(int index, int iLevel); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIODirection - - ''' - cindex = c_int(index) - ciLevel = c_int(iLevel) - ret = self.dll.SetIOLevel(cindex, ciLevel) - return (ret) - - def SetIsolatedCropMode(self, active, cropheight, cropwidth, vbin, hbin): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. In isolated crop mode iXon, Newton and iKon cameras can operate in either Full Vertical Binning or Imaging read modes. iDus can operate in Full Vertical Binning read mode only. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - - Inputs: - active - Crop mode active: - 1 - Crop mode is ON. - Crop - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - The selected vertical binning. - hbin - The selected horizontal binning. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_NOT_SUPPORTED - Either the camera does not support isolated Crop mode or the read mode is invalid - - C++ Equiv: - unsigned int SetIsolatedCropMode(int active, int cropheight, int cropwidth, int vbin, int hbin); - - See Also: - GetDetector SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ret = self.dll.SetIsolatedCropMode(cactive, ccropheight, ccropwidth, cvbin, chbin) - return (ret) - - def SetIsolatedCropModeEx(self, active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. This feature is currently only available for iXon Ultra and can only be used in Image readout mode with the EM output amplifier. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - The following centralized regions of interest are recommended to be used with this mode to achieve the fastest possible frame rates. The table below shows the optimally positioned ROI coordinates recommended to be used with this mode: - ROI - Crop Left Start Position - Crop Right Position - Crop Bottom Start Position - Crop Top Position - 32 x 32 - 241 - 272 - 240 - 271 - 64 x 64 - 219 - 282 - 224 - 287 - 96 x 96 - 209 - 304 - 208 - 303 - 128 x 128 - 189 - 316 - 192 - 319 - 192 x 192 - 157 - 348 - 160 - 351 - 256 x 256 - 123 - 378 - 128 - 383 - 496 x 4 - 8 - 503 - 254 - 257 - 496 x 8 - 8 - 503 - 252 - 259 - 496 x 16 - 8 - 503 - 249 - 262 - - Synopsis: - ret = SetIsolatedCropModeEx(active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom) - - Inputs: - active - Crop mode active.: - 1 - Crop mode is ON. - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - vbinThe selected vertical binning. - hbin - hbinThe selected horizontal binning. - cropleft - The selected crop left start position - cropbottom - The selected crop bottom start position - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_P6INVALID - Invalid crop left start position - DRV_P7INVALID - Invalid crop bottom start position - DRV_NOT_SUPPORTED - The camera does not support isolated crop mode - DRV_NOT_AVAILABLE - Invalid read mode - - C++ Equiv: - unsigned int SetIsolatedCropModeEx(int active, int cropheight, int cropwidth, int vbin, int hbin, int cropleft, int cropbottom); - - See Also: - GetDetector SetReadMode - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ccropleft = c_int(cropleft) - ccropbottom = c_int(cropbottom) - ret = self.dll.SetIsolatedCropModeEx(cactive, ccropheight, ccropwidth, cvbin, chbin, ccropleft, ccropbottom) - return (ret) - - def SetKineticCycleTime(self, time): - ''' - Description: - This function will set the kinetic cycle time to the nearest valid value not less than the given value. The actual time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. . Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetKineticCycleTime(time) - - Inputs: - time - the kinetic cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Time invalid. - - C++ Equiv: - unsigned int SetKineticCycleTime(float time); - - See Also: - SetNumberKinetics - - ''' - ctime = c_float(time) - ret = self.dll.SetKineticCycleTime(ctime) - return (ret) - - def SetMCPGain(self, gain): - ''' - Description: - Allows the user to control the voltage across the microchannel plate. Increasing the gain increases the voltage and so amplifies the signal. The gain range can be returned using GetMCPGainRange. - - Synopsis: - ret = SetMCPGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with device. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetMCPGain(int gain); - - See Also: - GetMCPGainRange SetGateMode SetMCPGating - - Note: Available on iStar. - - ''' - cgain = c_int(gain) - ret = self.dll.SetMCPGain(cgain) - return (ret) - - def SetMCPGating(self, gating): - ''' - Description: - This function controls the MCP gating. - - Synopsis: - ret = SetMCPGating(gating) - - Inputs: - gating - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gating accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Value for gating invalid. - - C++ Equiv: - unsigned int SetMCPGating(int gating); - - See Also: - SetMCPGain SetGateMode - - Note: Available on some ICCD models. - - ''' - cgating = c_int(gating) - ret = self.dll.SetMCPGating(cgating) - return (ret) - - def SetMessageWindow(self, wnd): - ''' - Description: - This function is reserved. - - Synopsis: - ret = SetMessageWindow(wnd) - - Inputs: - wnd - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMessageWindow(at_32 wnd); - - ''' - cwnd = c_int(wnd) - ret = self.dll.SetMessageWindow(cwnd) - return (ret) - - def SetMetaData(self, state): - ''' - Description: - This function activates the meta data option. - - Synopsis: - ret = SetMetaData(state) - - Inputs: - state - ON/OFF switch for the meta data option.: - 0 - to switch meta data OFF. - 1 - to switch meta data ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Meta data option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid state. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetMetaData(int state); - - See Also: - GetMetaDataInfo - - ''' - cstate = c_int(state) - ret = self.dll.SetMetaData(cstate) - return (ret) - - def SetMultiTrack(self, number, height, offset): - ''' - Description: - This function will set the multi-Track parameters. The tracks are automatically spread evenly over the detector. Validation of the parameters is carried out in the following order: - * Number of tracks, - * Track height - * Offset. - The first pixels row of the first track is returned via bottom. - The number of rows between each track is returned via gap. - - Synopsis: - (ret, bottom, gap) = SetMultiTrack(number, height, offset) - - Inputs: - number - number tracks (1 to number of vertical pixels) - height - height of each track (>0 (maximum depends on number of tracks)) - offset - vertical displacement of tracks. (depends on number of tracks and track height) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track height invalid. - DRV_P3INVALID - Offset invalid. - bottom - first pixels row of the first track - gap - number of rows between each track (could be 0) - - C++ Equiv: - unsigned int SetMultiTrack(int number, int height, int offset, int * bottom, int * gap); - - See Also: - SetReadMode StartAcquisition SetRandomTracks - - ''' - cnumber = c_int(number) - cheight = c_int(height) - coffset = c_int(offset) - cbottom = c_int() - cgap = c_int() - ret = self.dll.SetMultiTrack(cnumber, cheight, coffset, byref(cbottom), byref(cgap)) - return (ret, cbottom.value, cgap.value) - - def SetMultiTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Multi-Track read mode. - - Synopsis: - ret = SetMultiTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetMultiTrackHBin(int bin); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - Note: 1) If the multitrack range is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetMultiTrackHBin(cbin) - return (ret) - - def SetMultiTrackHRange(self, iStart, iEnd): - ''' - Description: - This function sets the horizontal range used when acquiring in Multi Track read mode. - - Synopsis: - ret = SetMultiTrackHRange(iStart, iEnd) - - Inputs: - iStart - First horizontal pixel in multi track mode. - iEnd - iEndLast horizontal pixel in multi track mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Range set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available for this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid start position. - DRV_P2INVALID - Invalid end position. - - C++ Equiv: - unsigned int SetMultiTrackHRange(int iStart, int iEnd); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - ''' - ciStart = c_int(iStart) - ciEnd = c_int(iEnd) - ret = self.dll.SetMultiTrackHRange(ciStart, ciEnd) - return (ret) - - def SetMultiTrackScan(self, trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetMultiTrackScan(trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames) - - Inputs: - trackHeight - - numberTracks - - iSIHStart - - iSIHEnd - - trackHBinning - - trackVBinning - - trackGap - - trackOffset - - trackSkip - - numberSubFrames - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMultiTrackScan(int trackHeight, int numberTracks, int iSIHStart, int iSIHEnd, int trackHBinning, int trackVBinning, int trackGap, int trackOffset, int trackSkip, int numberSubFrames); - - ''' - ctrackHeight = c_int(trackHeight) - cnumberTracks = c_int(numberTracks) - ciSIHStart = c_int(iSIHStart) - ciSIHEnd = c_int(iSIHEnd) - ctrackHBinning = c_int(trackHBinning) - ctrackVBinning = c_int(trackVBinning) - ctrackGap = c_int(trackGap) - ctrackOffset = c_int(trackOffset) - ctrackSkip = c_int(trackSkip) - cnumberSubFrames = c_int(numberSubFrames) - ret = self.dll.SetMultiTrackScan(ctrackHeight, cnumberTracks, ciSIHStart, ciSIHEnd, ctrackHBinning, ctrackVBinning, ctrackGap, ctrackOffset, ctrackSkip, cnumberSubFrames) - return (ret) - - def SetNextAddress(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNextAddress16(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress16(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress16(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress16(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNumberAccumulations(self, number): - ''' - Description: - This function will set the number of scans accumulated in memory. This will only take effect if the acquisition mode is either Accumulate or Kinetic Series. - - Synopsis: - ret = SetNumberAccumulations(number) - - Inputs: - number - number of scans to accumulate - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Accumulations set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of accumulates. - - C++ Equiv: - unsigned int SetNumberAccumulations(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberKinetics - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberAccumulations(cnumber) - return (ret) - - def SetNumberKinetics(self, number): - ''' - Description: - This function will set the number of scans (possibly accumulated scans) to be taken during a single acquisition sequence. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberKinetics(number) - - Inputs: - number - number of scans to store - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number in series invalid. - - C++ Equiv: - unsigned int SetNumberKinetics(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberKinetics(cnumber) - return (ret) - - def SetNumberPrescans(self, iNumber): - ''' - Description: - This function will set the number of scans acquired before data is to be retrieved. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberPrescans(iNumber) - - Inputs: - iNumber - number of scans to ignore - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Prescans set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of prescans invalid. - - C++ Equiv: - unsigned int SetNumberPrescans(int iNumber); - - See Also: - GetAcquisitionTimings SetAcquisitionMode SetKineticCycleTime SetNumberKinetics - - ''' - ciNumber = c_int(iNumber) - ret = self.dll.SetNumberPrescans(ciNumber) - return (ret) - - def SetOutputAmplifier(self, typ): - ''' - Description: - Some EMCCD systems have the capability to use a second output amplifier. This function will set the type of output amplifier to be used when reading data from the head for these systems. - - Synopsis: - ret = SetOutputAmplifier(typ) - - Inputs: - typ - the type of output amplifier.: - 0 - Standard EMCCD gain register (default)/Conventional(clara). - 1 - Conventional CCD register/Extended NIR mode(clara). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Output amplifier type invalid. - - C++ Equiv: - unsigned int SetOutputAmplifier(int typ); - - Note: 1. Available in Clara, iXon & Newton. - 2. If the current camera HSSpeed is not available when the amplifier is set then it will default to the maximum HSSpeed that is. - - - ''' - ctyp = c_int(typ) - ret = self.dll.SetOutputAmplifier(ctyp) - return (ret) - - def SetOverlapMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Overlap Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetOverlapMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Overlap mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetOverlapMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is an Overlap sensor. - - ''' - cmode = c_int(mode) - ret = self.dll.SetOverlapMode(cmode) - return (ret) - - def SetPCIMode(self, mode, value): - ''' - Description: - With the CCI23 card, events can be sent when the camera is starting to expose and when it has finished exposing. This function will control whether those events happen or not. - - Synopsis: - ret = SetPCIMode(mode, value) - - Inputs: - mode - currently must be set to 1 - value - 0 to disable the events, 1 to enable - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid - - C++ Equiv: - unsigned int SetPCIMode(int mode, int value); - - See Also: - SetAcqStatusEvent SetCameraStatusEnable - - Note: This is only supported by the CCI23 card. The software must register its event via the SetAcqStatusEvent. To specify which event the software is interested in use the SetCameraStatusEnable. - - ''' - cmode = c_int(mode) - cvalue = c_int(value) - ret = self.dll.SetPCIMode(cmode, cvalue) - return (ret) - - def SetPhosphorEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the phosphor has saturated or returned to a normal state. To determine what event has actually occurred call the GetPhosphorStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetPhosphorEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetPhosphorEvent(at_32 driverEvent); - - See Also: - GetPhosphorStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetPhosphorEvent(cdriverEvent) - return (ret) - - def SetPhotonCounting(self, state): - ''' - Description: - This function activates the photon counting option. - - Synopsis: - ret = SetPhotonCounting(state) - - Inputs: - state - ON/OFF switch for the photon counting option.: - 0 - to switch photon counting OFF. - 1 - to switch photon counting ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - photon counting option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCounting(int state); - - See Also: - SetPhotonCountingThreshold - - ''' - cstate = c_int(state) - ret = self.dll.SetPhotonCounting(cstate) - return (ret) - - def SetPhotonCountingDivisions(self, noOfDivisions): - ''' - Description: - This function sets the thresholds for the photon counting option. - - Synopsis: - (ret, divisions) = SetPhotonCountingDivisions(noOfDivisions) - - Inputs: - noOfDivisions - number of thresholds to be used. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Number of thresholds outside valid range - DRV_P2INVALID - Thresholds outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Feature not supported. - divisions - threshold levels. - - C++ Equiv: - unsigned int SetPhotonCountingDivisions(at_u32 noOfDivisions, at_32 * divisions); - - See Also: - SetPhotonCounting GetNumberPhotonCountingDivisions - - ''' - cnoOfDivisions = c_uint(noOfDivisions) - cdivisions = c_int() - ret = self.dll.SetPhotonCountingDivisions(cnoOfDivisions, byref(cdivisions)) - return (ret, cdivisions.value) - - def SetPhotonCountingThreshold(self, min, max): - ''' - Description: - This function sets the minimum and maximum threshold for the photon counting option. - - Synopsis: - ret = SetPhotonCountingThreshold(min, max) - - Inputs: - min - minimum threshold in counts for photon counting. - max - maximum threshold in counts for photon counting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Minimum threshold outside valid range (1-65535) - DRV_P2INVALID - Maximum threshold outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCountingThreshold(long min, long max); - - See Also: - SetPhotonCounting - - ''' - cmin = c_int(min) - cmax = c_int(max) - ret = self.dll.SetPhotonCountingThreshold(cmin, cmax) - return (ret) - - def SetPixelMode(self, bitdepth, colormode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetPixelMode(bitdepth, colormode) - - Inputs: - bitdepth - - colormode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetPixelMode(int bitdepth, int colormode); - - ''' - cbitdepth = c_int(bitdepth) - ccolormode = c_int(colormode) - ret = self.dll.SetPixelMode(cbitdepth, ccolormode) - return (ret) - - def SetPreAmpGain(self, index): - ''' - Description: - This function will set the pre amp gain to be used for subsequent acquisitions. The actual gain factor that will be applied can be found through a call to the GetPreAmpGain function. - The number of Pre Amp Gains available is found by calling the GetNumberPreAmpGains function. - - Synopsis: - ret = SetPreAmpGain(index) - - Inputs: - index - index pre amp gain table: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pre amp gain set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetPreAmpGain(int index); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains GetPreAmpGain - - Note: Available on iDus, iXon & Newton. - - ''' - cindex = c_int(index) - ret = self.dll.SetPreAmpGain(cindex) - return (ret) - - def SetRandomTracks(self, numTracks): - ''' - Description: - This function will set the Random-Track parameters. The positions of the tracks are validated to ensure that the tracks are in increasing order and do not overlap. The horizontal binning is set via the SetCustomTrackHBin function. The vertical binning is set to the height of each track. - Some cameras need to have at least 1 row in between specified tracks. Ixon+ and the USB cameras allow tracks with no gaps in between. - Example: - Tracks specified as 20 30 31 40 tells the SDK that the first track starts at row 20 in the CCD and finishes at row 30. The next track starts at row 31 (no gap between tracks) and ends at row 40. - - Synopsis: - (ret, areas) = SetRandomTracks(numTracks) - - Inputs: - numTracks - number tracks: - 1 - to number of vertical pixels/2 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_RANDOM_TRACK_ERROR - Invalid combination of tracks, out of memory or mode not available. - areas - pointer to an array of track positions. The array has the form: - bottom1 - bottom1 top1, bottom2, top2 ... bottomN, topN - - C++ Equiv: - unsigned int SetRandomTracks(int numTracks, int * areas); - - See Also: - SetCustomTrackHBin SetReadMode StartAcquisition SetComplexImage - - ''' - cnumTracks = c_int(numTracks) - careas = c_int() - ret = self.dll.SetRandomTracks(cnumTracks, byref(careas)) - return (ret, careas.value) - - def SetReadMode(self, mode): - ''' - Description: - This function will set the readout mode to be used on the subsequent acquisitions. - - Synopsis: - ret = SetReadMode(mode) - - Inputs: - mode - readout mode: - 0 - Full Vertical Binning - 1 - Multi-Track - 2 - Random-Track - 3 - Single-Track - 4 - Image - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadMode(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadMode(cmode) - return (ret) - - def SetReadoutRegisterPacking(self, mode): - ''' - Description: - This function will configure whether data is packed into the readout register to improve frame rates for sub-images. - Note: It is important to ensure that no light falls outside of the sub-image area otherwise the acquired data will be corrupted. Only currently available on iXon+ and iXon3. - - Synopsis: - ret = SetReadoutRegisterPacking(mode) - - Inputs: - mode - register readout mode: - 0 - Packing Off - 1 - Packing On - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadoutRegisterPacking(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadoutRegisterPacking(cmode) - return (ret) - - def SetRegisterDump(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetRegisterDump(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetRegisterDump(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetRegisterDump(cmode) - return (ret) - - def SetRingExposureTimes(self, numTimes): - ''' - Description: - This function will send up an array of exposure times to the camera if the hardware supports the feature. See GetCapabilities. Each acquisition will then use the next exposure in the ring looping round to the start again when the end is reached. There can be a maximum of 16 exposures. - - Synopsis: - (ret, times) = SetRingExposureTimes(numTimes) - - Inputs: - numTimes - The number of exposures - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_NOTAVAILABLE - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - This mode is not available. - DRV_P1INVALID - Must be between 1 and 16 exposures inclusive - DRV_P2INVALID - The exposures times are invalid. - times - A predeclared pointer to an array of numTimes floats - - C++ Equiv: - unsigned int SetRingExposureTimes(int numTimes, float * times); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable - - ''' - cnumTimes = c_int(numTimes) - ctimes = c_float() - ret = self.dll.SetRingExposureTimes(cnumTimes, byref(ctimes)) - return (ret, ctimes.value) - - def SetSaturationEvent(self, saturationEvent): - ''' - Description: - This is only supported with the CCI-23 PCI card. USB cameras do not have this feature. - This function passes a Win32 Event handle to the driver via which the driver can inform the main software that an acquisition has saturated the sensor to a potentially damaging level. You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetEvent with NULL as the parameter. - - Synopsis: - ret = SetSaturationEvent(saturationEvent) - - Inputs: - saturationEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetSaturationEvent(HANDLE saturationEvent); - - See Also: - SetDriverEvent - - Note: The programmer must reset the event after it has been handled in order to receive additional triggers, unless the event has been created with auto-reset, e.g. event = CreateEvent(NULL, FALSE, FALSE, NULL). Also, NOT all programming environments allow the use of multiple threads and Win32 events. - Only supported with the CCI-23 card. - USB cameras do not have this feature. - - - - ''' - csaturationEvent = c_void_p(saturationEvent) - ret = self.dll.SetSaturationEvent(csaturationEvent) - return (ret) - - def SetShutter(self, typ, mode, closingtime, openingtime): - ''' - Description: - This function controls the behaviour of the shutter. - The typ parameter allows the user to control the TTL signal output to an external shutter. The mode parameter configures whether the shutter opens & closes automatically (controlled by the camera) or is permanently open or permanently closed. - The opening and closing time specify the time required to open and close the shutter (this information is required for calculating acquisition timings (see SHUTTER TRANSFER TIME). - - Synopsis: - ret = SetShutter(typ, mode, closingtime, openingtime) - - Inputs: - typ - shutter type: - 1 - Output TTL high signal to open shutter - 0 - Output TTL low signal to open shutter - mode - Shutter mode: - 0 - Automatic - 1 - Open - 2 - Close - closingtime - Time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_ERROR_ACK - Acquisition in progress. - DRV_NOT_SUPPORTED - Unable to communicate with card. - DRV_P1INVALID - Camera does not support shutter control. - DRV_P2INVALID - Invalid TTL type. - DRV_P3INVALID - Invalid mode. - DRV_P4INVALID - Invalid time to open. - - C++ Equiv: - unsigned int SetShutter(int typ, int mode, int closingtime, int openingtime); - - See Also: - SetShutterEx - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - ret = self.dll.SetShutter(ctyp, cmode, cclosingtime, copeningtime) - return (ret) - - def SetShutterEx(self, typ, mode, closingtime, openingtime, extmode): - ''' - Description: - This function expands the control offered by SetShutter to allow an external shutter and internal shutter to be controlled independently (only available on some cameras - please consult your Camera User Guide). The typ parameter allows the user to control the TTL signal output to an external shutter. The opening and closing times specify the length of time required to open and close the shutter (this information is required for calculating acquisition timings - see SHUTTER TRANSFER TIME). - The mode and extmode parameters control the behaviour of the internal and external shutters. To have an external shutter open and close automatically in an experiment, set the mode parameter to Open and set the extmode parameter to Auto. To have an internal shutter open and close automatically in an experiment, set the extmode parameter to Open and set the mode parameter to Auto. - To not use any shutter in the experiment, set both shutter modes to permanently open. - - Synopsis: - ret = SetShutterEx(typ, mode, closingtime, openingtime, extmode) - - Inputs: - typ - Shutter type: - 0 - Output TTL low signal to open shutter - 1 - Output TTL high signal to open shutter - mode - Internal shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - closingtime - time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - extmode - External shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_P5INVALID - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support shutter control. - DRV_P1INVALID - Invalid TTL type. - DRV_P2INVALID - Invalid internal mode - DRV_P3INVALID - Invalid time to open. - DRV_P4INVALID - Invalid time to close - - C++ Equiv: - unsigned int SetShutterEx(int typ, int mode, int closingtime, int openingtime, int extmode); - - See Also: - SetShutter - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cextmode = c_int(extmode) - ret = self.dll.SetShutterEx(ctyp, cmode, cclosingtime, copeningtime, cextmode) - return (ret) - - def SetShutters(self, typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetShutters(typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2) - - Inputs: - typ - - mode - - closingtime - - openingtime - - exttype - - extmode - - dummy1 - - dummy2 - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetShutters(int typ, int mode, int closingtime, int openingtime, int exttype, int extmode, int dummy1, int dummy2); - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cexttype = c_int(exttype) - cextmode = c_int(extmode) - cdummy1 = c_int(dummy1) - cdummy2 = c_int(dummy2) - ret = self.dll.SetShutters(ctyp, cmode, cclosingtime, copeningtime, cexttype, cextmode, cdummy1, cdummy2) - return (ret) - - def SetSifComment(self, comment): - ''' - Description: - This function will set the user text that will be added to any sif files created with the SaveAsSif function. The stored comment can be cleared by passing NULL or an empty text string. - - Synopsis: - ret = SetSifComment(comment) - - Inputs: - comment - The comment to add to new sif files. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sif comment set. - - C++ Equiv: - unsigned int SetSifComment(char * comment); - - See Also: - SaveAsSif SaveAsCommentedSif SaveAsSif SetReadMode - - Note: To add a comment to a SIF file that will not be used in any future SIF files that are saved, use the function SaveAsCommentedSif. - - ''' - ccomment = comment - ret = self.dll.SetSifComment(ccomment) - return (ret) - - def SetSingleTrack(self, centre, height): - ''' - Description: - This function will set the single track parameters. The parameters are validated in the following order: centre row and then track height. - - Synopsis: - ret = SetSingleTrack(centre, height) - - Inputs: - centre - centre row of track: - Valid - range 0 to number of vertical pixels. - height - height of track: - Valid - range > 1 (maximum value depends on centre row and number of vertical pixels). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Center row invalid. - DRV_P2INVALID - Track height invalid. - - C++ Equiv: - unsigned int SetSingleTrack(int centre, int height); - - See Also: - SetReadMode - - ''' - ccentre = c_int(centre) - cheight = c_int(height) - ret = self.dll.SetSingleTrack(ccentre, cheight) - return (ret) - - def SetSingleTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Single Track read mode. - - Synopsis: - ret = SetSingleTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetSingleTrackHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetSingleTrackHBin(cbin) - return (ret) - - def SetSpool(self, active, method, path, framebuffersize): - ''' - Description: - This function will enable and disable the spooling of acquired data to the hard disk or to the RAM. - With spooling method 0, each scan in the series will be saved to a separate file composed of a sequence of 32-bit integers. - With spooling method 1 the type of data in the output files depends on what type of acquisition is taking place (see below). - Spooling method 2 writes out the data to file as 16-bit integers. - Spooling method 3 creates a directory structure for storing images where multiple images may appear in each file within the directory structure and the files may be spread across multiple directories. Like method 1 the data type of the image pixels depends on whether accumulate mode is being used. - Method 4 Creates a RAM disk for storing images so you should ensure that there is enough free RAM to store the full acquisition. - Methods 5, 6 and 7 can be used to directly spool out to a particular file type, either FITS, SIF or TIFF respectively. In the case of FITS and TIFF the data will be written out as 16-bit values. - Method 8 is similar to method 3, however the data is first compressed before writing to disk. In some circumstances this may improve the maximum rate of writing images to disk, however as the compression can be very CPU intensive this option may not be suitable on slower processors. - The data is stored in row order starting with the row nearest the readout register. With the exception of methods 5, 6 and 7, the data acquired during a spooled acquisition can be retrieved through the normal functions. This is a change to previous versions; it is no longer necessary to load the data from disk from your own application. - - Synopsis: - ret = SetSpool(active, method, path, framebuffersize) - - Inputs: - active - Enable/disable spooling: - 0 - Disable spooling. - 1 - Enable spooling. - method - Indicates the format of the files written to disk: - 0 - Files contain sequence of 32-bit integers - 1 - Format of data in files depends on whether multiple accumulations are being taken for each scan. Format will be 32-bit integer if data is being accumulated each scan; otherwise the format will be 16-bit integer. - 2 - Files contain sequence of 16-bit integers. - 3 - Multiple directory structure with multiple images per file and multiple files per directory. - 4 - Spool to RAM disk. - 5 - Spool to 16-bit Fits File. - 6 - Spool to Andor Sif format. - 7 - Spool to 16-bit Tiff File. - 8 - Similar to method 3 but with data compression. - path - String containing the filename stem. May also contain the path to the directory into which the files are to be stored. - framebuffersize - This sets the size of an internal circular buffer used as temporary storage. The value is the total number images the buffer can hold, not the size in bytes. Typical value would be 10. This value would be increased in situations where the computer is not able to spool the data to disk at the required rate. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - - C++ Equiv: - unsigned int SetSpool(int active, int method, char * path, int framebuffersize); - - See Also: - GetSpoolProgress - - Note: Spooled images will not be post processed, i.e. flipped or rotated. - - ''' - cactive = c_int(active) - cmethod = c_int(method) - cpath = path - cframebuffersize = c_int(framebuffersize) - ret = self.dll.SetSpool(cactive, cmethod, cpath, cframebuffersize) - return (ret) - - def SetSpoolThreadCount(self, count): - ''' - Description: - This function sets the number of parallel threads used for writing data to disk when spooling is enabled. Increasing this to a value greater than the default of 1, can sometimes improve the data rate to the hard disk particularly with Solid State hard disks. In other cases increasing this value may actually reduce the rate at which data is written to disk. - - Synopsis: - ret = SetSpoolThreadCount(count) - - Inputs: - count - The number of threads to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread count is set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid thread count. - - C++ Equiv: - unsigned int SetSpoolThreadCount(int count); - - See Also: - SetSpool - - Note: This feature is currently only available when using the Neo camera. - - ''' - ccount = c_int(count) - ret = self.dll.SetSpoolThreadCount(ccount) - return (ret) - - def SetStorageMode(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetStorageMode(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetStorageMode(long mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetStorageMode(cmode) - return (ret) - - def SetTECEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the TEC has overheated or returned to a normal state. To determine what event has actually occurred call the GetTECStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetTECEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetTECEvent(HANDLE driverEvent); - - See Also: - GetTECStatus - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetTECEvent(cdriverEvent) - return (ret) - - def SetTemperature(self, temperature): - ''' - Description: - This function will set the desired temperature of the detector. To turn the cooling ON and OFF use the CoolerONCoolerON and CoolerOFFCoolerOFF function respectively. - - Synopsis: - ret = SetTemperature(temperature) - - Inputs: - temperature - the temperature in Centigrade.: - Valid - range is given by GetTemperatureRangeGetTemperatureRange - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Temperature invalid. - DRV_NOT_SUPPORTED - The camera does not support setting the temperature. - - C++ Equiv: - unsigned int SetTemperature(int temperature); - - See Also: - CoolerOFF CoolerON GetTemperature GetTemperatureF GetTemperatureRange - - Note: Not available on Luca R cameras - automatically cooled to -20C. - - ''' - ctemperature = c_int(temperature) - ret = self.dll.SetTemperature(ctemperature) - return (ret) - - def SetTemperatureEvent(self, temperatureEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetTemperatureEvent(temperatureEvent) - - Inputs: - temperatureEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetTemperatureEvent(at_32 temperatureEvent); - - ''' - ctemperatureEvent = c_int(temperatureEvent) - ret = self.dll.SetTemperatureEvent(ctemperatureEvent) - return (ret) - - def SetTriggerInvert(self, mode): - ''' - Description: - This function will set whether an acquisition will be triggered on a rising or falling edge external trigger. - - Synopsis: - ret = SetTriggerInvert(mode) - - Inputs: - mode - trigger mode: - 0 - Rising Edge - 1 - Falling Edge - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetTriggerInvert(int mode); - - See Also: - Trigger Modes SetTriggerMode SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerInvert(cmode) - return (ret) - - def SetTriggerLevel(self, f_level): - ''' - Description: - This function sets the trigger voltage which the system will use. - - Synopsis: - ret = SetTriggerLevel(f_level) - - Inputs: - f_level - trigger voltage - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetTriggerLevel(float f_level); - - See Also: - GetCapabilities GetTriggerLevelRange - - ''' - cf_level = c_float(f_level) - ret = self.dll.SetTriggerLevel(cf_level) - return (ret) - - def SetTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode that the camera will operate in. - - Synopsis: - ret = SetTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - 6 - External Start - 7 - External Exposure (Bulb) - 9 - External FVB EM (only valid for EM Newton models in FVB mode) 10. Software Trigger - 12 - External Charge Shifting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetTriggerMode(int mode); - - See Also: - Trigger Modes SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerMode(cmode) - return (ret) - - def SetUserEvent(self, userEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUserEvent(userEvent) - - Inputs: - userEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUserEvent(at_32 userEvent); - - ''' - cuserEvent = c_int(userEvent) - ret = self.dll.SetUserEvent(cuserEvent) - return (ret) - - def SetUSGenomics(self, width, height): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUSGenomics(width, height) - - Inputs: - width - - height - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUSGenomics(long width, long height); - - ''' - cwidth = c_int(width) - cheight = c_int(height) - ret = self.dll.SetUSGenomics(cwidth, cheight) - return (ret) - - def SetVerticalRowBuffer(self, rows): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVerticalRowBuffer(rows) - - Inputs: - rows - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVerticalRowBuffer(int rows); - - ''' - crows = c_int(rows) - ret = self.dll.SetVerticalRowBuffer(crows) - return (ret) - - def SetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVerticalSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVerticalSpeed(int index); // deprecated - - See Also: - GetNumberVerticalSpeeds GetVerticalSpeed - - Note: Deprecated by SetVSSpeedSetVSSpeed. - - ''' - cindex = c_int(index) - ret = self.dll.SetVerticalSpeed(cindex) - return (ret) - - def SetVirtualChip(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVirtualChip(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVirtualChip(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetVirtualChip(cstate) - return (ret) - - def SetVSAmplitude(self, index): - ''' - Description: - If you choose a high readout speed (a low readout time), then you should also consider increasing the amplitude of the Vertical Clock Voltage. - There are five levels of amplitude available for you to choose from: - * Normal - * +1 - * +2 - * +3 - * +4 - Exercise caution when increasing the amplitude of the vertical clock voltage, since higher clocking voltages may result in increased clock-induced charge (noise) in your signal. In general, only the very highest vertical clocking speeds are likely to benefit from an increased vertical clock voltage amplitude. - - Synopsis: - ret = SetVSAmplitude(index) - - Inputs: - index - desired Vertical Clock Voltage Amplitude: - 0 - Normal - 1 ->4 - Increasing Clock voltage Amplitude - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplitude set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Your system does not support this feature - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid amplitude parameter. - - C++ Equiv: - unsigned int SetVSAmplitude(int index); - - Note: Available in iXon, iKon and Newton - full range of amplitude levels is not available on all compatible cameras. - - ''' - cindex = c_int(index) - ret = self.dll.SetVSAmplitude(cindex) - return (ret) - - def SetVSSpeed(self, index): - ''' - Description: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVSSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVSSpeed(int index); - - See Also: - GetNumberVSSpeeds GetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - ret = self.dll.SetVSSpeed(cindex) - return (ret) - - def ShutDown(self): - ''' - Description: - This function will close the AndorMCD system down. - - Synopsis: - ret = ShutDown() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System shut down. - - C++ Equiv: - unsigned int ShutDown(void); - - See Also: - CoolerOFF CoolerON SetTemperature GetTemperature - - Note: 1. For Classic & ICCD systems, the temperature of the detector should be above -20C before shutting down the system. - 2. When dynamically loading a DLL which is statically linked to the SDK library, ShutDown MUST be called before unloading. - - ''' - ret = self.dll.ShutDown() - return (ret) - - def StartAcquisition(self): - ''' - Description: - This function starts an acquisition. The status of the acquisition can be monitored via GetStatus(). - - Synopsis: - ret = StartAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition started. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int StartAcquisition(void); - - See Also: - GetStatus GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - ret = self.dll.StartAcquisition() - return (ret) - - def UnMapPhysicalAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = UnMapPhysicalAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int UnMapPhysicalAddress(void); - - ''' - ret = self.dll.UnMapPhysicalAddress() - return (ret) - - def WaitForAcquisition(self): - ''' - Description: - WaitForAcquisition can be called after an acquisition is started using StartAcquisitionStartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. - Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWaitCancelWait. - An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - If a second event occurs before the first one has been acknowledged, the first one will be ignored. Care should be taken in this case, as you may have to use CancelWaitCancelWait to exit the function. - - Synopsis: - ret = WaitForAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred - DRV_NOT_INITIALIZED - System not initialized. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(e.g. CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisition(void); - - See Also: - StartAcquisition CancelWait - - ''' - ret = self.dll.WaitForAcquisition() - return (ret) - - def WaitForAcquisitionByHandle(self, cameraHandle): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - - Synopsis: - ret = WaitForAcquisitionByHandle(cameraHandle) - - Inputs: - cameraHandle - handle of camera to put into wait state. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandle(long cameraHandle); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionTimeOut WaitForAcquisitionByHandleTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.WaitForAcquisitionByHandle(ccameraHandle) - return (ret) - - def WaitForAcquisitionByHandleTimeOut(self, cameraHandle, iTimeOutMs): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionByHandleTimeOut(cameraHandle, iTimeOutMs) - - Inputs: - cameraHandle - handle of camera to put into wait state. - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandleTimeOut(long cameraHandle, int iTimeOutMs); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionByHandleTimeOut(ccameraHandle, ciTimeOutMs) - return (ret) - - def WaitForAcquisitionTimeOut(self, iTimeOutMs): - ''' - Description: - WaitForAcquisitionTimeOut can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - Inputs: - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionTimeOut(int iTimeOutMs); - - See Also: - CancelWait StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionByHandleTimeOut - - ''' - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionTimeOut(ciTimeOutMs) - return (ret) - - def WhiteBalance(self): - ''' - Description: - For colour sensors only - Calculates the red and blue relative to green factors to white balance a colour image using the parameters stored in info. - Before passing the address of an WhiteBalanceInfo structure to the function the iSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - nfo-> iSize = sizeof(WhiteBalanceInfo); - Below is the WhiteBalanceInfo structure definition and a description of its members: - struct WHITEBALANCEINFO { - int iSize; // Structure size. - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to used to calculate white balance. - int iROI_left; // Region Of interest from which white balance is calculated - int iROI_right; // Region Of interest from which white balance is calculated - int iROI_top; // Region Of interest from which white balance is calculated - int iROI_bottom; // Region Of interest from which white balance is calculated - WhiteBalanceInfo; - iX and iY are the image dimensions. The number of elements of the input, red, green and blue arrays are iX x iY. - iAlgorithm sets the algorithm to use. The function sums all the colour values per each colour field within the Region Of interest (ROI) and calculates the relative to green values as: 0) _fRelR = GreenSum / RedSum and _fRelB = GreenSum / BlueSum; 1) _fRelR = 2/3 GreenSum / RedSum and _fRelB = 2/3 GreenSum / BlueSum, giving more importance to the green field. - iROI_left, iROI_right, iROI_top and iROI_bottom define the ROI with the constraints: - iROI_left0 <= iROI_left < iROI_right <= iX and 0 <= iROI_ bottom < iROI_ top <= iX - - Synopsis: - (ret, wRed, wGreen, wBlue, fRelR, fRelB, info) = WhiteBalance() - - Inputs: - None - - Outputs: - ret - Function Return Code: - SUCCESS - White balance calculated. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Invalid pointer (i.e. NULL). - DRV_P6INVALID - One or more parameters in info is out of range - DRV_DIVIDE_BY_ZERO_ERROR - The sum of the green field within the ROI is zero. _fRelR and _fRelB are set to 1 - wRed - pointer to red field. - wGreen - pointer to green field. - wBlue - pointer to blue field. - fRelR - pointer to the relative to green red factor. - fRelB - pointer to the relative to green blue factor. - info - pointer to white balance information structure - - C++ Equiv: - unsigned int WhiteBalance(WORD * wRed, WORD * wGreen, WORD * wBlue, float * fRelR, float * fRelB, WhiteBalanceInfo * info); - - See Also: - DemosaicImage GetMostRecentColorImage16 - - ''' - cwRed = c_short() - cwGreen = c_short() - cwBlue = c_short() - cfRelR = c_float() - cfRelB = c_float() - cinfo = WhiteBalanceInfo() - ret = self.dll.WhiteBalance(byref(cwRed), byref(cwGreen), byref(cwBlue), byref(cfRelR), byref(cfRelB), byref(cinfo)) - return (ret, cwRed.value, cwGreen.value, cwBlue.value, cfRelR.value, cfRelB.value, cinfo) - diff --git a/Andor/andorv2/doc/Makefile b/Andor/andorv2/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/Andor/andorv2/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/Andor/andorv2/doc/conf.py b/Andor/andorv2/doc/conf.py deleted file mode 100644 index f7c5161..0000000 --- a/Andor/andorv2/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'Andor' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'Novatech409Bdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'Novatech409B.tex', 'Novatech409B Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'novatech409', 'Novatech409B Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'Novatech409B', 'Novatech409B Documentation', - author, 'Novatech409B', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/Andor/andorv2/doc/index.rst b/Andor/andorv2/doc/index.rst deleted file mode 100644 index 8764c75..0000000 --- a/Andor/andorv2/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: novatech409b.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: novatech409b.aqctl_novatech409b.get_argparser - :prog: aqctl_novatech409b - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/Andor/andorv2/setup.py b/Andor/andorv2/setup.py deleted file mode 100644 index 84af854..0000000 --- a/Andor/andorv2/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="andor", - install_requires=[],#"sipyco", "asyncserial"], - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_andor = andor.aqctl_andor:main", - ], - }, -) diff --git a/Andor/sdk's/sdk2/Andor.py b/Andor/sdk's/sdk2/Andor.py deleted file mode 100644 index 20fbd6a..0000000 --- a/Andor/sdk's/sdk2/Andor.py +++ /dev/null @@ -1,132 +0,0 @@ -from atmcd import * - -class Andor(): - def __init__(self): - print("Intialising Camera") - cam = atmcd() #load the atmcd library - (ret) = cam.Initialize("/usr/local/etc/andor") #initialise camera - print("Initialize returned",ret) - - if atmcd.DRV_SUCCESS==ret: - self.Initialize() - else: - print("Cannot continue, could not initialise camera") - - - def Initialize(self): - - #(ret, totalCameras) = cam.GetAvailableCameras() - - (ret, iSerialNumber) = cam.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = cam.CoolerON() - print("Function CoolerON returned",ret) - #(ret) = cam.CoolerOFF() - #(ret, iCoolerStatus) = IsCoolerOn() - - - #(ret, temperature) = GetTemperature() - - #(ret, gain) = cam.SetEMCCDGain() - #(ret, low, high) = cam.GetEMGainRange() - - #(ret, noGains) = cam.GetNumberPreAmpGains() - #(ret, gain) = GetPreAmpGain(index) - #ret = SetPreAmpGain(index) - #ret = SetShutter(typ, mode, closingtime, openingtime) - - (ret) = cam.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - # Inputs: - # mode - the acquisition mode.: - # 1 - Single Scan - # 2 - Accumulate - # 3 - Kinetics - # 4 - Fast Kinetics - # 5 - Run till abort - - #ret = SetCameraLinkMode(mode) # 1 enables, 0 disables - - #ret = SetCropMode(active, cropHeight, reserved) - - #ret = SetFanMode(mode) - - # ret = SetCountConvertMode(Mode) - # Mode - : - # 0 - Data in Counts - # 1 - Data in Electrons - # 2 - Data in Photons - - #ret = SetHorizontalSpeed(index) - - - (ret) = cam.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = cam.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - #ret = SetFastExtTrigger(mode) - - (ret, xpixels, ypixels) = cam.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = cam.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - # Inputs: - # hbin - number of pixels to bin horizontally. - # vbin - number of pixels to bin vertically. - # hstart - Start column (inclusive). - # hend - End column (inclusive). - # vstart - Start row (inclusive). - # vend - End row (inclusive). - # ret = SetFullImage(hbin, vbin) - - #ret = SetImageRotate(iRotate) - #ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - #SetPhotonCounting(self, state): - - (ret) = cam.SetExposureTime(0.01) # seconds - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = cam.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - def PrepareAcquisition(self): - (ret) = cam.PrepareAcquisition() # reads current acquisition setup and allocates memory. Is called automatically by StartAcuiqision if not run, but can take a while. - print("Function PrepareAcquisition returned",ret) - - - def StartAcquisition(self): - #Run after PrepareAcquisition to start waiting for trigger. - (ret) = cam.StartAcquisition() - print("Function StartAcquisition returned",ret) - #GetStatus() - - def WaitForAcquisition(self): - - (ret) = cam.WaitForAcquisition() # calling thread is put to sleep until Acquisition Event occurs. - print("Function WaitForAcquisition returned",ret) - #ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - # def CancelWait(self): - # (ret) = cam.CancelWait() - # print("Cancel wait",ret) - - def GetImage(self): - - imageSize = xpixels*ypixels - (ret, fullFrameBuffer) = cam.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #(ret, arr, validfirst, validlast) = cam.GetImages(first, last, size) - #(ret, first, last) = cam.GetNumberNewImages() - #(ret, index) = GetTotalNumberImagesAcquired() - return fullFrameBuffer - - def ShutDown(self): - #Clean up - (ret) = cam.ShutDown() - print("Shutdown returned",ret) \ No newline at end of file diff --git a/Andor/sdk's/sdk2/CameraInformation.py b/Andor/sdk's/sdk2/CameraInformation.py deleted file mode 100644 index a98bdf3..0000000 --- a/Andor/sdk's/sdk2/CameraInformation.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -from atmcd import * - -print("Camera Information Example") - -numberOfImages=10 - -print("Intialising Camera") -sdkObject = atmcd() #load the atmcd library -(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera -print("Initialize returned",ret) - -if atmcd.DRV_SUCCESS==ret: - - (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - print("Serial No : ",iSerialNumber) - - (ret, headModel) = sdkObject.GetHeadModel() - print("Head Model : ",headModel) - - (ret, caps) = sdkObject.GetCapabilities() - if caps.ulCameraType == atmcd.AC_CAMERATYPE_PDA : - print("Camera Type : AC_CAMERATYPE_PDA") - if caps.ulCameraType == atmcd.AC_CAMERATYPE_IXON : - print("Camera Type : AC_CAMERATYPE_IXON") - if caps.ulCameraType == atmcd.AC_CAMERATYPE_ICCD: - print("Camera Type : AC_CAMERATYPE_ICCD") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_EMCCD: - print("Camera Type : AC_CAMERATYPE_EMCCD") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_CCD: - print("Camera Type : AC_CAMERATYPE_CCD") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_ISTAR: - print("Camera Type : AC_CAMERATYPE_ISTAR") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_VIDEO: - print("Camera Type : AC_CAMERATYPE_VIDEO") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_NEWTON: - print("Camera Type : AC_CAMERATYPE_NEWTON") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_SURCAM: - print("Camera Type : AC_CAMERATYPE_SURCAM") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_USBICCD: - print("Camera Type : AC_CAMERATYPE_USBICCD") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_LUCA: - print("Camera Type : AC_CAMERATYPE_LUCA") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_RESERVED: - print("Camera Type : AC_CAMERATYPE_RESERVED") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_IKON: - print("Camera Type : AC_CAMERATYPE_IKON") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_INGAAS: - print("Camera Type : AC_CAMERATYPE_INGAAS") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_CLARA: - print("Camera Type : AC_CAMERATYPE_CLARA") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_USBISTAR: - print("Camera Type : AC_CAMERATYPE_USBISTAR") - - if caps.ulCameraType == atmcd.AC_CAMERATYPE_IXONULTRA: - print("Camera Type : AC_CAMERATYPE_IXONULTRA") - - - - #Clean up - (ret) = sdkObject.ShutDown() - print("Shutdown returned",ret) - -else: - print("Cannot continue, could not initialise camera") - diff --git a/Andor/sdk's/sdk2/FVB.py b/Andor/sdk's/sdk2/FVB.py deleted file mode 100644 index 6200fca..0000000 --- a/Andor/sdk's/sdk2/FVB.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -from atmcd import * - -print("FVB Example") - -print("Intialising Camera") -sdkObject = atmcd() #load the atmcd library -(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera -print("Initialize returned",ret) - -if atmcd.DRV_SUCCESS==ret: - - (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = sdkObject.CoolerON() - print("Function CoolerON returned",ret) - - (ret) = sdkObject.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - - (ret) = sdkObject.SetReadMode(0) - print("Function SetReadMode returned",ret,"mode = FVB") - - (ret) = sdkObject.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - (ret, xpixels, ypixels) = sdkObject.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - - (ret) = sdkObject.SetExposureTime(0.01) - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - (ret) = sdkObject.PrepareAcquisition() - print("Function PrepareAcquisition returned",ret) - - #Perform Acquisition - (ret) = sdkObject.StartAcquisition() - print("Function StartAcquisition returned",ret) - - (ret) = sdkObject.WaitForAcquisition() - print("Function WaitForAcquisition returned",ret) - - imageSize = xpixels - (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #Clean up - (ret) = sdkObject.ShutDown() - print("Shutdown returned",ret) - -else: - print("Cannot continue, could not initialise camera") - diff --git a/Andor/sdk's/sdk2/KineticSeries.py b/Andor/sdk's/sdk2/KineticSeries.py deleted file mode 100644 index c5aa6b2..0000000 --- a/Andor/sdk's/sdk2/KineticSeries.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -from atmcd import * - -print("Kinetic Series Example") - -numberOfImages=10 - -print("Intialising Camera") -sdkObject = atmcd() #load the atmcd library -(ret) = sdkObject.Initialize("C:/Program Files/Andor SDK") #initialise camera #C:\Program Files\Andor SDK -print("Initialize returned",ret) - -if atmcd.DRV_SUCCESS==ret: - - (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = sdkObject.CoolerON() - print("Function CoolerON returned",ret) - - (ret) = sdkObject.SetAcquisitionMode(3) - print("Function SetAcquisitionMode returned",ret,"mode = Kinetic Series") - - (ret) = sdkObject.SetNumberKinetics(numberOfImages); - print("Function SetNumberKinetics returned",ret,"numberOfImages =",numberOfImages) - - (ret) = sdkObject.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = sdkObject.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - (ret, xpixels, ypixels) = sdkObject.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - - (ret) = sdkObject.SetExposureTime(0.01) - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - (ret) = sdkObject.PrepareAcquisition() - print("Function PrepareAcquisition returned",ret) - - #Perform Acquisition - (ret) = sdkObject.StartAcquisition() - print("Function StartAcquisition returned",ret) - - imageSize = xpixels*ypixels - - for currentImage in range(numberOfImages): - - print("Acquiring image",currentImage) - - (ret) = sdkObject.WaitForAcquisition() - print("Function WaitForAcquisition returned",ret) - - (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #Clean up - (ret) = sdkObject.ShutDown() - print("Shutdown returned",ret) - -else: - print("Cannot continue, could not initialise camera") - diff --git a/Andor/sdk's/sdk2/README b/Andor/sdk's/sdk2/README deleted file mode 100644 index 91ab431..0000000 --- a/Andor/sdk's/sdk2/README +++ /dev/null @@ -1,12 +0,0 @@ -Python Wrapper Readme - -The python module which wraps the SDK2 is atmcd.py - -There are 4 examples: -* CameraInformation.py - Prints basic information about the camera -* SingleScan.py - Performs a Single image acquisition -* KineticSeries.py - Performs a Kinetic Series Acquisition -* FVB.py - Performs an acqusition with Full Vertical Binning - -If the AndorSDK is installed to a directory that is not the default install location, i.e. not c:\Program Files\Andor SDK on Windows or /usr/local/lib/libandor.so on Linux, please update the __init__ (atmcd.py line 50) function accordingly. - diff --git a/Andor/sdk's/sdk2/SingleScan.py b/Andor/sdk's/sdk2/SingleScan.py deleted file mode 100644 index 5026b52..0000000 --- a/Andor/sdk's/sdk2/SingleScan.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -from atmcd import * -import numpy as np -import matplotlib.pyplot as plt - -print("Single Scan Example") - -print("Intialising Camera") -sdkObject = atmcd() #load the atmcd library -(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK -print("Initialize returned",ret) - -if atmcd.DRV_SUCCESS==ret: - - (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - print("GetCameraSerialNumb er returned:",ret,"Serial No:",iSerialNumber) - - #configure the acquisition - (ret) = sdkObject.CoolerON() - print("Function CoolerON returned",ret) - - (ret) = sdkObject.SetAcquisitionMode(1) - print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") - - (ret) = sdkObject.SetReadMode(4) - print("Function SetReadMode returned",ret,"mode = Image") - - (ret) = sdkObject.SetTriggerMode(0) - print("Function SetTriggerMode returned",ret,"mode = Internal") - - (ret, xpixels, ypixels) = sdkObject.GetDetector() - print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) - - (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) - print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) - - (ret) = sdkObject.SetExposureTime(0.01) - print("Function SetExposureTime returned",ret,"time = 0.01s") - - (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() - print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) - - (ret) = sdkObject.PrepareAcquisition() - print("Function PrepareAcquisition returned",ret) - - #Perform Acquisition - (ret) = sdkObject.StartAcquisition() - print("Function StartAcquisition returned",ret) - - (ret) = sdkObject.WaitForAcquisition() - print("Function WaitForAcquisition returned",ret) - - imageSize = xpixels*ypixels - (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) - print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) - - #Clean up - (ret) = sdkObject.ShutDown() - print("Shutdown returned",ret) - - #David's addition - image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array - plt.imshow(image) - -else: - print("Cannot continue, could not initialise camera") - diff --git a/Andor/sdk's/sdk2/__pycache__/atmcd.cpython-37.pyc b/Andor/sdk's/sdk2/__pycache__/atmcd.cpython-37.pyc deleted file mode 100644 index bbb5f8a..0000000 Binary files a/Andor/sdk's/sdk2/__pycache__/atmcd.cpython-37.pyc and /dev/null differ diff --git a/Andor/sdk's/sdk2/atmcd.py b/Andor/sdk's/sdk2/atmcd.py deleted file mode 100644 index 03a3281..0000000 --- a/Andor/sdk's/sdk2/atmcd.py +++ /dev/null @@ -1,12230 +0,0 @@ -from ctypes import * -import time -import platform -import sys - -MAX_PATH = 256 - -class ColorDemosaicInfo(Structure) : - _fields_ = [("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iXPhase", c_int), - ("iYPhase", c_int), - ("iBackground", c_int)] -class AndorCapabilities(Structure) : - _fields_ = [("ulSize", c_ulong), - ("ulAcqModes", c_ulong), - ("ulReadModes", c_ulong), - ("ulTriggerModes", c_ulong), - ("ulCameraType", c_ulong), - ("ulPixelMode", c_ulong), - ("ulSetFunctions", c_ulong), - ("ulGetFunctions", c_ulong), - ("ulFeatures", c_ulong), - ("ulPCICard", c_ulong), - ("ulEMGainCapability", c_ulong), - ("ulFTReadModes", c_ulong)] -class WhiteBalanceInfo(Structure) : - _fields_ = [("iSize", c_int), - ("iX", c_int), - ("iY", c_int), - ("iAlgorithm", c_int), - ("iROI_left", c_int), - ("iROI_right", c_int), - ("iROI_top", c_int), - ("iROI_bottom", c_int), - ("iOperation", c_int)] -class SYSTEMTIME(Structure) : - _fields_ = [("wYear", c_short), - ("wMonth", c_short), - ("wDayOfWeek", c_short), - ("wDay", c_short), - ("wHour", c_short), - ("wMinute", c_short), - ("wSecond", c_short), - ("wMilliseconds", c_short)] - -class atmcd: - def __init__(self): - if sys.platform == "linux2": - dllname = "/usr/local/lib/libandor.so" - self.dll = cdll.LoadLibrary(dllname) - elif sys.platform == "win32": - if platform.architecture()[0] == "64bit" : - dllname = "C:\\Program Files\\Andor SDK\\atmcd64d.dll" - else: - dllname = "C:\\Program Files\\Andor SDK\\atmcd32d.dll" - self.dll = windll.LoadLibrary(dllname) - else: - print("Cannot detect operating system, will now stop") - raise - - # Error Code Returns and Definitions - DRV_ERROR_CODES = 20001 - DRV_SUCCESS = 20002 - DRV_VXDNOTINSTALLED = 20003 - DRV_ERROR_SCAN = 20004 - DRV_ERROR_CHECK_SUM = 20005 - DRV_ERROR_FILELOAD = 20006 - DRV_UNKNOWN_FUNCTION = 20007 - DRV_ERROR_VXD_INIT = 20008 - DRV_ERROR_ADDRESS = 20009 - DRV_ERROR_PAGELOCK = 20010 - DRV_ERROR_PAGEUNLOCK = 20011 - DRV_ERROR_BOARDTEST = 20012 - DRV_ERROR_ACK = 20013 - DRV_ERROR_UP_FIFO = 20014 - DRV_ERROR_PATTERN = 20015 - DRV_ACQUISITION_ERRORS = 20017 - DRV_ACQ_BUFFER = 20018 - DRV_ACQ_DOWNFIFO_FULL = 20019 - DRV_PROC_UNKONWN_INSTRUCTION = 20020 - DRV_ILLEGAL_OP_CODE = 20021 - DRV_KINETIC_TIME_NOT_MET = 20022 - DRV_ACCUM_TIME_NOT_MET = 20023 - DRV_NO_NEW_DATA = 20024 - DRV_PCI_DMA_FAIL = 20025 - DRV_SPOOLERROR = 20026 - DRV_SPOOLSETUPERROR = 20027 - DRV_FILESIZELIMITERROR = 20028 - DRV_ERROR_FILESAVE = 20029 - DRV_TEMPERATURE_CODES = 20033 - DRV_TEMPERATURE_OFF = 20034 - DRV_TEMPERATURE_NOT_STABILIZED = 20035 - DRV_TEMPERATURE_STABILIZED = 20036 - DRV_TEMPERATURE_NOT_REACHED = 20037 - DRV_TEMPERATURE_OUT_RANGE = 20038 - DRV_TEMPERATURE_NOT_SUPPORTED = 20039 - DRV_TEMPERATURE_DRIFT = 20040 - DRV_TEMP_CODES = 20033 - DRV_TEMP_OFF = 20034 - DRV_TEMP_NOT_STABILIZED = 20035 - DRV_TEMP_STABILIZED = 20036 - DRV_TEMP_NOT_REACHED = 20037 - DRV_TEMP_OUT_RANGE = 20038 - DRV_TEMP_NOT_SUPPORTED = 20039 - DRV_TEMP_DRIFT = 20040 - DRV_GENERAL_ERRORS = 20049 - DRV_INVALID_AUX = 20050 - DRV_COF_NOTLOADED = 20051 - DRV_FPGAPROG = 20052 - DRV_FLEXERROR = 20053 - DRV_GPIBERROR = 20054 - DRV_EEPROMVERSIONERROR = 20055 - DRV_DATATYPE = 20064 - DRV_DRIVER_ERRORS = 20065 - DRV_P1INVALID = 20066 - DRV_P2INVALID = 20067 - DRV_P3INVALID = 20068 - DRV_P4INVALID = 20069 - DRV_INIERROR = 20070 - DRV_COFERROR = 20071 - DRV_ACQUIRING = 20072 - DRV_IDLE = 20073 - DRV_TEMPCYCLE = 20074 - DRV_NOT_INITIALIZED = 20075 - DRV_P5INVALID = 20076 - DRV_P6INVALID = 20077 - DRV_INVALID_MODE = 20078 - DRV_INVALID_FILTER = 20079 - DRV_I2CERRORS = 20080 - DRV_I2CDEVNOTFOUND = 20081 - DRV_I2CTIMEOUT = 20082 - DRV_P7INVALID = 20083 - DRV_P8INVALID = 20084 - DRV_P9INVALID = 20085 - DRV_P10INVALID = 20086 - DRV_P11INVALID = 20087 - DRV_USBERROR = 20089 - DRV_IOCERROR = 20090 - DRV_VRMVERSIONERROR = 20091 - DRV_GATESTEPERROR = 20092 - DRV_USB_INTERRUPT_ENDPOINT_ERROR = 20093 - DRV_RANDOM_TRACK_ERROR = 20094 - DRV_INVALID_TRIGGER_MODE = 20095 - DRV_LOAD_FIRMWARE_ERROR = 20096 - DRV_DIVIDE_BY_ZERO_ERROR = 20097 - DRV_INVALID_RINGEXPOSURES = 20098 - DRV_BINNING_ERROR = 20099 - DRV_INVALID_AMPLIFIER = 20100 - DRV_INVALID_COUNTCONVERT_MODE = 20101 - DRV_ERROR_NOCAMERA = 20990 - DRV_NOT_SUPPORTED = 20991 - DRV_NOT_AVAILABLE = 20992 - DRV_ERROR_MAP = 20115 - DRV_ERROR_UNMAP = 20116 - DRV_ERROR_MDL = 20117 - DRV_ERROR_UNMDL = 20118 - DRV_ERROR_BUFFSIZE = 20119 - DRV_ERROR_NOHANDLE = 20121 - DRV_GATING_NOT_AVAILABLE = 20130 - DRV_FPGA_VOLTAGE_ERROR = 20131 - DRV_OW_CMD_FAIL = 20150 - DRV_OWMEMORY_BAD_ADDR = 20151 - DRV_OWCMD_NOT_AVAILABLE = 20152 - DRV_OW_NO_SLAVES = 20153 - DRV_OW_NOT_INITIALIZED = 20154 - DRV_OW_ERROR_SLAVE_NUM = 20155 - DRV_MSTIMINGS_ERROR = 20156 - DRV_OA_NULL_ERROR = 20173 - DRV_OA_PARSE_DTD_ERROR = 20174 - DRV_OA_DTD_VALIDATE_ERROR = 20175 - DRV_OA_FILE_ACCESS_ERROR = 20176 - DRV_OA_FILE_DOES_NOT_EXIST = 20177 - DRV_OA_XML_INVALID_OR_NOT_FOUND_ERROR = 20178 - DRV_OA_PRESET_FILE_NOT_LOADED = 20179 - DRV_OA_USER_FILE_NOT_LOADED = 20180 - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED = 20181 - DRV_OA_INVALID_FILE = 20182 - DRV_OA_FILE_HAS_BEEN_MODIFIED = 20183 - DRV_OA_BUFFER_FULL = 20184 - DRV_OA_INVALID_STRING_LENGTH = 20185 - DRV_OA_INVALID_CHARS_IN_NAME = 20186 - DRV_OA_INVALID_NAMING = 20187 - DRV_OA_GET_CAMERA_ERROR = 20188 - DRV_OA_MODE_ALREADY_EXISTS = 20189 - DRV_OA_STRINGS_NOT_EQUAL = 20190 - DRV_OA_NO_USER_DATA = 20191 - DRV_OA_VALUE_NOT_SUPPORTED = 20192 - DRV_OA_MODE_DOES_NOT_EXIST = 20193 - DRV_OA_CAMERA_NOT_SUPPORTED = 20194 - DRV_OA_FAILED_TO_GET_MODE = 20195 - DRV_PROCESSING_FAILED = 20211 - AT_NoOfVersionInfoIds = 2 - AT_VERSION_INFO_LEN = 80 - AT_CONTROLLER_CARD_MODEL_LEN = 80 - AT_DDGLite_ControlBit_GlobalEnable = 0x01 - AT_DDGLite_ControlBit_ChannelEnable = 0x01 - AT_DDGLite_ControlBit_FreeRun = 0x02 - AT_DDGLite_ControlBit_DisableOnFrame = 0x04 - AT_DDGLite_ControlBit_RestartOnFire = 0x08 - AT_DDGLite_ControlBit_Invert = 0x10 - AT_DDGLite_ControlBit_EnableOnFire = 0x20 - AT_DDG_POLARITY_POSITIVE = 0 - AT_DDG_POLARITY_NEGATIVE = 1 - AT_DDG_TERMINATION_50OHMS = 0 - AT_DDG_TERMINATION_HIGHZ = 1 - AT_STEPMODE_CONSTANT = 0 - AT_STEPMODE_EXPONENTIAL = 1 - AT_STEPMODE_LOGARITHMIC = 2 - AT_STEPMODE_LINEAR = 3 - AT_STEPMODE_OFF = 100 - AT_GATEMODE_FIRE_AND_GATE = 0 - AT_GATEMODE_FIRE_ONLY = 1 - AT_GATEMODE_GATE_ONLY = 2 - AT_GATEMODE_CW_ON = 3 - AT_GATEMODE_CW_OFF = 4 - AT_GATEMODE_DDG = 5 - AC_ACQMODE_SINGLE = 1 - AC_ACQMODE_VIDEO = 2 - AC_ACQMODE_ACCUMULATE = 4 - AC_ACQMODE_KINETIC = 8 - AC_ACQMODE_FRAMETRANSFER = 16 - AC_ACQMODE_FASTKINETICS = 32 - AC_ACQMODE_OVERLAP = 64 - AC_READMODE_FULLIMAGE = 1 - AC_READMODE_SUBIMAGE = 2 - AC_READMODE_SINGLETRACK = 4 - AC_READMODE_FVB = 8 - AC_READMODE_MULTITRACK = 16 - AC_READMODE_RANDOMTRACK = 32 - AC_READMODE_MULTITRACKSCAN = 64 - AC_TRIGGERMODE_INTERNAL = 1 - AC_TRIGGERMODE_EXTERNAL = 2 - AC_TRIGGERMODE_EXTERNAL_FVB_EM = 4 - AC_TRIGGERMODE_CONTINUOUS = 8 - AC_TRIGGERMODE_EXTERNALSTART = 16 - AC_TRIGGERMODE_EXTERNALEXPOSURE = 32 - AC_TRIGGERMODE_INVERTED = 0x40 - AC_TRIGGERMODE_EXTERNAL_CHARGESHIFTING = 0x80 - AC_TRIGGERMODE_BULB = 32 - AC_CAMERATYPE_PDA = 0 - AC_CAMERATYPE_IXON = 1 - AC_CAMERATYPE_ICCD = 2 - AC_CAMERATYPE_EMCCD = 3 - AC_CAMERATYPE_CCD = 4 - AC_CAMERATYPE_ISTAR = 5 - AC_CAMERATYPE_VIDEO = 6 - AC_CAMERATYPE_IDUS = 7 - AC_CAMERATYPE_NEWTON = 8 - AC_CAMERATYPE_SURCAM = 9 - AC_CAMERATYPE_USBICCD = 10 - AC_CAMERATYPE_LUCA = 11 - AC_CAMERATYPE_RESERVED = 12 - AC_CAMERATYPE_IKON = 13 - AC_CAMERATYPE_INGAAS = 14 - AC_CAMERATYPE_IVAC = 15 - AC_CAMERATYPE_UNPROGRAMMED = 16 - AC_CAMERATYPE_CLARA = 17 - AC_CAMERATYPE_USBISTAR = 18 - AC_CAMERATYPE_SIMCAM = 19 - AC_CAMERATYPE_NEO = 20 - AC_CAMERATYPE_IXONULTRA = 21 - AC_CAMERATYPE_VOLMOS = 22 - AC_PIXELMODE_8BIT = 1 - AC_PIXELMODE_14BIT = 2 - AC_PIXELMODE_16BIT = 4 - AC_PIXELMODE_32BIT = 8 - AC_PIXELMODE_MONO = 0x000000 - AC_PIXELMODE_RGB = 0x010000 - AC_PIXELMODE_CMY = 0x020000 - AC_SETFUNCTION_VREADOUT = 0x01 - AC_SETFUNCTION_HREADOUT = 0x02 - AC_SETFUNCTION_TEMPERATURE = 0x04 - AC_SETFUNCTION_MCPGAIN = 0x08 - AC_SETFUNCTION_EMCCDGAIN = 0x10 - AC_SETFUNCTION_BASELINECLAMP = 0x20 - AC_SETFUNCTION_VSAMPLITUDE = 0x40 - AC_SETFUNCTION_HIGHCAPACITY = 0x80 - AC_SETFUNCTION_BASELINEOFFSET = 0x0100 - AC_SETFUNCTION_PREAMPGAIN = 0x0200 - AC_SETFUNCTION_CROPMODE = 0x0400 - AC_SETFUNCTION_DMAPARAMETERS = 0x0800 - AC_SETFUNCTION_HORIZONTALBIN = 0x1000 - AC_SETFUNCTION_MULTITRACKHRANGE = 0x2000 - AC_SETFUNCTION_RANDOMTRACKNOGAPS = 0x4000 - AC_SETFUNCTION_EMADVANCED = 0x8000 - AC_SETFUNCTION_GATEMODE = 0x010000 - AC_SETFUNCTION_DDGTIMES = 0x020000 - AC_SETFUNCTION_IOC = 0x040000 - AC_SETFUNCTION_INTELLIGATE = 0x080000 - AC_SETFUNCTION_INSERTION_DELAY = 0x100000 - AC_SETFUNCTION_GATESTEP = 0x200000 - AC_SETFUNCTION_GATEDELAYSTEP = 0x200000 - AC_SETFUNCTION_TRIGGERTERMINATION = 0x400000 - AC_SETFUNCTION_EXTENDEDNIR = 0x800000 - AC_SETFUNCTION_SPOOLTHREADCOUNT = 0x1000000 - AC_SETFUNCTION_REGISTERPACK = 0x2000000 - AC_SETFUNCTION_PRESCANS = 0x4000000 - AC_SETFUNCTION_GATEWIDTHSTEP = 0x8000000 - AC_SETFUNCTION_GAIN = 8 - AC_SETFUNCTION_ICCDGAIN = 8 - AC_GETFUNCTION_TEMPERATURE = 0x01 - AC_GETFUNCTION_TARGETTEMPERATURE = 0x02 - AC_GETFUNCTION_TEMPERATURERANGE = 0x04 - AC_GETFUNCTION_DETECTORSIZE = 0x08 - AC_GETFUNCTION_MCPGAIN = 0x10 - AC_GETFUNCTION_EMCCDGAIN = 0x20 - AC_GETFUNCTION_HVFLAG = 0x40 - AC_GETFUNCTION_GATEMODE = 0x80 - AC_GETFUNCTION_DDGTIMES = 0x0100 - AC_GETFUNCTION_IOC = 0x0200 - AC_GETFUNCTION_INTELLIGATE = 0x0400 - AC_GETFUNCTION_INSERTION_DELAY = 0x0800 - AC_GETFUNCTION_GATESTEP = 0x1000 - AC_GETFUNCTION_GATEDELAYSTEP = 0x1000 - AC_GETFUNCTION_PHOSPHORSTATUS = 0x2000 - AC_GETFUNCTION_MCPGAINTABLE = 0x4000 - AC_GETFUNCTION_BASELINECLAMP = 0x8000 - AC_GETFUNCTION_GATEWIDTHSTEP = 0x10000 - AC_GETFUNCTION_GAIN = 0x10 - AC_GETFUNCTION_ICCDGAIN = 0x10 - AC_FEATURES_POLLING = 1 - AC_FEATURES_EVENTS = 2 - AC_FEATURES_SPOOLING = 4 - AC_FEATURES_SHUTTER = 8 - AC_FEATURES_SHUTTEREX = 16 - AC_FEATURES_EXTERNAL_I2C = 32 - AC_FEATURES_SATURATIONEVENT = 64 - AC_FEATURES_FANCONTROL = 128 - AC_FEATURES_MIDFANCONTROL = 256 - AC_FEATURES_TEMPERATUREDURINGACQUISITION = 512 - AC_FEATURES_KEEPCLEANCONTROL = 1024 - AC_FEATURES_DDGLITE = 0x0800 - AC_FEATURES_FTEXTERNALEXPOSURE = 0x1000 - AC_FEATURES_KINETICEXTERNALEXPOSURE = 0x2000 - AC_FEATURES_DACCONTROL = 0x4000 - AC_FEATURES_METADATA = 0x8000 - AC_FEATURES_IOCONTROL = 0x10000 - AC_FEATURES_PHOTONCOUNTING = 0x20000 - AC_FEATURES_COUNTCONVERT = 0x40000 - AC_FEATURES_DUALMODE = 0x80000 - AC_FEATURES_OPTACQUIRE = 0x100000 - AC_FEATURES_REALTIMESPURIOUSNOISEFILTER = 0x200000 - AC_FEATURES_POSTPROCESSSPURIOUSNOISEFILTER = 0x400000 - AC_FEATURES_DUALPREAMPGAIN = 0x800000 - AC_FEATURES_DEFECT_CORRECTION = 0x1000000 - AC_FEATURES_STARTOFEXPOSURE_EVENT = 0x2000000 - AC_FEATURES_ENDOFEXPOSURE_EVENT = 0x4000000 - AC_FEATURES_CAMERALINK = 0x8000000 - AC_EMGAIN_8BIT = 1 - AC_EMGAIN_12BIT = 2 - AC_EMGAIN_LINEAR12 = 4 - AC_EMGAIN_REAL12 = 8 - def AbortAcquisition(self): - ''' - Description: - This function aborts the current acquisition if one is active. - - Synopsis: - ret = AbortAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition aborted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_IDLE - The system is not currently acquiring. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int AbortAcquisition(void); - - See Also: - GetStatus StartAcquisition - - ''' - ret = self.dll.AbortAcquisition() - return (ret) - - def CancelWait(self): - ''' - Description: - This function restarts a thread which is sleeping within the WaitForAcquisitionWaitForAcquisition function. The sleeping thread will return from WaitForAcquisition with a value not equal to DRV_SUCCESS. - - Synopsis: - ret = CancelWait() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread restarted successfully. - - C++ Equiv: - unsigned int CancelWait(void); - - See Also: - WaitForAcquisition - - ''' - ret = self.dll.CancelWait() - return (ret) - - def CoolerOFF(self): - ''' - Description: - Switches OFF the cooling. The rate of temperature change is controlled in some models until the temperature reaches 0C. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerOFF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched OFF. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support switching cooler off. - - C++ Equiv: - unsigned int CoolerOFF(void); - - See Also: - CoolerON SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: Not available on Luca R cameras - always cooled to -20C. - - NOTE: (Classic & ICCD only) 1. When the temperature control is switched off the temperature of the sensor is gradually raised to 0C to ensure no thermal stresses are set up in the sensor. 2. When closing down the program via ShutDown you must ensure that the temperature of the detector is above -20C, otherwise calling ShutDown while the detector is still cooled will cause the temperature to rise faster than certified. - - - ''' - ret = self.dll.CoolerOFF() - return (ret) - - def CoolerON(self): - ''' - Description: - Switches ON the cooling. On some systems the rate of temperature change is controlled until the temperature is within 3C of the set value. Control is returned immediately to the calling application. - - Synopsis: - ret = CoolerON() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature controller switched ON. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int CoolerON(void); - - See Also: - CoolerOFF SetTemperature GetTemperature GetTemperatureF GetTemperatureRange GetStatus - - Note: The temperature to which the detector will be cooled is set via SetTemperatureSetTemperature. The temperature stabilization is controlled via hardware, and the current temperature can be obtained via GetTemperatureGetTemperature. The temperature of the sensor is gradually brought to the desired temperature to ensure no thermal stresses are set up in the sensor. - - Can be called for certain systems during an acquisition. This can be tested for using GetCapabilities. - - - ''' - ret = self.dll.CoolerON() - return (ret) - - def DemosaicImage(self, grey, info): - ''' - Description: - For colour sensors only - Demosaics an image taken with a CYMG CCD into RGB using the parameters stored in info. Below is the ColorDemosaicInfo structure definition and a description of its members: - struct COLORDEMOSAICINFO { - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to demosaic image. - int iXPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iYPhase; // First pixel in data (Cyan or Yellow/Magenta or Green). - int iBackground; // Background to remove from raw data when demosaicing. - ColorDemosaicInfo; - * iX and iY are the image dimensions. The number of elements in the input red, green and blue arrays is iX x iY. - * iAlgorithm sets the algorithm to use: 0 for a 2x2 matrix demosaic algorithm or 1 for a 3x3 one. - The CYMG CCD pattern can be broken into cells of 2x4 pixels, e.g.: - * iXPhase and iYPhase store what colour is the bottom-left pixel. - * iBackground sets the numerical value to be removed from every pixel in the input image before demosaicing is done. - - Synopsis: - (ret, red, green, blue) = DemosaicImage(grey, info) - - Inputs: - grey - pointer to image to demosaic - info - pointer to demosaic information structure. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image demosaiced - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - One or more parameters in info is out of range - red - pointer to the red plane storage allocated by the user. - green - pointer to the green plane storage allocated by the user. - blue - pointer to the blue plane storage allocated by the user. - - C++ Equiv: - unsigned int DemosaicImage(WORD * grey, WORD * red, WORD * green, WORD * blue, ColorDemosaicInfo * info); - - See Also: - GetMostRecentColorImage16 WhiteBalance - - ''' - cgrey = (c_short * info.iX * info.iY)(grey) - cred = (c_short * info.iX * info.iY)() - cgreen = (c_short * info.iX * info.iY)() - cblue = (c_short * info.iX * info.iY)() - cinfo = ColorDemosaicInfo(info) - ret = self.dll.DemosaicImage(cgrey, cred, cgreen, cblue, byref(cinfo)) - return (ret, cred, cgreen, cblue) - - def EnableKeepCleans(self, mode): - ''' - Description: - This function is only available on certain cameras operating in FVB external trigger mode. It determines if the camera keep clean cycle will run between acquisitions. - When keep cleans are disabled in this way the exposure time is effectively the exposure time between triggers. - The Keep Clean cycle is enabled by default. - The feature capability AC_FEATURES_KEEPCLEANCONTROL determines if this function can be called for the camera. - - Synopsis: - ret = EnableKeepCleans(mode) - - Inputs: - mode - The keep clean mode.: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Keep clean cycle mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int EnableKeepCleans(int mode); - - See Also: - GetCapabilities - - Note: Currently only available on Newton and iKon cameras operating in FVB external trigger mode. - - ''' - cmode = c_int(mode) - ret = self.dll.EnableKeepCleans(cmode) - return (ret) - - def Filter_GetAveragingFactor(self): - ''' - Description: - Returns the current averaging factor value. - - Synopsis: - (ret, averagingFactor) = Filter_GetAveragingFactor() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid averagingFactor (i.e. NULL pointer). - averagingFactor - The current averaging factor value. - - C++ Equiv: - unsigned int Filter_GetAveragingFactor(int * averagingFactor); - - See Also: - Filter_SetAveragingFactor - - ''' - caveragingFactor = c_int() - ret = self.dll.Filter_GetAveragingFactor(byref(caveragingFactor)) - return (ret, caveragingFactor.value) - - def Filter_GetAveragingFrameCount(self): - ''' - Description: - Returns the current frame count value. - - Synopsis: - (ret, frames) = Filter_GetAveragingFrameCount() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame count returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count (i.e. NULL pointer). - frames - The current frame count value. - - C++ Equiv: - unsigned int Filter_GetAveragingFrameCount(int * frames); - - See Also: - Filter_SetAveragingFrameCount - - ''' - cframes = c_int() - ret = self.dll.Filter_GetAveragingFrameCount(byref(cframes)) - return (ret, cframes.value) - - def Filter_GetDataAveragingMode(self): - ''' - Description: - Returns the current averaging mode. - - Synopsis: - (ret, mode) = Filter_GetDataAveragingMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - mode - The current averaging mode. - - C++ Equiv: - unsigned int Filter_GetDataAveragingMode(int * mode); - - See Also: - Filter_SetDataAveragingMode - - ''' - cmode = c_int() - ret = self.dll.Filter_GetDataAveragingMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetMode(self): - ''' - Description: - Returns the current Noise Filter mode. - - Synopsis: - (ret, mode) = Filter_GetMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode (i.e. NULL pointer) - mode - Noise Filter mode. - - C++ Equiv: - unsigned int Filter_GetMode(unsigned int * mode); - - See Also: - Filter_SetMode - - ''' - cmode = c_uint() - ret = self.dll.Filter_GetMode(byref(cmode)) - return (ret, cmode.value) - - def Filter_GetThreshold(self): - ''' - Description: - Returns the current Noise Filter threshold value. - - Synopsis: - (ret, threshold) = Filter_GetThreshold() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold (i.e. NULL pointer). - threshold - The current threshold value. - - C++ Equiv: - unsigned int Filter_GetThreshold(float * threshold); - - See Also: - Filter_SetThreshold - - ''' - cthreshold = c_float() - ret = self.dll.Filter_GetThreshold(byref(cthreshold)) - return (ret, cthreshold.value) - - def Filter_SetAveragingFactor(self, averagingFactor): - ''' - Description: - Sets the averaging factor. - - Synopsis: - ret = Filter_SetAveragingFactor(averagingFactor) - - Inputs: - averagingFactor - The averaging factor to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging factor set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - - C++ Equiv: - unsigned int Filter_SetAveragingFactor(int averagingFactor); - - See Also: - Filter_GetAveragingFactor - - ''' - caveragingFactor = c_int(averagingFactor) - ret = self.dll.Filter_SetAveragingFactor(caveragingFactor) - return (ret) - - def Filter_SetAveragingFrameCount(self, frames): - ''' - Description: - Sets the averaging frame count. - - Synopsis: - ret = Filter_SetAveragingFrameCount(frames) - - Inputs: - frames - The averaging frame count to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging frame count set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid frame count. - - C++ Equiv: - unsigned int Filter_SetAveragingFrameCount(int frames); - - See Also: - Filter_GetAveragingFrameCount - - ''' - cframes = c_int(frames) - ret = self.dll.Filter_SetAveragingFrameCount(cframes) - return (ret) - - def Filter_SetDataAveragingMode(self, mode): - ''' - Description: - Sets the current data averaging mode. - - Synopsis: - ret = Filter_SetDataAveragingMode(mode) - - Inputs: - mode - The averaging factor mode to use.: - 0 - No Averaging Filter - 5 - Recursive Averaging Filter - 6 - Frame Averaging Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Averaging mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetDataAveragingMode(int mode); - - See Also: - Filter_GetDataAveragingMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetDataAveragingMode(cmode) - return (ret) - - def Filter_SetMode(self, mode): - ''' - Description: - Set the Noise Filter to use. - - Synopsis: - ret = Filter_SetMode(mode) - - Inputs: - mode - Filter mode to use.: - 0 - No Filter - 1 - Median Filter - 2 - Level Above Filter - 3 - interquartile Range Filter - 4 - Noise Threshold Filter - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid mode. - - C++ Equiv: - unsigned int Filter_SetMode(int mode); - - See Also: - Filter_GetMode - - ''' - cmode = c_int(mode) - ret = self.dll.Filter_SetMode(cmode) - return (ret) - - def Filter_SetThreshold(self, threshold): - ''' - Description: - Sets the threshold value for the Noise Filter. - - Synopsis: - ret = Filter_SetThreshold(threshold) - - Inputs: - threshold - Threshold value used to process image.: - 0 - 65535 for Level Above filter. - 0 - 10 for all other filters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Threshold set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Noise Filter processing not available for this camera. - DRV_P1INVALID - Invalid threshold. - - C++ Equiv: - unsigned int Filter_SetThreshold(float threshold); - - See Also: - Filter_GetThreshold - - ''' - cthreshold = c_float(threshold) - ret = self.dll.Filter_SetThreshold(cthreshold) - return (ret) - - def FreeInternalMemory(self): - ''' - Description: - The FreeinternalMemory function will deallocate any memory used internally to store the previously acquired data. Note that once this function has been called, data from last acquisition cannot be retrieved. - - Synopsis: - ret = FreeInternalMemory() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Memory freed. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int FreeInternalMemory(void); - - See Also: - GetImages PrepareAcquisition - - ''' - ret = self.dll.FreeInternalMemory() - return (ret) - - def GetAcquiredData(self, size): - ''' - Description: - This function will return the data from the last acquisition. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData(at_32 * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData16 - - ''' - carr = c_int() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredData16(self, size): - ''' - Description: - 16-bit version of the GetAcquiredDataGetAcquiredData function. The array must be large enough to hold the complete data set. - - Synopsis: - (ret, arr) = GetAcquiredData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size isincorrect. - DRV_NO_NEW_DATA - No acquisition has taken place - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetAcquiredData16(WORD * arr, unsigned long size); - - See Also: - GetStatus StartAcquisition GetAcquiredData - - ''' - carr = c_short() - csize = c_ulong(size) - ret = self.dll.GetAcquiredData16(byref(carr), csize) - return (ret, carr.value) - - def GetAcquiredFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAcquiredFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAcquiredFloatData(float * arr, unsigned long size); - - ''' - carr = c_float() - csize = c_ulong(size) - ret = self.dll.GetAcquiredFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetAcquisitionProgress(self): - ''' - Description: - This function will return information on the progress of the current acquisition. It can be called at any time but is best used in conjunction with SetDriverEventSetDriverEvent. - The values returned show the number of completed scans in the current acquisition. - If 0 is returned for both accum and series then either:- - * No acquisition is currently running - * The acquisition has just completed - * The very first scan of an acquisition has just started and not yet completed - GetStatus can be used to confirm if the first scan has just started, returning - DRV_ACQUIRING, otherwise it will return DRV_IDLE. - For example, if [i]accum[/i]=2 and [i]series[/i]=3 then the acquisition has completed 3 in the series and 2 accumulations in the 4 scan of the series. - - Synopsis: - (ret, acc, series) = GetAcquisitionProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of accumulation and series scans completed. - DRV_NOT_INITIALIZED - System not initialized. - acc - returns the number of accumulations completed in the current kinetic scan. - series - series the number of kinetic scans completed - - C++ Equiv: - unsigned int GetAcquisitionProgress(long * acc, long * series); - - See Also: - SetAcquisitionMode SetNumberAccumulations SetNumberKinetics SetDriverEvent - - ''' - cacc = c_int() - cseries = c_int() - ret = self.dll.GetAcquisitionProgress(byref(cacc), byref(cseries)) - return (ret, cacc.value, cseries.value) - - def GetAcquisitionTimings(self): - ''' - Description: - This function will return the current "valid" acquisition timing information. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The values returned are the actual times used in subsequent acquisitions. - This function is required as it is possible to set the exposure time to 20ms, accumulate cycle time to 30ms and then set the readout mode to full image. As it can take 250ms to read out an image it is not possible to have a cycle time of 30ms. - - Synopsis: - (ret, exposure, accumulate, kinetic) = GetAcquisitionTimings() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Acquisition or readout mode is not available. - exposure - valid exposure time in seconds - accumulate - valid accumulate cycle time in seconds - kinetic - valid kinetic cycle time in seconds - - C++ Equiv: - unsigned int GetAcquisitionTimings(float * exposure, float * accumulate, float * kinetic); - - See Also: - SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - cexposure = c_float() - caccumulate = c_float() - ckinetic = c_float() - ret = self.dll.GetAcquisitionTimings(byref(cexposure), byref(caccumulate), byref(ckinetic)) - return (ret, cexposure.value, caccumulate.value, ckinetic.value) - - def GetAdjustedRingExposureTimes(self, inumTimes): - ''' - Description: - This function will return the actual exposure times that the camera will use. There may be differences between requested exposures and the actual exposures. - - Synopsis: - (ret, fptimes) = GetAdjustedRingExposureTimes(inumTimes) - - Inputs: - inumTimes - inumTimesNumbers of times requested. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number of exposures requested - fptimes - fptimesPointer to an array large enough to hold _inumTimes floats. - - C++ Equiv: - unsigned int GetAdjustedRingExposureTimes(int inumTimes, float * fptimes); - - See Also: - GetNumberRingExposureTimes SetRingExposureTimes - - ''' - cinumTimes = c_int(inumTimes) - cfptimes = c_float() - ret = self.dll.GetAdjustedRingExposureTimes(cinumTimes, byref(cfptimes)) - return (ret, cfptimes.value) - - def GetAllDMAData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetAllDMAData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetAllDMAData(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetAllDMAData(byref(carr), csize) - return (ret, carr.value) - - def GetAmpDesc(self, index, length): - ''' - Description: - This function will return a string with an amplifier description. The amplifier is selected using the index. The SDK has a string associated with each of its amplifiers. The maximum number of characters needed to store the amplifier descriptions is 21. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetAmpDesc(index, length) - - Inputs: - index - The amplifier index. - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid. - DRV_P2INVALID - The desc pointer is null. - DRV_P3INVALID - The length parameter is invalid (less than 1) - name - A user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetAmpDesc(int index, char * name, int length); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetAmpDesc(cindex, cname, clength) - return (ret, cname) - - def GetAmpMaxSpeed(self, index): - ''' - Description: - This function will return the maximum available horizontal shift speed for the amplifier selected by the index parameter. - - Synopsis: - (ret, speed) = GetAmpMaxSpeed(index) - - Inputs: - index - amplifier index - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - The amplifier index is not valid - speed - horizontal shift speed - - C++ Equiv: - unsigned int GetAmpMaxSpeed(int index, float * speed); - - See Also: - GetNumberAmp - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetAmpMaxSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetAvailableCameras(self): - ''' - Description: - This function returns the total number of Andor cameras currently installed. It is possible to call this function before any of the cameras are initialized. - - Synopsis: - (ret, totalCameras) = GetAvailableCameras() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of available cameras returned. - DRV_GENERAL_ERRORS - An error occurred while obtaining the number of available cameras. - totalCameras - the number of cameras currently installed - - C++ Equiv: - unsigned int GetAvailableCameras(long * totalCameras); - - See Also: - SetCurrentCamera GetCurrentCamera GetCameraHandle - - ''' - ctotalCameras = c_int() - ret = self.dll.GetAvailableCameras(byref(ctotalCameras)) - return (ret, ctotalCameras.value) - - def GetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetBackground(byref(carr), csize) - return (ret, carr.value) - - def GetBaselineClamp(self): - ''' - Description: - This function returns the status of the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - (ret, state) = GetBaselineClamp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - state - Baseline clamp functionality Enabled/Disabled: - 1 - Baseline Clamp Enabled - 0 - Baseline Clamp Disabled - - C++ Equiv: - unsigned int GetBaselineClamp(int * state); - - See Also: - SetBaselineClamp SetBaselineOffset - - ''' - cstate = c_int() - ret = self.dll.GetBaselineClamp(byref(cstate)) - return (ret, cstate.value) - - def GetBitDepth(self, channel): - ''' - Description: - This function will retrieve the size in bits of the dynamic range for any available AD channel. - - Synopsis: - (ret, depth) = GetBitDepth(channel) - - Inputs: - channel - the AD channel. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Depth returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel - depth - dynamic range in bits - - C++ Equiv: - unsigned int GetBitDepth(int channel, int * depth); - - See Also: - GetNumberADChannels SetADChannel - - ''' - cchannel = c_int(channel) - cdepth = c_int() - ret = self.dll.GetBitDepth(cchannel, byref(cdepth)) - return (ret, cdepth.value) - - def GetCameraEventStatus(self): - ''' - Description: - This function will return if the system is exposing or not. - - Synopsis: - (ret, camStatus) = GetCameraEventStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - camStatus - The status of the firepulse will be returned that the firepulse is low: - 0 - Fire pulse low - 1 - Fire pulse high - - C++ Equiv: - unsigned int GetCameraEventStatus(DWORD * camStatus); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: This is only supported by the CCI23 card. - - ''' - ccamStatus = () - ret = self.dll.GetCameraEventStatus(byref(ccamStatus)) - return (ret, ccamStatus.value) - - def GetCameraHandle(self, cameraIndex): - ''' - Description: - This function returns the handle for the camera specified by cameraIndex. When multiple Andor cameras are installed the handle of each camera must be retrieved in order to select a camera using the SetCurrentCamera function. - The number of cameras can be obtained using the GetAvailableCameras function. - - Synopsis: - (ret, cameraHandle) = GetCameraHandle(cameraIndex) - - Inputs: - cameraIndex - index of any of the installed cameras. 0 to NumberCameras-1 where NumberCameras is the value returned by the GetAvailableCamerasGetAvailableCameras functionGetAvailableCamerasGetNumberVerticalSpeedsGetNumberHSSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - DRV_P1INVALID - Invalid camera index. - cameraHandle - handle of the camera. - - C++ Equiv: - unsigned int GetCameraHandle(long cameraIndex, long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCurrentCamera - - ''' - ccameraIndex = c_int(cameraIndex) - ccameraHandle = c_int() - ret = self.dll.GetCameraHandle(ccameraIndex, byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCameraInformation(self, index): - ''' - Description: - This function will return information on a particular camera denoted by the index. - - Synopsis: - (ret, information) = GetCameraInformation(index) - - Inputs: - index - (reserved) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Driver status return - DRV_VXDNOTINSTALLED - Driver not installed - DRV_USBERROR - USB device error - information - current state of camera: - Bit:1 - USB camera present - Bit:2 - All dlls loaded properly - Bit:3 - Camera Initialized correctly - - C++ Equiv: - unsigned int GetCameraInformation(int index, long * information); - - See Also: - GetCameraHandle GetHeadModel GetCameraSerialNumber GetCapabilities - - Note: Only available in iDus. The index parameter is not used at present so should be set to 0. For any camera except the iDus The value of information following a call to this function will be zero. - - ''' - cindex = c_int(index) - cinformation = c_int() - ret = self.dll.GetCameraInformation(cindex, byref(cinformation)) - return (ret, cinformation.value) - - def GetCameraSerialNumber(self): - ''' - Description: - This function will retrieve camera's serial number. - - Synopsis: - (ret, number) = GetCameraSerialNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Serial Number returned. - DRV_NOT_INITIALIZED - System not initialized. - number - Serial Number. - - C++ Equiv: - unsigned int GetCameraSerialNumber(int * number); - - See Also: - GetCameraHandle GetHeadModel GetCameraInformation GetCapabilities - - ''' - cnumber = c_int() - ret = self.dll.GetCameraSerialNumber(byref(cnumber)) - return (ret, cnumber.value) - - def GetCapabilities(self): - ''' - Description: - This function will fill in an AndorCapabilities structure with the capabilities associated with the connected camera. Before passing the address of an AndorCapabilites structure to the function the ulSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - caps->ulSize = sizeof(AndorCapabilities); - Individual capabilities are determined by examining certain bits and combinations of bits in the member variables of the AndorCapabilites structure. - - Synopsis: - (ret, caps) = GetCapabilities() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized - DRV_SUCCESS - Capabilities returned. - DRV_P1INVALID - Invalid caps parameter (i.e. NULL). - caps - the capabilities structure to be filled in. - - C++ Equiv: - unsigned int GetCapabilities(AndorCapabilities * caps); - - See Also: - GetCameraHandle GetCameraSerialNumber GetHeadModel GetCameraInformation - - ''' - caps = AndorCapabilities() - caps.ulSize = sizeof(caps) - ret = self.dll.GetCapabilities(byref(caps)) - return (ret, caps) - - def GetControllerCardModel(self): - ''' - Description: - This function will retrieve the type of PCI controller card included in your system. This function is not applicable for USB systems. The maximum number of characters that can be returned from this function is 10. - - Synopsis: - (ret, controllerCardModel) = GetControllerCardModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized - controllerCardModel - A user allocated array of characters for storage of the controller card model. - - C++ Equiv: - unsigned int GetControllerCardModel(char * controllerCardModel); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - ccontrollerCardModel = create_string_buffer(10) - ret = self.dll.GetControllerCardModel(ccontrollerCardModel) - return (ret, ccontrollerCardModel) - - def GetCountConvertWavelengthRange(self): - ''' - Description: - This function returns the valid wavelength range available in Count Convert mode. - - Synopsis: - (ret, minval, maxval) = GetCountConvertWavelengthRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - minval - minimum wavelength permited. - maxval - maximum wavelength permited. - - C++ Equiv: - unsigned int GetCountConvertWavelengthRange(float * minval, float * maxval); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cminval = c_float() - cmaxval = c_float() - ret = self.dll.GetCountConvertWavelengthRange(byref(cminval), byref(cmaxval)) - return (ret, cminval.value, cmaxval.value) - - def GetCurrentCamera(self): - ''' - Description: - When multiple Andor cameras are installed this function returns the handle of the currently selected one. - - Synopsis: - (ret, cameraHandle) = GetCurrentCamera() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera handle returned. - cameraHandle - handle of the currently selected camera - - C++ Equiv: - unsigned int GetCurrentCamera(long * cameraHandle); - - See Also: - SetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int() - ret = self.dll.GetCurrentCamera(byref(ccameraHandle)) - return (ret, ccameraHandle.value) - - def GetCYMGShift(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, iXshift, iYShift) = GetCYMGShift() - - Inputs: - None - - Outputs: - ret - Function Return Code - iXshift - - iYShift - - - C++ Equiv: - unsigned int GetCYMGShift(int * iXshift, int * iYShift); - - ''' - ciXshift = c_int() - ciYShift = c_int() - ret = self.dll.GetCYMGShift(byref(ciXshift), byref(ciYShift)) - return (ret, ciXshift.value, ciYShift.value) - - def GetDDGExternalOutputEnabled(self, uiIndex): - ''' - Description: - This function gets the current state of a selected external output. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputPolarity(self, uiIndex): - ''' - Description: - This function gets the current polarity of a selected external output. - - Synopsis: - (ret, puiPolarity) = GetDDGExternalOutputPolarity(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiPolarity - current polarity of external output (0 - Positive, 1 - Negative). - - C++ Equiv: - unsigned int GetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 * puiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputPolarity SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiPolarity = c_uint() - ret = self.dll.GetDDGExternalOutputPolarity(cuiIndex, byref(cpuiPolarity)) - return (ret, cpuiPolarity.value) - - def GetDDGExternalOutputStepEnabled(self, uiIndex): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to determine if this option is currently active. - - Synopsis: - (ret, puiEnabled) = GetDDGExternalOutputStepEnabled(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - puiEnabled - current state of external output track step (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputStepEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiEnabled = c_uint() - ret = self.dll.GetDDGExternalOutputStepEnabled(cuiIndex, byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGExternalOutputTime(self, uiIndex): - ''' - Description: - This function can be used to find the actual timings for a particular external output. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGExternalOutputTime(uiIndex) - - Inputs: - uiIndex - index of external output. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Delay has invalid memory address. - puiDelay - actual external output delay time in picoseconds. - puiWidth - actual external output width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGExternalOutputTime(at_u32 uiIndex, at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled SetDDGExternalOutputTime SetDDGGateStep - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGExternalOutputTime(cuiIndex, byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGGateTime(self): - ''' - Description: - This function can be used to get the actual gate timings for a USB iStar. - - Synopsis: - (ret, puiDelay, puiWidth) = GetDDGGateTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Delay has invalid memory address. - puiDelay - gate delay time in picoseconds. - puiWidth - gate width time in picoseconds. - - C++ Equiv: - unsigned int GetDDGGateTime(at_u64 * puiDelay, at_u64 * puiWidth); - - See Also: - GetCapabilities SetDDGGateTimeSetDDGGateStep - - ''' - cpuiDelay = c_ulonglong() - cpuiWidth = c_ulonglong() - ret = self.dll.GetDDGGateTime(byref(cpuiDelay), byref(cpuiWidth)) - return (ret, cpuiDelay.value, cpuiWidth.value) - - def GetDDGInsertionDelay(self): - ''' - Description: - This function gets the current state of the insertion delay. - - Synopsis: - (ret, piState) = GetDDGInsertionDelay() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Insertion delay state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Insertion delay not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the insertion delay option (0 - Normal, 1 - Ultra Fast). - - C++ Equiv: - unsigned int GetDDGInsertionDelay(int * piState); - - See Also: - GetCapabilities SetDDGInsertionDelay SetDDGIntelligate - - ''' - cpiState = c_int() - ret = self.dll.GetDDGInsertionDelay(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIntelligate(self): - ''' - Description: - This function gets the current state of intelligate. - - Synopsis: - (ret, piState) = GetDDGIntelligate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - intelligate not supported. - DRV_ERROR_ACK - Unable to communicate with system. - piState - current state of the intelligate option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIntelligate(int * piState); - - See Also: - GetCapabilities SetDDGIntelligate SetDDGInsertionDelay - - ''' - cpiState = c_int() - ret = self.dll.GetDDGIntelligate(byref(cpiState)) - return (ret, cpiState.value) - - def GetDDGIOC(self): - ''' - Description: - This function gets the current state of the integrate on chip (IOC) option. - - Synopsis: - (ret, state) = GetDDGIOC() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - state has invalid memory address. - state - current state of the IOC option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGIOC(int * state); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency - - ''' - cstate = c_int() - ret = self.dll.GetDDGIOC(byref(cstate)) - return (ret, cstate.value) - - def GetDDGIOCFrequency(self): - ''' - Description: - This function can be used to return the actual IOC frequency that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, frequency) = GetDDGIOCFrequency() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - frequency - the frequency of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCFrequency(double * frequency); - - See Also: - GetCapabilities SetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cfrequency = c_double() - ret = self.dll.GetDDGIOCFrequency(byref(cfrequency)) - return (ret, cfrequency.value) - - def GetDDGIOCNumber(self): - ''' - Description: - This function can be used to return the actual number of pulses that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, numberPulses) = GetDDGIOCNumber() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCNumber(unsigned long * numberPulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCPulses SetDDGIOC SetDDGIOCFrequency - - ''' - cnumberPulses = c_ulong() - ret = self.dll.GetDDGIOCNumber(byref(cnumberPulses)) - return (ret, cnumberPulses.value) - - def GetDDGIOCNumberRequested(self): - ''' - Description: - This function can be used to return the number of pulses that were requested by the user. - - Synopsis: - (ret, pulses) = GetDDGIOCNumberRequested() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - pulses has invalid memory address. - pulses - the number of integrate on chip pulses requested. - - C++ Equiv: - unsigned int GetDDGIOCNumberRequested(at_u32 * pulses); - - See Also: - GetCapabilities SetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_uint() - ret = self.dll.GetDDGIOCNumberRequested(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCPeriod(self): - ''' - Description: - This function can be used to return the actual IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, period) = GetDDGIOCPeriod() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - period has invalid memory address. - period - the period of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPeriod(at_u64 * period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCPeriod SetDDGIOCFrequency - - ''' - cperiod = c_ulonglong() - ret = self.dll.GetDDGIOCPeriod(byref(cperiod)) - return (ret, cperiod.value) - - def GetDDGIOCPulses(self): - ''' - Description: - This function can be used to calculate the number of pulses that will be triggered with the given exposure time, readout mode, acquisition mode and integrate on chip frequency. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - (ret, pulses) = GetDDGIOCPulses() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - pulses - the number of integrate on chip pulses triggered within the fire pulse. - - C++ Equiv: - unsigned int GetDDGIOCPulses(int * pulses); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber SetDDGIOC SetDDGIOCFrequency - - ''' - cpulses = c_int() - ret = self.dll.GetDDGIOCPulses(byref(cpulses)) - return (ret, cpulses.value) - - def GetDDGIOCTrigger(self): - ''' - Description: - function can be used to retrieve the active IOC trigger. - at_u32* trigger: active IOC trigger (0 - Fire pulse, 1 - External trigger). - at_u32 int - DRV_SUCCESS - DRV_NOT_INITIALIZED - DRV_NOT_SUPPORTED - DRV_ACQUIRING - DRV_ERROR_ACK - DRV_P1INVALID - IOC trigger returned. - System not initialized. - IOC not supported. - Acquisition in progress. - Unable to communicate with system. - Invalid trigger. - See also - GetCapabilities SetDDGIOC SetDDGIOCFrequency SetDDGIOCTrigger SetTriggerMode - GetDDGLiteControlByte - GetDDGLiteControlByte int WINAPI GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control) - Description - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, trigger) = GetDDGIOCTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code - trigger - - - C++ Equiv: - unsigned int GetDDGIOCTrigger(at_u32 * trigger); - - ''' - ctrigger = c_uint() - ret = self.dll.GetDDGIOCTrigger(byref(ctrigger)) - return (ret, ctrigger.value) - - def GetDDGLiteControlByte(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, control) = GetDDGLiteControlByte(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteControlByte(AT_DDGLiteChannelId channel, unsigned char * control); - - ''' - cchannel = (channel) - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteControlByte(cchannel, byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteGlobalControlByte(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, control) = GetDDGLiteGlobalControlByte() - - Inputs: - None - - Outputs: - ret - Function Return Code - control - - - C++ Equiv: - unsigned int GetDDGLiteGlobalControlByte(unsigned char * control); - - ''' - ccontrol = c_ubyte() - ret = self.dll.GetDDGLiteGlobalControlByte(byref(ccontrol)) - return (ret, ccontrol.value) - - def GetDDGLiteInitialDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInitialDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInitialDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLiteInterPulseDelay(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fDelay) = GetDDGLiteInterPulseDelay(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fDelay - - - C++ Equiv: - unsigned int GetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float * fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float() - ret = self.dll.GetDDGLiteInterPulseDelay(cchannel, byref(cfDelay)) - return (ret, cfDelay.value) - - def GetDDGLitePulsesPerExposure(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, ui32Pulses) = GetDDGLitePulsesPerExposure(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - ui32Pulses - - - C++ Equiv: - unsigned int GetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 * ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint() - ret = self.dll.GetDDGLitePulsesPerExposure(cchannel, byref(cui32Pulses)) - return (ret, cui32Pulses.value) - - def GetDDGLitePulseWidth(self, channel): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, fWidth) = GetDDGLitePulseWidth(channel) - - Inputs: - channel - - - Outputs: - ret - Function Return Code - fWidth - - - C++ Equiv: - unsigned int GetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float * fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float() - ret = self.dll.GetDDGLitePulseWidth(cchannel, byref(cfWidth)) - return (ret, cfWidth.value) - - def GetDDGOpticalWidthEnabled(self): - ''' - Description: - This function can be used to check whether optical gate widths are being used. - - Synopsis: - (ret, puiEnabled) = GetDDGOpticalWidthEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiEnabled - optical gate width option (0 - Off, 1 - On). - - C++ Equiv: - unsigned int GetDDGOpticalWidthEnabled(at_u32 * puiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth - - ''' - cpuiEnabled = c_uint() - ret = self.dll.GetDDGOpticalWidthEnabled(byref(cpuiEnabled)) - return (ret, cpuiEnabled.value) - - def GetDDGPulse(self, wid, resolution): - ''' - Description: - This function attempts to find a laser pulse in a user-defined region with a given resolution. The values returned will provide an estimation of the location of the pulse. - - Synopsis: - (ret, Delay, Width) = GetDDGPulse(wid, resolution) - - Inputs: - wid - the time in picoseconds of the region to be searched. - resolution - the minimum gate pulse used to locate the laser. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Location returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - Delay - the approximate start of the laser pulse. - Width - the pulse width, which encapsulated the laser pulse. - - C++ Equiv: - unsigned int GetDDGPulse(double wid, double resolution, double * Delay, double * Width); - - Note: Available in iStar. - - ''' - cwid = c_double(wid) - cresolution = c_double(resolution) - cDelay = c_double() - cWidth = c_double() - ret = self.dll.GetDDGPulse(cwid, cresolution, byref(cDelay), byref(cWidth)) - return (ret, cDelay.value, cWidth.value) - - def GetDDGStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate step mode. - - Synopsis: - (ret, p1, p2) = GetDDGStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - First coefficient - p2 - Second coefficient - - C++ Equiv: - unsigned int GetDDGStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGStepMode(self): - ''' - Description: - This function will return the current gate step mode. - - Synopsis: - (ret, mode) = GetDDGStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGStepMode(at_u32 * mode); - - See Also: - StartAcquisition SetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint() - ret = self.dll.GetDDGStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDDGTTLGateWidth(self, opticalWidth): - ''' - Description: - This function can be used to get the TTL gate width which corresponds to a particular optical gate width. - - Synopsis: - (ret, ttlWidth) = GetDDGTTLGateWidth(opticalWidth) - - Inputs: - opticalWidth - optical gate width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P2_INVALID - Unable to communicate with system. - ttlWidth - TTL gate width in picoseconds. - - C++ Equiv: - unsigned int GetDDGTTLGateWidth(at_u64 opticalWidth, at_u64 * ttlWidth); - - See Also: - GetCapabilities SetDDGOpticalWidthEnabled SetDDGGateStep - - ''' - copticalWidth = c_ulonglong(opticalWidth) - cttlWidth = c_ulonglong() - ret = self.dll.GetDDGTTLGateWidth(copticalWidth, byref(cttlWidth)) - return (ret, cttlWidth.value) - - def GetDDGWidthStepCoefficients(self, mode): - ''' - Description: - This function will return the coefficients for a particular gate width step mode. - - Synopsis: - (ret, p1, p2) = GetDDGWidthStepCoefficients(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step coefficients returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - DRV_P2_INVALID - p1 has invalid memory address. - DRV_P3_INVALID - p2 has invalid memory address. - p1 - The first coefficient. - p2 - The second coefficient. - - C++ Equiv: - unsigned int GetDDGWidthStepCoefficients(at_u32 mode, double * p1, double * p2); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepMode - - ''' - cmode = c_uint(mode) - cp1 = c_double() - cp2 = c_double() - ret = self.dll.GetDDGWidthStepCoefficients(cmode, byref(cp1), byref(cp2)) - return (ret, cp1.value, cp2.value) - - def GetDDGWidthStepMode(self): - ''' - Description: - This function will return the current gate width step mode. - - Synopsis: - (ret, mode) = GetDDGWidthStepMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - mode has invalid memory address. - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - C++ Equiv: - unsigned int GetDDGWidthStepMode(at_u32 * mode); - - See Also: - SetDDGWidthStepCoefficients SetDDGWidthStepMode GetDDGWidthStepCoefficients StartAcquisition - - ''' - cmode = c_uint() - ret = self.dll.GetDDGWidthStepMode(byref(cmode)) - return (ret, cmode.value) - - def GetDetector(self): - ''' - Description: - This function returns the size of the detector in pixels. The horizontal axis is taken to be the axis parallel to the readout register. - - Synopsis: - (ret, xpixels, ypixels) = GetDetector() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Detector size returned. - DRV_NOT_INITIALIZED - System not initialized. - xpixels - number of horizontal pixels. - ypixels - number of vertical pixels. - - C++ Equiv: - unsigned int GetDetector(int * xpixels, int * ypixels); - - ''' - cxpixels = c_int() - cypixels = c_int() - ret = self.dll.GetDetector(byref(cxpixels), byref(cypixels)) - return (ret, cxpixels.value, cypixels.value) - - def GetDICameraInfo(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, info) = GetDICameraInfo() - - Inputs: - None - - Outputs: - ret - Function Return Code - info - - - C++ Equiv: - unsigned int GetDICameraInfo(void * info); - - ''' - cinfo = c_void() - ret = self.dll.GetDICameraInfo(byref(cinfo)) - return (ret, cinfo.value) - - def GetDualExposureTimes(self): - ''' - Description: - This function will return the current valid acquisition timing information for dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - (ret, exposure1, exposure2) = GetDualExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. . - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_NOT_AVAILABLE - Dual exposure mode not configured correctly. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - exposure1 has invalid memory address. - DRV_P2INVALID - exposure2 has invalid memory address. - exposure1 - valid exposure time in seconds for each odd numbered frame. - exposure2 - valid exposure time in seconds for each even numbered frame. - - C++ Equiv: - unsigned int GetDualExposureTimes(float * exposure1, float * exposure2); - - See Also: - GetCapabilities SetDualExposureMode SetDualExposureTimes - - ''' - cexposure1 = c_float() - cexposure2 = c_float() - ret = self.dll.GetDualExposureTimes(byref(cexposure1), byref(cexposure2)) - return (ret, cexposure1.value, cexposure2.value) - - def GetEMAdvanced(self): - ''' - Description: - Returns the current Advanced gain setting. - - Synopsis: - (ret, state) = GetEMAdvanced() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Advanced state returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - state has invalid memory address. - state - current EM advanced gain setting - - C++ Equiv: - unsigned int GetEMAdvanced(int * state); - - ''' - cstate = c_int() - ret = self.dll.GetEMAdvanced(byref(cstate)) - return (ret, cstate.value) - - def GetEMCCDGain(self): - ''' - Description: - Returns the current gain setting. The meaning of the value returned depends on the EM Gain mode. - - Synopsis: - (ret, gain) = GetEMCCDGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - gain - current EM gain setting - - C++ Equiv: - unsigned int GetEMCCDGain(int * gain); - - ''' - cgain = c_int() - ret = self.dll.GetEMCCDGain(byref(cgain)) - return (ret, cgain.value) - - def GetEMGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the current selected EM Gain mode and temperature of the sensor. - - Synopsis: - (ret, low, high) = GetEMGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - low - lowest gain setting - high - highest gain setting - - C++ Equiv: - unsigned int GetEMGainRange(int * low, int * high); - - ''' - clow = c_int() - chigh = c_int() - ret = self.dll.GetEMGainRange(byref(clow), byref(chigh)) - return (ret, clow.value, chigh.value) - - def GetExternalTriggerTermination(self): - ''' - Description: - This function can be used to get the current external trigger termination mode. - - Synopsis: - (ret, puiTermination) = GetExternalTriggerTermination() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - C++ Equiv: - unsigned int GetExternalTriggerTermination(at_u32 * puiTermination); - - See Also: - GetCapabilities SetExternalTriggerTermination - - ''' - cpuiTermination = c_uint() - ret = self.dll.GetExternalTriggerTermination(byref(cpuiTermination)) - return (ret, cpuiTermination.value) - - def GetFastestRecommendedVSSpeed(self): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the fastest recommended speed available. The very high readout speeds, may require an increase in the amplitude of the Vertical Clock Voltage using SetVSAmplitudeSetVSAmplitude. This function returns the fastest speed which does not require the Vertical Clock Voltage to be adjusted. The values returned are the vertical shift speed index and the actual speed in microseconds per pixel shift. - - Synopsis: - (ret, index, speed) = GetFastestRecommendedVSSpeed() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - index - index of the fastest recommended vertical shift speed - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetFastestRecommendedVSSpeed(int * index, float * speed); - - See Also: - GetVSSpeed GetNumberVSSpeeds SetVSSpeed - - ''' - cindex = c_int() - cspeed = c_float() - ret = self.dll.GetFastestRecommendedVSSpeed(byref(cindex), byref(cspeed)) - return (ret, cindex.value, cspeed.value) - - def GetFIFOUsage(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, FIFOusage) = GetFIFOUsage() - - Inputs: - None - - Outputs: - ret - Function Return Code - FIFOusage - - - C++ Equiv: - unsigned int GetFIFOUsage(int * FIFOusage); - - ''' - cFIFOusage = c_int() - ret = self.dll.GetFIFOUsage(byref(cFIFOusage)) - return (ret, cFIFOusage.value) - - def GetFilterMode(self): - ''' - Description: - This function returns the current state of the cosmic ray filtering mode. - - Synopsis: - (ret, mode) = GetFilterMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mode - current state of filter: - 0 - OFF - 2 - ON - - C++ Equiv: - unsigned int GetFilterMode(int * mode); - - See Also: - SetFilterMode - - ''' - cmode = c_int() - ret = self.dll.GetFilterMode(byref(cmode)) - return (ret, cmode.value) - - def GetFKExposureTime(self): - ''' - Description: - This function will return the current "valid" exposure time for a fast kinetics acquisition. This function should be used after all the acquisitions settings have been set, i.e. SetFastKineticsSetFastKinetics and SetFKVShiftSpeedSetFKVShiftSpeed. The value returned is the actual time used in subsequent acquisitions. - - Synopsis: - (ret, time) = GetFKExposureTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_INVALID_MODE - Fast kinetics is not available. - time - valid exposure time in seconds - - C++ Equiv: - unsigned int GetFKExposureTime(float * time); - - See Also: - SetFastKinetics SetFKVShiftSpeed - - ''' - ctime = c_float() - ret = self.dll.GetFKExposureTime(byref(ctime)) - return (ret, ctime.value) - - def GetFKVShiftSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Deprecated by GetFKVShiftSpeedFGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetFKVShiftSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFKVShiftSpeedF(self, index): - ''' - Description: - As your Andor system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetFKVShiftSpeedF(index) - - Inputs: - index - speed required: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetFKVShiftSpeedF(int index, float * speed); - - See Also: - GetNumberFKVShiftSpeeds SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetFKVShiftSpeedF(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetFrontEndStatus(self): - ''' - Description: - This function will return if the Front End cooler has overheated. - - Synopsis: - (ret, piFlag) = GetFrontEndStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Front End cooler not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the front end cooler: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetFrontEndStatus(int * piFlag); - - See Also: - SetFrontEndEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetFrontEndStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetGateMode(self): - ''' - Description: - Allows the user to get the current photocathode gating mode. - - Synopsis: - (ret, piGatemode) = GetGateMode() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - gatemode has invalid memory address. - piGatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - C++ Equiv: - unsigned int GetGateMode(int * piGatemode); - - See Also: - GetCapabilities SetGateMode - - ''' - cpiGatemode = c_int() - ret = self.dll.GetGateMode(byref(cpiGatemode)) - return (ret, cpiGatemode.value) - - def GetHardwareVersion(self): - ''' - Description: - This function returns the Hardware version information. - - Synopsis: - (ret, PCB, Decode, dummy1, dummy2, CameraFirmwareVersion, CameraFirmwareBuild) = GetHardwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - PCB - Plug-in card version - Decode - Flex 10K file version - dummy1 - - dummy2 - - CameraFirmwareVersion - Version number of camera firmware - CameraFirmwareBuild - Build number of camera firmware - - C++ Equiv: - unsigned int GetHardwareVersion(unsigned int * PCB, unsigned int * Decode, unsigned int * dummy1, unsigned int * dummy2, unsigned int * CameraFirmwareVersion, unsigned int * CameraFirmwareBuild); - - ''' - cPCB = c_uint() - cDecode = c_uint() - cdummy1 = c_uint() - cdummy2 = c_uint() - cCameraFirmwareVersion = c_uint() - cCameraFirmwareBuild = c_uint() - ret = self.dll.GetHardwareVersion(byref(cPCB), byref(cDecode), byref(cdummy1), byref(cdummy2), byref(cCameraFirmwareVersion), byref(cCameraFirmwareBuild)) - return (ret, cPCB.value, cDecode.value, cdummy1.value, cdummy2.value, cCameraFirmwareVersion.value, cCameraFirmwareBuild.value) - - def GetHeadModel(self): - ''' - Description: - This function will retrieve the type of CCD attached to your system. - - Synopsis: - (ret, name) = GetHeadModel() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Name returned. - DRV_NOT_INITIALIZED - System not initialized. - name - A user allocated array of characters for storage of the Head Model. This should be declared as size MAX_PATH. - - C++ Equiv: - unsigned int GetHeadModel(char * name); - - ''' - cname = create_string_buffer(MAX_PATH) - ret = self.dll.GetHeadModel(cname) - return (ret, cname.value) - - def GetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetHorizontalSpeed(index) - - Inputs: - index - speed required, 0 to NumberSpeeds-1, where NumberSpeeds is the parameter returned by GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in micro-seconds per pixel shift - - C++ Equiv: - unsigned int GetHorizontalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberHorizontalSpeeds SetHorizontalSpeed - - Note: Deprecated by GetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetHorizontalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHSSpeed(self, channel, typ, index): - ''' - Description: - As your Andor system is capable of operating at more than one horizontal shift speed this function will return the actual speeds available. The value returned is in MHz. - - Synopsis: - (ret, speed) = GetHSSpeed(channel, typ, index) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR Mode(clara). - index - speed required Valid values: 0 to NumberSpeeds-1, where NumberSpeeds is value returned in first parameter after a call to GetNumberHSSpeedsGetNumberHSSpeeds(). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - DRV_P3INVALID - Invalid index - speed - speed in in MHz. - - C++ Equiv: - unsigned int GetHSSpeed(int channel, int typ, int index, float * speed); - - See Also: - GetNumberHSSpeeds SetHSSpeed - - Note: The speed is returned in microseconds per pixel shift for iStar and Classic systems. - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetHSSpeed(cchannel, ctyp, cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetHVflag(self): - ''' - Description: - This function will retrieve the High Voltage flag from your USB iStar intensifier. A 0 value indicates that the high voltage is abnormal. - - Synopsis: - (ret, bFlag) = GetHVflag() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - HV flag returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - bFlag - pointer to High Voltage flag. - - C++ Equiv: - unsigned int GetHVflag(int * bFlag); - - Note: Available only on USB iStar. - - ''' - cbFlag = c_int() - ret = self.dll.GetHVflag(byref(cbFlag)) - return (ret, cbFlag.value) - - def GetID(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, id) = GetID(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - id - - - C++ Equiv: - unsigned int GetID(int devNum, int * id); - - ''' - cdevNum = c_int(devNum) - cid = c_int() - ret = self.dll.GetID(cdevNum, byref(cid)) - return (ret, cid.value) - - def GetImageFlip(self): - ''' - Description: - This function will obtain whether the acquired data output is flipped in either the horizontal or vertical direction. - - Synopsis: - (ret, iHFlip, iVFlip) = GetImageFlip() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - iHFlip - Gets horizontal flipping. - iVFlip - Gets vertical flipping.: - 1 - Flipping Enabled - 0 - Flipping Disabled - - C++ Equiv: - unsigned int GetImageFlip(int * iHFlip, int * iVFlip); - - See Also: - SetImageRotate SetImageFlip - - ''' - ciHFlip = c_int() - ciVFlip = c_int() - ret = self.dll.GetImageFlip(byref(ciHFlip), byref(ciVFlip)) - return (ret, ciHFlip.value, ciVFlip.value) - - def GetImageRotate(self): - ''' - Description: - This function will obtain whether the acquired data output is rotated in any direction. - - Synopsis: - (ret, iRotate) = GetImageRotate() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - iRotate - Rotation setting: - 0 - - No rotation - 1 - - Rotate 90 degrees clockwise - 2 - - Rotate 90 degrees anti-clockwise - - C++ Equiv: - unsigned int GetImageRotate(int * iRotate); - - See Also: - SetImageFlip SetImageRotate SetReadMode - - ''' - ciRotate = c_int() - ret = self.dll.GetImageRotate(byref(ciRotate)) - return (ret, ciRotate.value) - - def GetImages(self, first, last, size): - ''' - Description: - This function will update the data array with the specified series of images from the circular buffer. If the specified series is out of range (i.e. the images have been overwritten or have not yet been acquired then an error will be returned. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages(long first, long last, at_32 * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages16 GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_int * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImages16(self, first, last, size): - ''' - Description: - 16-bit version of the GetImagesGetImages function. - - Synopsis: - (ret, arr, validfirst, validlast) = GetImages16(first, last, size) - - Inputs: - first - index of first image in buffer to retrieve. - last - index of last image in buffer to retrieve. - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Images have been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_GENERAL_ERRORS - The series is out of range. - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - validfirst - index of the first valid image. - validlast - index of the last valid image. - - C++ Equiv: - unsigned int GetImages16(long first, long last, WORD * arr, long size, long * validfirst, long * validlast); - - See Also: - GetImages GetNumberNewImages - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = (c_short * size)() - csize = c_int(size) - cvalidfirst = c_int() - cvalidlast = c_int() - ret = self.dll.GetImages16(cfirst, clast, carr, csize, byref(cvalidfirst), byref(cvalidlast)) - return (ret, carr, cvalidfirst.value, cvalidlast.value) - - def GetImagesPerDMA(self): - ''' - Description: - This function will return the maximum number of images that can be transferred during a single DMA transaction. - - Synopsis: - (ret, images) = GetImagesPerDMA() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of images per DMA returned. - images - The maximum number of images that can be transferred during a single DMA transaction - - C++ Equiv: - unsigned int GetImagesPerDMA(unsigned long * images); - - ''' - cimages = c_ulong() - ret = self.dll.GetImagesPerDMA(byref(cimages)) - return (ret, cimages.value) - - def GetIODirection(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iDirection) = GetIODirection(index) - - Inputs: - index - IO index. Valid values: 0 to GetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iDirection - current direction for this index.: - 0 - 0 Output - 1 - 1 Input - - C++ Equiv: - unsigned int GetIODirection(int index, int * iDirection); - - See Also: - GetNumberIO GetIOLevel SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int() - ret = self.dll.GetIODirection(cindex, byref(ciDirection)) - return (ret, ciDirection.value) - - def GetIOLevel(self, index): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the current state of a particular IO. - - Synopsis: - (ret, iLevel) = GetIOLevel(index) - - Inputs: - index - IO index: - 0 - toGetNumberIO() - 1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - C++ Equiv: - unsigned int GetIOLevel(int index, int * iLevel); - - See Also: - GetNumberIO GetIODirection SetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciLevel = c_int() - ret = self.dll.GetIOLevel(cindex, byref(ciLevel)) - return (ret, ciLevel.value) - - def GetIRQ(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, IRQ) = GetIRQ() - - Inputs: - None - - Outputs: - ret - Function Return Code - IRQ - - - C++ Equiv: - unsigned int GetIRQ(int * IRQ); - - ''' - cIRQ = c_int() - ret = self.dll.GetIRQ(byref(cIRQ)) - return (ret, cIRQ.value) - - def GetKeepCleanTime(self): - ''' - Description: - This function will return the time to perform a keep clean cycle. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, KeepCleanTime) = GetKeepCleanTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - KeepCleanTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetKeepCleanTime(float * KeepCleanTime); - - See Also: - GetAcquisitionTimings GetReadOutTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cKeepCleanTime = c_float() - ret = self.dll.GetKeepCleanTime(byref(cKeepCleanTime)) - return (ret, cKeepCleanTime.value) - - def GetMaximumBinning(self, ReadMode, HorzVert): - ''' - Description: - This function will return the maximum binning allowable in either the vertical or horizontal dimension for a particular readout mode. - - Synopsis: - (ret, MaxBinning) = GetMaximumBinning(ReadMode, HorzVert) - - Inputs: - ReadMode - The readout mode for which to retrieve the maximum binning (see SetReadMode for possible values). - HorzVert - 0 to retrieve horizontal binning limit, 1 to retreive limit in the vertical. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Binning returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid Readmode - DRV_P2INVALID - HorzVert not equal to 0 or 1 - DRV_P3INVALID - Invalid MaxBinning address (i.e. NULL) - MaxBinning - Will contain the Maximum binning value on return. - - C++ Equiv: - unsigned int GetMaximumBinning(int ReadMode, int HorzVert, int * MaxBinning); - - See Also: - GetMinimumImageLength SetReadMode - - ''' - cReadMode = c_int(ReadMode) - cHorzVert = c_int(HorzVert) - cMaxBinning = c_int() - ret = self.dll.GetMaximumBinning(cReadMode, cHorzVert, byref(cMaxBinning)) - return (ret, cMaxBinning.value) - - def GetMaximumExposure(self): - ''' - Description: - This function will return the maximum Exposure Time in seconds that is settable by the SetExposureTime function. - - Synopsis: - (ret, MaxExp) = GetMaximumExposure() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum Exposure returned. - DRV_P1INVALID - Invalid MaxExp value (i.e. NULL) - MaxExp - Will contain the Maximum exposure value on return. - - C++ Equiv: - unsigned int GetMaximumExposure(float * MaxExp); - - See Also: - SetExposureTime - - ''' - cMaxExp = c_float() - ret = self.dll.GetMaximumExposure(byref(cMaxExp)) - return (ret, cMaxExp.value) - - def GetMaximumNumberRingExposureTimes(self): - ''' - Description: - This function will return the maximum number of exposures that can be configured in the SetRingExposureTimes SDK function. - - Synopsis: - (ret, number) = GetMaximumNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid number value (ie NULL) - DRV_NOTAVAILABLE - System does not support this option - number - Will contain the maximum number of exposures on return. - - C++ Equiv: - unsigned int GetMaximumNumberRingExposureTimes(int * number); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable SetRingExposureTimes - - ''' - cnumber = c_int() - ret = self.dll.GetMaximumNumberRingExposureTimes(byref(cnumber)) - return (ret, cnumber.value) - - def GetMCPGain(self): - ''' - Description: - This function will retrieve the set value for the MCP Gain. - - Synopsis: - (ret, gain) = GetMCPGain() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Table returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Invalid pointer (i.e. NULL) - DRV_NOT_AVAILABLE - Not a USB iStar - gain - Returned gain value. - - C++ Equiv: - unsigned int GetMCPGain(int * gain); - - See Also: - SetMCPGain - - Note: Available only on USB iStar. - - ''' - cgain = c_int() - ret = self.dll.GetMCPGain(byref(cgain)) - return (ret, cgain.value) - - def GetMCPGainRange(self): - ''' - Description: - Returns the minimum and maximum values of the SetMCPGain function. - - Synopsis: - (ret, iLow, iHigh) = GetMCPGainRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain range returned. - DRV_NOT_INITIALIZED - System not initialized. - iLow - lowest gain setting - iHigh - highest gain setting - - C++ Equiv: - unsigned int GetMCPGainRange(int * iLow, int * iHigh); - - See Also: - SetMCPGain - - Note: Available only iStar. - - ''' - ciLow = c_int() - ciHigh = c_int() - ret = self.dll.GetMCPGainRange(byref(ciLow), byref(ciHigh)) - return (ret, ciLow.value, ciHigh.value) - - def GetMCPGainTable(self, iNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, piGain, pfPhotoepc) = GetMCPGainTable(iNum) - - Inputs: - iNum - - - Outputs: - ret - Function Return Code - piGain - - pfPhotoepc - - - C++ Equiv: - unsigned int GetMCPGainTable(int iNum, int * piGain, float * pfPhotoepc); - - ''' - ciNum = c_int(iNum) - cpiGain = c_int() - cpfPhotoepc = c_float() - ret = self.dll.GetMCPGainTable(ciNum, byref(cpiGain), byref(cpfPhotoepc)) - return (ret, cpiGain.value, cpfPhotoepc.value) - - def GetMCPVoltage(self): - ''' - Description: - This function will retrieve the current Micro Channel Plate voltage. - - Synopsis: - (ret, iVoltage) = GetMCPVoltage() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Voltage returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Not a USB iStar. - DRV_GENERAL_ERRORS - EEPROM not valid - iVoltage - Will contain voltage on return. The unit is in Volts and should be between the range 600 - 1100 Volts. - - C++ Equiv: - unsigned int GetMCPVoltage(int * iVoltage); - - See Also: - GetMCPGain - - Note: Available only on USB iStar. - - ''' - ciVoltage = c_int() - ret = self.dll.GetMCPVoltage(byref(ciVoltage)) - return (ret, ciVoltage.value) - - def GetMetaDataInfo(self, index): - ''' - Description: - This function will return the time of the initial frame and the time in milliseconds of further frames from this point. - - Synopsis: - (ret, TimeOfStart, pfTimeFromStart) = GetMetaDataInfo(index) - - Inputs: - index - frame for which time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - TimeOfStart - Structure with start time details. - pfTimeFromStart - time in milliseconds for a particular frame from time of start. - - C++ Equiv: - unsigned int GetMetaDataInfo(SYSTEMTIME * TimeOfStart, float * pfTimeFromStart, int index); - - See Also: - SetMetaData - - ''' - cTimeOfStart = SYSTEMTIME() - cpfTimeFromStart = c_float() - cindex = c_int(index) - ret = self.dll.GetMetaDataInfo(byref(cTimeOfStart), byref(cpfTimeFromStart), cindex) - return (ret, cTimeOfStart, cpfTimeFromStart.value) - - def GetMinimumImageLength(self): - ''' - Description: - This function will return the minimum number of pixels that can be read out from the chip at each exposure. This minimum value arises due the way in which the chip is read out and will limit the possible sub image dimensions and binning sizes that can be applied. - - Synopsis: - (ret, MinImageLength) = GetMinimumImageLength() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum Number of Pixels returned - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Invalid MinImageLength value (i.e. NULL) - MinImageLength - Will contain the minimum number of super pixels on return. - - C++ Equiv: - unsigned int GetMinimumImageLength(int * MinImageLength); - - See Also: - SetImage - - ''' - cMinImageLength = c_int() - ret = self.dll.GetMinimumImageLength(byref(cMinImageLength)) - return (ret, cMinImageLength.value) - - def GetMinimumNumberInSeries(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, number) = GetMinimumNumberInSeries() - - Inputs: - None - - Outputs: - ret - Function Return Code - number - - - C++ Equiv: - unsigned int GetMinimumNumberInSeries(int * number); - - ''' - cnumber = c_int() - ret = self.dll.GetMinimumNumberInSeries(byref(cnumber)) - return (ret, cnumber.value) - - def GetMostRecentColorImage16(self, size, algorithm): - ''' - Description: - For colour sensors only. - Color version of the GetMostRecentImage16 function. The CCD is sensitive to Cyan, Yellow, Magenta and Green (CYMG). The Red, Green and Blue (RGB) are calculated and Data is stored in 3 planes/images, one for each basic color. - - Synopsis: - (ret, red, green, blue) = GetMostRecentColorImage16(size, algorithm) - - Inputs: - size - total number of pixels. - algorithm - algorithm used to extract the RGB from the original CYMG CCD.: - 0 - 0 basic algorithm combining Cyan, Yellow and Magenta. - 1 - 1 algorithm combining Cyan, Yellow, Magenta and Green. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image RGB has been copied into arrays. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Arrays size is incorrect. - DRV_P2INVALID - Invalid algorithm. - DRV_P3INVALID - Invalid red pointer (i.e. NULL).. - DRV_P4INVALID - Invalid green pointer (i.e. NULL).. - DRV_P5INVALID - Invalid bluepointer (i.e. NULL).. - DRV_NO_NEW_DATA - There is no new data yet. - red - pointer to red data storage allocated by the user. - green - pointer to red data storage allocated by the user. - blue - pointer to red data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentColorImage16(unsigned long size, int algorithm, WORD * red, WORD * green, WORD * blue); - - See Also: - GetMostRecentImage16 DemosaicImage WhiteBalance - - ''' - csize = c_ulong(size) - calgorithm = c_int(algorithm) - cred = (c_short * size)() - cgreen = (c_short * size)() - cblue = (c_short * size)() - ret = self.dll.GetMostRecentColorImage16(csize, calgorithm, cred, cgreen, cblue) - return (ret, cred, cgreen, cblue) - - def GetMostRecentImage(self, size): - ''' - Description: - This function will update the data array with the most recently acquired image in any acquisition mode. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the complete image. - - Synopsis: - (ret, arr) = GetMostRecentImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage(at_32 * arr, unsigned long size); - - See Also: - GetMostRecentImage16 GetOldestImage GetOldestImage16 GetImages - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetMostRecentImage(carr, csize) - return (ret, carr) - - def GetMostRecentImage16(self, size): - ''' - Description: - 16-bit version of the GetMostRecentImageGetMostRecentImage function. - - Synopsis: - (ret, arr) = GetMostRecentImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetMostRecentImage16(WORD * arr, long size); - - See Also: - GetMostRecentImage GetOldestImage16 GetOldestImage GetImages - - ''' - carr = (c_short * size)() - csize = c_int(size) - ret = self.dll.GetMostRecentImage16(carr, csize) - return (ret, carr) - - def GetMSTimingsData(self, inoOfImages): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, TimeOfStart, pfDifferences) = GetMSTimingsData(inoOfImages) - - Inputs: - inoOfImages - - - Outputs: - ret - Function Return Code - TimeOfStart - - pfDifferences - - - C++ Equiv: - unsigned int GetMSTimingsData(SYSTEMTIME * TimeOfStart, float * pfDifferences, int inoOfImages); - - ''' - cTimeOfStart = SYSTEMTIME() - cpfDifferences = c_float() - cinoOfImages = c_int(inoOfImages) - ret = self.dll.GetMSTimingsData(byref(cTimeOfStart), byref(cpfDifferences), cinoOfImages) - return (ret, cTimeOfStart, cpfDifferences.value) - - def GetMSTimingsEnabled(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = GetMSTimingsEnabled() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int GetMSTimingsEnabled(void); - - ''' - ret = self.dll.GetMSTimingsEnabled() - return (ret) - - def GetNewData(self, size): - ''' - Description: - Deprecated see Note: - This function will update the data array to hold data acquired so far. The data are returned as long integers (32-bit signed integers). The array must be large enough to hold the complete data set. When used in conjunction with the SetDriverEventSetDriverEvent and GetAcquisitonProgressGetAcquisitionProgress functions, the data from each scan in a kinetic series can be processed while the acquisition is taking place. - - Synopsis: - (ret, arr) = GetNewData(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData(at_32 * arr, long size); // deprecated - - See Also: - SetDriverEvent GetAcquisitionProgress SetAcquisitionMode SetAcGetNewData8 GetNewData16 - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.GetNewData(byref(carr), csize) - return (ret, carr.value) - - def GetNewData16(self, size): - ''' - Description: - Deprecated see Note: - 16-bit version of the GetNewDataGetNewData function. - - Synopsis: - (ret, arr) = GetNewData16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData16(WORD * arr, long size); // deprecated - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = c_short() - csize = c_int(size) - ret = self.dll.GetNewData16(byref(carr), csize) - return (ret, carr.value) - - def GetNewData8(self, size): - ''' - Description: - Deprecated see Note: - 8-bit version of the GetNewDataGetNewData function. This function will return the data in the lower 8 bits of the acquired data. - - Synopsis: - (ret, arr) = GetNewData8(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data copied. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetNewData8(unsigned char * arr, long size); - - Note: Deprecated by the following functions: - * GetImages - * GetMostRecentImage - * GetOldestImage - - ''' - carr = (c_ubyte * size)() - csize = c_int(size) - ret = self.dll.GetNewData8(carr, csize) - return (ret, carr) - - def GetNewFloatData(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = GetNewFloatData(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int GetNewFloatData(float * arr, long size); - - ''' - carr = c_float() - csize = c_int(size) - ret = self.dll.GetNewFloatData(byref(carr), csize) - return (ret, carr.value) - - def GetNumberADChannels(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one A-D converter, this function will tell you the number available. - - Synopsis: - (ret, channels) = GetNumberADChannels() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of channels returned. - channels - number of allowed channels - - C++ Equiv: - unsigned int GetNumberADChannels(int * channels); - - See Also: - SetADChannel - - ''' - cchannels = c_int() - ret = self.dll.GetNumberADChannels(byref(cchannels)) - return (ret, cchannels.value) - - def GetNumberAmp(self): - ''' - Description: - As your Andor SDK system may be capable of operating with more than one output amplifier, this function will tell you the number available. - - Synopsis: - (ret, amp) = GetNumberAmp() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of output amplifiers returned. - amp - number of allowed channels - - C++ Equiv: - unsigned int GetNumberAmp(int * amp); - - See Also: - SetOutputAmplifier - - ''' - camp = c_int() - ret = self.dll.GetNumberAmp(byref(camp)) - return (ret, camp.value) - - def GetNumberAvailableImages(self): - ''' - Description: - This function will return information on the number of available images in the circular buffer. This information can be used with GetImages to retrieve a series of images. If any images are overwritten in the circular buffer they no longer can be retrieved and the information returned will treat overwritten images as not available. - - Synopsis: - (ret, first, last) = GetNumberAvailableImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned - DRV_NOT_INITIALIZED - System not initialized - DRV_ERROR_ACK - Unable to communicate with card - DRV_NO_NEW_DATA - There is no new data yet - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberAvailableImages(at_32 * first, at_32 * last); - - See Also: - GetImages GetImages16 GetNumberNewImages - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberAvailableImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberDDGExternalOutputs(self): - ''' - Description: - This function gets the number of available external outputs. - - Synopsis: - (ret, puiCount) = GetNumberDDGExternalOutputs() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - puiCount - number of available external outputs. - - C++ Equiv: - unsigned int GetNumberDDGExternalOutputs(at_u32 * puiCount); - - See Also: - GetCapabilities SetDDGExternalOutputEnabled SetDDGGateStep - - Note: Available on USB iStar. - - ''' - cpuiCount = c_uint() - ret = self.dll.GetNumberDDGExternalOutputs(byref(cpuiCount)) - return (ret, cpuiCount.value) - - def GetNumberDevices(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, numDevs) = GetNumberDevices() - - Inputs: - None - - Outputs: - ret - Function Return Code - numDevs - - - C++ Equiv: - unsigned int GetNumberDevices(int * numDevs); - - ''' - cnumDevs = c_int() - ret = self.dll.GetNumberDevices(byref(cnumDevs)) - return (ret, cnumDevs.value) - - def GetNumberFKVShiftSpeeds(self): - ''' - Description: - As your Andor SDK system is capable of operating at more than one fast kinetics vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberFKVShiftSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed speeds - - C++ Equiv: - unsigned int GetNumberFKVShiftSpeeds(int * number); - - See Also: - GetFKVShiftSpeedF SetFKVShiftSpeed - - Note: Only available if camera is Classic or iStar. - - ''' - cnumber = c_int() - ret = self.dll.GetNumberFKVShiftSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHorizontalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberHorizontalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHorizontalSpeeds(int * number); // deprecated - - See Also: - GetHorizontalSpeed SetHorizontalSpeed - - Note: Deprecated by GetNumberHSSpeedsGetNumberHSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberHorizontalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberHSSpeeds(self, channel, typ): - ''' - Description: - As your Andor SDK system is capable of operating at more than one horizontal shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, speeds) = GetNumberHSSpeeds(channel, typ) - - Inputs: - channel - the AD channel. - typ - output amplification.: - 0 - electron multiplication. - 1 - conventional. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid horizontal read mode - speeds - number of allowed horizontal speeds - - C++ Equiv: - unsigned int GetNumberHSSpeeds(int channel, int typ, int * speeds); - - See Also: - GetHSSpeed SetHSSpeed GetNumberADChannel - - ''' - cchannel = c_int(channel) - ctyp = c_int(typ) - cspeeds = c_int() - ret = self.dll.GetNumberHSSpeeds(cchannel, ctyp, byref(cspeeds)) - return (ret, cspeeds.value) - - def GetNumberIO(self): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function gets the number of these IOs available. The functions GetIODirection, GetIOLevel, SetIODirection and SetIOLevel can be used to specify the configuration. - - Synopsis: - (ret, iNumber) = GetNumberIO() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of IOs returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Feature not available. - iNumber - number of allowed IOs - - C++ Equiv: - unsigned int GetNumberIO(int * iNumber); - - See Also: - GetIOLevel GetIODirection SetIODirection SetIOLevel - - ''' - ciNumber = c_int() - ret = self.dll.GetNumberIO(byref(ciNumber)) - return (ret, ciNumber.value) - - def GetNumberNewImages(self): - ''' - Description: - This function will return information on the number of new images (i.e. images which have not yet been retrieved) in the circular buffer. This information can be used with GetImages to retrieve a series of the latest images. If any images are overwritten in the circular buffer they can no longer be retrieved and the information returned will treat overwritten images as having been retrieved. - - Synopsis: - (ret, first, last) = GetNumberNewImages() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NO_NEW_DATA - There is no new data yet. - first - returns the index of the first available image in the circular buffer. - last - returns the index of the last available image in the circular buffer. - - C++ Equiv: - unsigned int GetNumberNewImages(long * first, long * last); - - See Also: - GetImages GetImages16 GetNumberAvailableImages - - Note: This index will increment as soon as a single accumulation has been completed within the current acquisition. - - - ''' - cfirst = c_int() - clast = c_int() - ret = self.dll.GetNumberNewImages(byref(cfirst), byref(clast)) - return (ret, cfirst.value, clast.value) - - def GetNumberPhotonCountingDivisions(self): - ''' - Description: - Available in some systems is photon counting mode. This function gets the number of photon counting divisions available. The functions SetPhotonCounting and SetPhotonCountingThreshold can be used to specify which of these divisions is to be used. - - Synopsis: - (ret, noOfDivisions) = GetNumberPhotonCountingDivisions() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of photon counting divisions returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid parameter. - DRV_NOT_AVAILABLE - Photon Counting not available - noOfDivisions - number of allowed photon counting divisions - - C++ Equiv: - unsigned int GetNumberPhotonCountingDivisions(at_u32 * noOfDivisions); - - See Also: - SetPhotonCounting IsPreAmpGainAvailable SetPhotonCountingThresholdGetPreAmpGain GetCapabilities - - ''' - cnoOfDivisions = c_uint() - ret = self.dll.GetNumberPhotonCountingDivisions(byref(cnoOfDivisions)) - return (ret, cnoOfDivisions.value) - - def GetNumberPreAmpGains(self): - ''' - Description: - Available in some systems are a number of pre amp gains that can be applied to the data as it is read out. This function gets the number of these pre amp gains available. The functions GetPreAmpGain and SetPreAmpGain can be used to specify which of these gains is to be used. - - Synopsis: - (ret, noGains) = GetNumberPreAmpGains() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of pre amp gains returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - noGains - number of allowed pre amp gains - - C++ Equiv: - unsigned int GetNumberPreAmpGains(int * noGains); - - See Also: - IsPreAmpGainAvailable GetPreAmpGain SetPreAmpGain GetCapabilities - - ''' - cnoGains = c_int() - ret = self.dll.GetNumberPreAmpGains(byref(cnoGains)) - return (ret, cnoGains.value) - - def GetNumberRingExposureTimes(self): - ''' - Description: - Gets the number of exposures in the ring at this moment. - - Synopsis: - (ret, ipnumTimes) = GetNumberRingExposureTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - ipnumTimes - Numberof exposure times. - - C++ Equiv: - unsigned int GetNumberRingExposureTimes(int * ipnumTimes); - - See Also: - SetRingExposureTimes - - ''' - cipnumTimes = c_int() - ret = self.dll.GetNumberRingExposureTimes(byref(cipnumTimes)) - return (ret, cipnumTimes.value) - - def GetNumberVerticalSpeeds(self): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - - Synopsis: - (ret, number) = GetNumberVerticalSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of speeds returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - number - number of allowed vertical speeds - - C++ Equiv: - unsigned int GetNumberVerticalSpeeds(int * number); // deprecated - - See Also: - GetVerticalSpeed SetVerticalSpeed - - Note: Deprecated by GetNumberVSSpeedsGetNumberVSSpeeds - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVerticalSpeeds(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSAmplitudes(self): - ''' - Description: - This function will normally return the number of vertical clock voltage amplitues that the camera has. - - Synopsis: - (ret, number) = GetNumberVSAmplitudes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters - DRV_NOT_INITIALIZED - int* speeds: number of allowed vertical speeds - DRV_NOT_AVAILABLE - Return - Number returned - Return int - System not initialized - DRV_SUCCESS - Your system does not support this feature - DRV_NOT_INITIALIZED - GetNumberVSSpeeds - DRV_ACQUIRING - GetNumberVSSpeeds int WINAPI GetNumberVSSpeeds(int* speeds) - Number of speeds returned. - Description - System not initialized. - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual number of speeds available. - Acquisition in progress. - number - Number of vertical clock voltages. - - C++ Equiv: - unsigned int GetNumberVSAmplitudes(int * number); - - See Also: - GetVSSpeed SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cnumber = c_int() - ret = self.dll.GetNumberVSAmplitudes(byref(cnumber)) - return (ret, cnumber.value) - - def GetNumberVSSpeeds(self): - ''' - Description: - - - Synopsis: - (ret, speeds) = GetNumberVSSpeeds() - - Inputs: - None - - Outputs: - ret - Function Return Code - speeds - - - C++ Equiv: - unsigned int GetNumberVSSpeeds(int * speeds); - - ''' - cspeeds = c_int() - ret = self.dll.GetNumberVSSpeeds(byref(cspeeds)) - return (ret, cspeeds.value) - - def GetOldestImage(self, size): - ''' - Description: - This function will update the data array with the oldest image in the circular buffer. Once the oldest image has been retrieved it no longer is available. The data are returned as long integers (32-bit signed integers). The "array" must be exactly the same size as the full image. - - Synopsis: - (ret, arr) = GetOldestImage(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage(at_32 * arr, unsigned long size); - - See Also: - GetOldestImage16 GetMostRecentImage GetMostRecentImage16 - - ''' - carr = (c_int * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage(carr, csize) - return (ret, carr) - - def GetOldestImage16(self, size): - ''' - Description: - 16-bit version of the GetOldestImageGetOldestImage function. - - Synopsis: - (ret, arr) = GetOldestImage16(size) - - Inputs: - size - total number of pixels. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Image has been copied into array. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Array size is incorrect. - DRV_NO_NEW_DATA - There is no new data yet. - arr - pointer to data storage allocated by the user. - - C++ Equiv: - unsigned int GetOldestImage16(WORD * arr, unsigned long size); - - See Also: - GetOldestImage GetMostRecentImage16 GetMostRecentImage - - ''' - carr = (c_short * size)() - csize = c_ulong(size) - ret = self.dll.GetOldestImage16(carr, csize) - return (ret, carr) - - def GetPhosphorStatus(self): - ''' - Description: - This function will return if the phosphor has saturated. - - Synopsis: - (ret, flag) = GetPhosphorStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Phosphor status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - flag - The status of the phosphor: - 0 - Normal - 1 - Saturated - - C++ Equiv: - unsigned int GetPhosphorStatus(int * flag); - - ''' - cflag = c_int() - ret = self.dll.GetPhosphorStatus(byref(cflag)) - return (ret, cflag.value) - - def GetPhysicalDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetPhysicalDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetPhysicalDMAAddress(unsigned long * Address1, unsigned long * Address2); - - ''' - cAddress1 = c_ulong() - cAddress2 = c_ulong() - ret = self.dll.GetPhysicalDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetPixelSize(self): - ''' - Description: - This function returns the dimension of the pixels in the detector in microns. - - Synopsis: - (ret, xSize, ySize) = GetPixelSize() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pixel size returned. - xSize - width of pixel. - ySize - height of pixel. - - C++ Equiv: - unsigned int GetPixelSize(float * xSize, float * ySize); - - ''' - cxSize = c_float() - cySize = c_float() - ret = self.dll.GetPixelSize(byref(cxSize), byref(cySize)) - return (ret, cxSize.value, cySize.value) - - def GetPreAmpGain(self, index): - ''' - Description: - For those systems that provide a number of pre amp gains to apply to the data as it is read out; this function retrieves the amount of gain that is stored for a particular index. The number of gains available can be obtained by calling the GetNumberPreAmpGainsGetNumberPreAmpGains function and a specific Gain can be selected using the function SetPreAmpGainSetPreAmpGain. - - Synopsis: - (ret, gain) = GetPreAmpGain(index) - - Inputs: - index - gain index: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gain returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - gain - gain factor for this index. - - C++ Equiv: - unsigned int GetPreAmpGain(int index, float * gain); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cgain = c_float() - ret = self.dll.GetPreAmpGain(cindex, byref(cgain)) - return (ret, cgain.value) - - def GetPreAmpGainText(self, index, length): - ''' - Description: - This function will return a string with a pre amp gain description. The pre amp gain is selected using the index. The SDK has a string associated with each of its pre amp gains. The maximum number of characters needed to store the pre amp gain descriptions is 30. The user has to specify the number of characters they wish to have returned to them from this function. - - Synopsis: - (ret, name) = GetPreAmpGainText(index, length) - - Inputs: - index - gain index 0 to GetNumberPreAmpGainsGetNumberPreAmpGains()-1 - length - The length of the user allocated character array. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Description returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Array size is incorrect - DRV_NOT_SUPPORTED - Function not supported with this camera - name - nameA user allocated array of characters for storage of the description. - - C++ Equiv: - unsigned int GetPreAmpGainText(int index, char * name, int length); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains SetPreAmpGain GetCapabilities - - ''' - cindex = c_int(index) - cname = create_string_buffer(length) - clength = c_int(length) - ret = self.dll.GetPreAmpGainText(cindex, cname, clength) - return (ret, cname) - - def GetQE(self, sensor, wavelength, mode): - ''' - Description: - Returns the percentage QE for a particular head model at a user specified wavelengthSetPreAmpGain. - - Synopsis: - (ret, QE) = GetQE(sensor, wavelength, mode) - - Inputs: - sensor - head model - wavelength - wavelength at which QE is required - mode - Clara mode (Normal (0) or Extended NIR (1)). 0 for all other systems - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - QE returned. - DRV_NOT_INITIALIZED - System not initialized. - QE - requested QE - - C++ Equiv: - unsigned int GetQE(char * sensor, float wavelength, int mode, float * QE); - - See Also: - GetHeadModel IsPreAmpGainAvailable SetPreAmpGain GetCapabilities - - ''' - csensor = sensor - cwavelength = c_float(wavelength) - cmode = c_int(mode) - cQE = c_float() - ret = self.dll.GetQE(csensor, cwavelength, cmode, byref(cQE)) - return (ret, cQE.value) - - def GetReadOutTime(self): - ''' - Description: - This function will return the time to readout data from a sensor. This function should be used after all the acquisitions settings have been set, e.g. SetExposureTimeSetExposureTime, SetKineticCycleTimeSetKineticCycleTime and SetReadModeSetReadMode etc. The value returned is the actual times used in subsequent acquisitions. - - Synopsis: - (ret, ReadOutTime) = GetReadOutTime() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timing information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_CODES - Error communicating with camera. - ReadOutTime - valid readout time in seconds - - C++ Equiv: - unsigned int GetReadOutTime(float * ReadOutTime); - - See Also: - GetAcquisitionTimings GetKeepCleanTime - - Note: Available on iDus, iXon, Luca & Newton. - - - ''' - cReadOutTime = c_float() - ret = self.dll.GetReadOutTime(byref(cReadOutTime)) - return (ret, cReadOutTime.value) - - def GetRegisterDump(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, mode) = GetRegisterDump() - - Inputs: - None - - Outputs: - ret - Function Return Code - mode - - - C++ Equiv: - unsigned int GetRegisterDump(int * mode); - - ''' - cmode = c_int() - ret = self.dll.GetRegisterDump(byref(cmode)) - return (ret, cmode.value) - - def GetRelativeImageTimes(self, first, last, size): - ''' - Description: - This function will return an array of the start times in nanoseconds of a user defined number of frames relative to the initial frame. - - Synopsis: - (ret, arr) = GetRelativeImageTimes(first, last, size) - - Inputs: - first - Index of first frame in array. - last - Index of last frame in array. - size - number of frames for which start time is required. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings returned - DRV_NOT_INITIALIZED - System not initialized - DRV_MSTIMINGS_ERROR - Invalid timing request - arr - array of times in nanoseconds for each frame from time of start. - - C++ Equiv: - unsigned int GetRelativeImageTimes(int first, int last, at_u64 * arr, int size); - - See Also: - GetCapabilities SetMetaData - - ''' - cfirst = c_int(first) - clast = c_int(last) - carr = c_ulonglong() - csize = c_int(size) - ret = self.dll.GetRelativeImageTimes(cfirst, clast, byref(carr), csize) - return (ret, carr.value) - - def GetRingExposureRange(self): - ''' - Description: - With the Ring Of Exposure feature there may be a case when not all exposures can be met. The ring of exposure feature will guarantee that the highest exposure will be met but this may mean that the lower exposures may not be. If the lower exposures are too low they will be increased to the lowest value possible. This function will return these upper and lower values. - - Synopsis: - (ret, fpMin, fpMax) = GetRingExposureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Min and max returned - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Trigger mode is not available - fpMin - Minimum exposure - fpMax - Maximum exposure. - - C++ Equiv: - unsigned int GetRingExposureRange(float * fpMin, float * fpMax); - - See Also: - GetCapabilities GetNumberRingExposureTimes IsTriggerModeAvailable SetRingExposureTimes - - ''' - cfpMin = c_float() - cfpMax = c_float() - ret = self.dll.GetRingExposureRange(byref(cfpMin), byref(cfpMax)) - return (ret, cfpMin.value, cfpMax.value) - - def GetSDK3Handle(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Handle) = GetSDK3Handle() - - Inputs: - None - - Outputs: - ret - Function Return Code - Handle - - - C++ Equiv: - unsigned int GetSDK3Handle(int * Handle); - - ''' - cHandle = c_int() - ret = self.dll.GetSDK3Handle(byref(cHandle)) - return (ret, cHandle.value) - - def GetSensitivity(self, channel, horzShift, amplifier, pa): - ''' - Description: - This function returns the sensitivity for a particular speed. - - Synopsis: - (ret, sensitivity) = GetSensitivity(channel, horzShift, amplifier, pa) - - Inputs: - channel - AD channel index. - horzShift - Type of output amplifier. - amplifier - Channel speed index. - pa - PreAmp gain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sensitivity returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - sensitivity - requested sensitivity. - - C++ Equiv: - unsigned int GetSensitivity(int channel, int horzShift, int amplifier, int pa, float * sensitivity); - - See Also: - GetCapabilities - - Note: Available only on iXon+ and Clara. - - ''' - cchannel = c_int(channel) - chorzShift = c_int(horzShift) - camplifier = c_int(amplifier) - cpa = c_int(pa) - csensitivity = c_float() - ret = self.dll.GetSensitivity(cchannel, chorzShift, camplifier, cpa, byref(csensitivity)) - return (ret, csensitivity.value) - - def GetShutterMinTimes(self): - ''' - Description: - This function will return the minimum opening and closing times in milliseconds for the shutter on the current camera. - - Synopsis: - (ret, minclosingtime, minopeningtime) = GetShutterMinTimes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Minimum times successfully returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Parameter is NULL. - DRV_P2INVALID - Parameter is NULL - minclosingtime - returns the minimum closing time in milliseconds that the shutter of the camera supports. - minopeningtime - returns the minimum opening time in milliseconds that the shutter of the camera supports. - - C++ Equiv: - unsigned int GetShutterMinTimes(int * minclosingtime, int * minopeningtime); - - ''' - cminclosingtime = c_int() - cminopeningtime = c_int() - ret = self.dll.GetShutterMinTimes(byref(cminclosingtime), byref(cminopeningtime)) - return (ret, cminclosingtime.value, cminopeningtime.value) - - def GetSizeOfCircularBuffer(self): - ''' - Description: - This function will return the maximum number of images the circular buffer can store based on the current acquisition settings. - - Synopsis: - (ret, index) = GetSizeOfCircularBuffer() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Maximum number of images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the maximum number of images the circular buffer can store. - - C++ Equiv: - unsigned int GetSizeOfCircularBuffer(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetSizeOfCircularBuffer(byref(cindex)) - return (ret, cindex.value) - - def GetSlotBusDeviceFunction(self): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - (ret, dwslot, dwBus, dwDevice, dwFunction) = GetSlotBusDeviceFunction() - - Inputs: - None - - Outputs: - ret - Function Return Code - dwslot - - dwBus - - dwDevice - - dwFunction - - - C++ Equiv: - unsigned int GetSlotBusDeviceFunction(DWORD * dwslot, DWORD * dwBus, DWORD * dwDevice, DWORD * dwFunction); - - ''' - cdwslot = () - cdwBus = () - cdwDevice = () - cdwFunction = () - ret = self.dll.GetSlotBusDeviceFunction(byref(cdwslot), byref(cdwBus), byref(cdwDevice), byref(cdwFunction)) - return (ret, cdwslot.value, cdwBus.value, cdwDevice.value, cdwFunction.value) - - def GetSoftwareVersion(self): - ''' - Description: - This function returns the Software version information for the microprocessor code and the driver. - - Synopsis: - (ret, eprom, coffile, vxdrev, vxdver, dllrev, dllver) = GetSoftwareVersion() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Version information returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - eprom - EPROM version - coffile - COF file version - vxdrev - Driver revision number - vxdver - Driver version number - dllrev - DLL revision number - dllver - DLL version number - - C++ Equiv: - unsigned int GetSoftwareVersion(unsigned int * eprom, unsigned int * coffile, unsigned int * vxdrev, unsigned int * vxdver, unsigned int * dllrev, unsigned int * dllver); - - ''' - ceprom = c_uint() - ccoffile = c_uint() - cvxdrev = c_uint() - cvxdver = c_uint() - cdllrev = c_uint() - cdllver = c_uint() - ret = self.dll.GetSoftwareVersion(byref(ceprom), byref(ccoffile), byref(cvxdrev), byref(cvxdver), byref(cdllrev), byref(cdllver)) - return (ret, ceprom.value, ccoffile.value, cvxdrev.value, cvxdver.value, cdllrev.value, cdllver.value) - - def GetSpoolProgress(self): - ''' - Description: - Deprecated see Note: - This function will return information on the progress of the current spool operation. The value returned is the number of images that have been saved to disk during the current kinetic scan. - - Synopsis: - (ret, index) = GetSpoolProgress() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Spool progress returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the number of files saved to disk in the current kinetic scan. - - C++ Equiv: - unsigned int GetSpoolProgress(long * index); // deprecated - - See Also: - SetSpool - - Note: Deprecated by GetTotalNumberImagesAcquiredGetNumberHSSpeeds - - ''' - cindex = c_int() - ret = self.dll.GetSpoolProgress(byref(cindex)) - return (ret, cindex.value) - - def GetStartUpTime(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, time) = GetStartUpTime() - - Inputs: - None - - Outputs: - ret - Function Return Code - time - - - C++ Equiv: - unsigned int GetStartUpTime(float * time); - - ''' - ctime = c_float() - ret = self.dll.GetStartUpTime(byref(ctime)) - return (ret, ctime.value) - - def GetStatus(self): - ''' - Description: - This function will return the current status of the Andor SDK system. This function should be called before an acquisition is started to ensure that it is IDLE and during an acquisition to monitor the process. - - Synopsis: - (ret, status) = GetStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned - DRV_NOT_INITIALIZED - System not initialized - status - current status: - DRV_IDLE - waiting on instructions. - DRV_TEMPCYCLE - Executing temperature cycle. - DRV_ACQUIRING - Acquisition in progress. - DRV_ACCUM_TIME_NOT_MET - Unable to meet Accumulate cycle time. - DRV_KINETIC_TIME_NOT_MET - Unable to meet Kinetic cycle time. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQ_BUFFER - Computer unable to read the data via the ISA slot at the required rate. - DRV_SPOOLERROR - Overflow of the spool buffer. - - C++ Equiv: - unsigned int GetStatus(int * status); - - See Also: - SetTemperature StartAcquisition - - Note: If the status is one of the following: - - ''' - cstatus = c_int() - ret = self.dll.GetStatus(byref(cstatus)) - return (ret, cstatus.value) - - def GetTECStatus(self): - ''' - Description: - This function will return if the TEC has overheated. - - Synopsis: - (ret, piFlag) = GetTECStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - TEC status not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - piFlag - The status of the TEC: - 0 - Normal - 1 - Tripped - - C++ Equiv: - unsigned int GetTECStatus(int * piFlag); - - See Also: - SetTECEvent - - ''' - cpiFlag = c_int() - ret = self.dll.GetTECStatus(byref(cpiFlag)) - return (ret, cpiFlag.value) - - def GetTemperature(self): - ''' - Description: - This function returns the temperature of the detector to the nearest degree. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperature() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilized but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperature(int * temperature); - - See Also: - GetTemperatureF SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_int() - ret = self.dll.GetTemperature(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureF(self): - ''' - Description: - This function returns the temperature in degrees of the detector. It also gives the status of cooling process. - - Synopsis: - (ret, temperature) = GetTemperatureF() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_TEMP_OFF - Temperature is OFF. - DRV_TEMP_STABILIZED - Temperature has stabilized at set point. - DRV_TEMP_NOT_REACHED - Temperature has not reached set point. - DRV_TEMP_DRIFT - Temperature had stabilised but has since drifted - DRV_TEMP_NOT_STABILIZED - Temperature reached but not stabilized - temperature - temperature of the detector - - C++ Equiv: - unsigned int GetTemperatureF(float * temperature); - - See Also: - GetTemperature SetTemperature CoolerON CoolerOFF GetTemperatureRange - - ''' - ctemperature = c_float() - ret = self.dll.GetTemperatureF(byref(ctemperature)) - return (ret, ctemperature.value) - - def GetTemperatureRange(self): - ''' - Description: - This function returns the valid range of temperatures in centigrade to which the detector can be cooled. - - Synopsis: - (ret, mintemp, maxtemp) = GetTemperatureRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature range returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - mintemp - minimum temperature - maxtemp - maximum temperature - - C++ Equiv: - unsigned int GetTemperatureRange(int * mintemp, int * maxtemp); - - See Also: - GetTemperature GetTemperatureF SetTemperature CoolerON CoolerOFF - - ''' - cmintemp = c_int() - cmaxtemp = c_int() - ret = self.dll.GetTemperatureRange(byref(cmintemp), byref(cmaxtemp)) - return (ret, cmintemp.value, cmaxtemp.value) - - def GetTemperatureStatus(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, SensorTemp, TargetTemp, AmbientTemp, CoolerVolts) = GetTemperatureStatus() - - Inputs: - None - - Outputs: - ret - Function Return Code - SensorTemp - - TargetTemp - - AmbientTemp - - CoolerVolts - - - C++ Equiv: - unsigned int GetTemperatureStatus(float * SensorTemp, float * TargetTemp, float * AmbientTemp, float * CoolerVolts); - - ''' - cSensorTemp = c_float() - cTargetTemp = c_float() - cAmbientTemp = c_float() - cCoolerVolts = c_float() - ret = self.dll.GetTemperatureStatus(byref(cSensorTemp), byref(cTargetTemp), byref(cAmbientTemp), byref(cCoolerVolts)) - return (ret, cSensorTemp.value, cTargetTemp.value, cAmbientTemp.value, cCoolerVolts.value) - - def GetTotalNumberImagesAcquired(self): - ''' - Description: - This function will return the total number of images acquired since the current acquisition started. If the camera is idle the value returned is the number of images acquired during the last acquisition. - - Synopsis: - (ret, index) = GetTotalNumberImagesAcquired() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Number of acquired images returned. - DRV_NOT_INITIALIZED - System not initialized. - index - returns the total number of images acquired since the acquisition started. - - C++ Equiv: - unsigned int GetTotalNumberImagesAcquired(long * index); - - ''' - cindex = c_int() - ret = self.dll.GetTotalNumberImagesAcquired(byref(cindex)) - return (ret, cindex.value) - - def GetTriggerLevelRange(self): - ''' - Description: - This function returns the valid range of triggers in volts which the system can use. - - Synopsis: - (ret, minimum, maximum) = GetTriggerLevelRange() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Levels returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - minimum has invalid memory address. - minimum - minimum trigger voltage - maximum - maximum trigger voltage - - C++ Equiv: - unsigned int GetTriggerLevelRange(float * minimum, float * maximum); - - See Also: - GetCapabilities SetTriggerLevel - - ''' - cminimum = c_float() - cmaximum = c_float() - ret = self.dll.GetTriggerLevelRange(byref(cminimum), byref(cmaximum)) - return (ret, cminimum.value, cmaximum.value) - - def GetVersionInfo(self, arr, ui32BufferLen): - ''' - Description: - This function retrieves version information about different aspects of the Andor system. The information is copied into a passed string buffer. Currently, the version of the SDK and the Device Driver (USB or PCI) is supported. - - Synopsis: - (ret, szVersionInfo) = GetVersionInfo(arr, ui32BufferLen) - - Inputs: - arr - : - AT_SDKVersion - requests the SDK version information - AT_DeviceDriverVersion - requests the device driver version - ui32BufferLen - The size of the passed character array, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS Information returned - Information returned - DRV_NOT_INITIALIZED System not initialized - System not initialized - DRV_P1INVALID - Invalid information type requested - DRV_P2INVALID - Storage array pointer is NULL - DRV_P3INVALID - Size of the storage array is zero - szVersionInfo - A user allocated array of characters for storage of the information - - C++ Equiv: - unsigned int GetVersionInfo(AT_VersionInfoId arr, char * szVersionInfo, at_u32 ui32BufferLen); - - See Also: - GetHeadModel GetCameraSerialNumber GetCameraInformation GetCapabilities - - ''' - carr = (arr) - cszVersionInfo = create_string_buffer(ui32BufferLen) - cui32BufferLen = c_uint(ui32BufferLen) - ret = self.dll.GetVersionInfo(carr, cszVersionInfo, cui32BufferLen) - return (ret, cszVersionInfo) - - def GetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - As your Andor system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds per pixel shift. - - Synopsis: - (ret, speed) = GetVerticalSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING DRV_P1INVALID - Acquisition in progress. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVerticalSpeed(int index, int * speed); // deprecated - - See Also: - GetNumberVerticalSpeeds SetVerticalSpeed - - Note: Deprecated by GetVSSpeedGetVSSpeed. - - ''' - cindex = c_int(index) - cspeed = c_int() - ret = self.dll.GetVerticalSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GetVirtualDMAAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, Address1, Address2) = GetVirtualDMAAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - Address1 - - Address2 - - - C++ Equiv: - unsigned int GetVirtualDMAAddress(void * Address1, void * Address2); - - ''' - cAddress1 = c_void() - cAddress2 = c_void() - ret = self.dll.GetVirtualDMAAddress(byref(cAddress1), byref(cAddress2)) - return (ret, cAddress1.value, cAddress2.value) - - def GetVSAmplitudeFromString(self, text): - ''' - Description: - This Function is used to get the index of the Vertical Clock Amplitude that corresponds to the string passed in. - - Synopsis: - (ret, index) = GetVSAmplitudeFromString(text) - - Inputs: - text - String to test "Normal" , "+1" , "+2" , "+3" , "+4" - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string Index returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid text. - DRV_P2INVALID - Invalid index pointer. - index - Returns the Index of the VSAmplitude that matches string passed in - - C++ Equiv: - unsigned int GetVSAmplitudeFromString(char * text, int * index); - - See Also: - GetVSAmplitudeString GetVSAmplitudeValue - - ''' - ctext = text - cindex = c_int() - ret = self.dll.GetVSAmplitudeFromString(ctext, byref(cindex)) - return (ret, cindex.value) - - def GetVSAmplitudeString(self, index): - ''' - Description: - This Function is used to get the Vertical Clock Amplitude string that corresponds to the index passed in. - - Synopsis: - (ret, text) = GetVSAmplitudeString(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude string returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid text pointer. - text - Returns string value of the VS Amplitude found at the index supplied - - C++ Equiv: - unsigned int GetVSAmplitudeString(int index, char * text); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeValue - - ''' - cindex = c_int(index) - ctext = create_string_buffer(64) - ret = self.dll.GetVSAmplitudeString(cindex, ctext) - return (ret, ctext) - - def GetVSAmplitudeValue(self, index): - ''' - Description: - This Function is used to get the value of the Vertical Clock Amplitude found at the index passed in. - - Synopsis: - (ret, value) = GetVSAmplitudeValue(index) - - Inputs: - index - Index of VS amplitude required: - 0 - to GetNumberVSAmplitudes()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical Clock Amplitude value returned - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid value pointer. - value - Returns Value of Vertical Clock Amplitude that matches index passed in - - C++ Equiv: - unsigned int GetVSAmplitudeValue(int index, int * value); - - See Also: - GetVSAmplitudeFromString GetVSAmplitudeString - - ''' - cindex = c_int(index) - cvalue = c_int() - ret = self.dll.GetVSAmplitudeValue(cindex, byref(cvalue)) - return (ret, cvalue.value) - - def GetVSSpeed(self, index): - ''' - Description: - As your Andor SDK system may be capable of operating at more than one vertical shift speed this function will return the actual speeds available. The value returned is in microseconds. - - Synopsis: - (ret, speed) = GetVSSpeed(index) - - Inputs: - index - speed required: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds()-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Speed returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - speed - speed in microseconds per pixel shift. - - C++ Equiv: - unsigned int GetVSSpeed(int index, float * speed); - - See Also: - GetNumberVSSpeeds SetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - cspeed = c_float() - ret = self.dll.GetVSSpeed(cindex, byref(cspeed)) - return (ret, cspeed.value) - - def GPIBReceive(self, id, address, size): - ''' - Description: - This function reads data from a device until a byte is received with the EOI line asserted or until size bytes have been read. - - Synopsis: - (ret, text) = GPIBReceive(id, address, size) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The address to send the data to - size - Number of characters to read - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data received. - DRV_P3INVALID - Invalid pointer (e.g. NULL). .Other errors may be returned by the GPIB device. Consult the help documentation supplied with these devices. - text - The data to be sent - - C++ Equiv: - unsigned int GPIBReceive(int id, short address, char * text, int size); - - See Also: - GPIBSend - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = create_string_buffer(size) - csize = c_int(size) - ret = self.dll.GPIBReceive(cid, caddress, ctext, csize) - return (ret, ctext) - - def GPIBSend(self, id, address, text): - ''' - Description: - This function initializes the GPIB by sending interface clear. Then the device described by address is put in a listen-active state. Finally the string of characters, text, is sent to the device with a newline character and with the EOI line asserted after the final character. - - Synopsis: - ret = GPIBSend(id, address, text) - - Inputs: - id - The interface board number: - short - address: Address of device to send data - address - The GPIB address to send data to - text - The data to send - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data sent. - DRV_P3INVALID - Invalid pointer (e.g. NULL). The GPIB device may return other errors. Consult the help documentation supplied with these devices. - - C++ Equiv: - unsigned int GPIBSend(int id, short address, char * text); - - See Also: - GPIBReceive - - ''' - cid = c_int(id) - caddress = c_short(address) - ctext = text - ret = self.dll.GPIBSend(cid, caddress, ctext) - return (ret) - - def I2CBurstRead(self, i2cAddress, nBytes): - ''' - Description: - This function will read a specified number of bytes from a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstRead(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to read from. - nBytes - The number of bytes to read from the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data read from the device. - - C++ Equiv: - unsigned int I2CBurstRead(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstWrite I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstRead(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CBurstWrite(self, i2cAddress, nBytes): - ''' - Description: - This function will write a specified number of bytes to a chosen device attached to the I2C data bus. - - Synopsis: - (ret, data) = I2CBurstWrite(i2cAddress, nBytes) - - Inputs: - i2cAddress - The address of the device to write to. - nBytes - The number of bytes to write to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - data - The data to write to the device. - - C++ Equiv: - unsigned int I2CBurstWrite(BYTE i2cAddress, long nBytes, BYTE * data); - - See Also: - I2CBurstRead I2CRead I2CWrite I2CReset - - ''' - ci2cAddress = c_ubyte(i2cAddress) - cnBytes = c_int(nBytes) - cdata = c_ubyte() - ret = self.dll.I2CBurstWrite(ci2cAddress, cnBytes, byref(cdata)) - return (ret, cdata.value) - - def I2CRead(self, deviceID, intAddress): - ''' - Description: - This function will read a single byte from the chosen device. - - Synopsis: - (ret, pdata) = I2CRead(deviceID, intAddress) - - Inputs: - deviceID - The device to read from. - intAddress - The internal address of the device to be read from. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Read successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - pdata - The byte read from the device. - - C++ Equiv: - unsigned int I2CRead(BYTE deviceID, BYTE intAddress, BYTE * pdata); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cpdata = c_ubyte() - ret = self.dll.I2CRead(cdeviceID, cintAddress, byref(cpdata)) - return (ret, cpdata.value) - - def I2CReset(self): - ''' - Description: - This function will reset the I2C data bus. - - Synopsis: - ret = I2CReset() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Reset successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CReset(void); - - See Also: - I2CBurstWrite I2CBurstRead I2CWrite - - ''' - ret = self.dll.I2CReset() - return (ret) - - def I2CWrite(self, deviceID, intAddress, data): - ''' - Description: - This function will write a single byte to the chosen device. - - Synopsis: - ret = I2CWrite(deviceID, intAddress, data) - - Inputs: - deviceID - The device to write to. - intAddress - The internal address of the device to write to. - data - The byte to be written to the device. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Write successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_I2CDEVNOTFOUND - Could not find the specified device. - DRV_I2CTIMEOUT - Timed out reading from device. - DRV_UNKNOWN_FUNC - Unknown function, incorrect cof file. - - C++ Equiv: - unsigned int I2CWrite(BYTE deviceID, BYTE intAddress, BYTE data); - - See Also: - I2CBurstWrite I2CBurstRead I2CRead I2CReset - - ''' - cdeviceID = c_ubyte(deviceID) - cintAddress = c_ubyte(intAddress) - cdata = c_ubyte(data) - ret = self.dll.I2CWrite(cdeviceID, cintAddress, cdata) - return (ret) - - def IdAndorDll(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = IdAndorDll() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int IdAndorDll(void); - - ''' - ret = self.dll.IdAndorDll() - return (ret) - - def InAuxPort(self, port): - ''' - Description: - This function returns the state of the TTL Auxiliary Input Port on the Andor plug-in card. - - Synopsis: - (ret, state) = InAuxPort(port) - - Inputs: - port - Number of AUX in port on Andor card. Valid Values: 1 to 4 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX read. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - state - current state of port: - 0 - OFF/LOW - all others - ON/HIGH - - C++ Equiv: - unsigned int InAuxPort(int port, int * state); - - See Also: - OutAuxPort - - ''' - cport = c_int(port) - cstate = c_int() - ret = self.dll.InAuxPort(cport, byref(cstate)) - return (ret, cstate.value) - - def Initialize(self, dir): - ''' - Description: - This function will initialize the Andor SDK System. As part of the initialization procedure on some cameras (i.e. Classic, iStar and earlier iXion) the DLL will need access to a DETECTOR.INI which contains information relating to the detector head, number pixels, readout speeds etc. If your system has multiple cameras then see the section Controlling multiple cameras - - Synopsis: - ret = Initialize(dir) - - Inputs: - dir - Path to the directory containing the files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_VXDNOTINSTALLED - Initialisation successful. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_INIERROR - Unable to load DETECTOR.INI. - DRV_COFERROR - Unable to load *.COF. - DRV_FLEXERROR - Unable to load *.RBF. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ERROR_FILELOAD - Unable to load *.COF or *.RBF files. - DRV_ERROR_PAGELOCK - Unable to acquire lock on requested memory. - DRV_USBERROR - Unable to detect USB device or not USB2.0. - DRV_ERROR_NOCAMERA - No camera found - - C++ Equiv: - unsigned int Initialize(char * dir); - - See Also: - GetAvailableCameras SetCurrentCamera GetCurrentCamera - - ''' - cdir = dir - ret = self.dll.Initialize(cdir) - return (ret) - - def InitializeDevice(self, dir): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = InitializeDevice(dir) - - Inputs: - dir - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int InitializeDevice(char * dir); - - ''' - cdir = dir - ret = self.dll.InitializeDevice(cdir) - return (ret) - - def IsAmplifierAvailable(self, iamp): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified amplifier. - - Synopsis: - ret = IsAmplifierAvailable(iamp) - - Inputs: - iamp - amplifier to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplifier available - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_AMPLIFIER - Not a valid amplifier - - C++ Equiv: - unsigned int IsAmplifierAvailable(int iamp); - - See Also: - SetHSSpeed - - ''' - ciamp = c_int(iamp) - ret = self.dll.IsAmplifierAvailable(ciamp) - return (ret) - - def IsCoolerOn(self): - ''' - Description: - This function checks the status of the cooler. - - Synopsis: - (ret, iCoolerStatus) = IsCoolerOn() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Status returned. - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - Parameter is NULL - iCoolerStatus - iCoolerStatus0: Cooler is OFF.: - 1 - 1 Cooler is ON. - - C++ Equiv: - unsigned int IsCoolerOn(int * iCoolerStatus); - - See Also: - CoolerON CoolerOFF - - ''' - ciCoolerStatus = c_int() - ret = self.dll.IsCoolerOn(byref(ciCoolerStatus)) - return (ret, ciCoolerStatus.value) - - def IsCountConvertModeAvailable(self, mode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified Count Convert mode. - - Synopsis: - ret = IsCountConvertModeAvailable(mode) - - Inputs: - mode - Count Convert mode to be checked - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode available. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Count Convert not supported on this camera - DRV_INVALID_COUNTCONVERT_MODE - Count Convert mode not available with current acquisition settings - - C++ Equiv: - unsigned int IsCountConvertModeAvailable(int mode); - - See Also: - GetCapabilities SetCountConvertMode SetCountConvertWavelength - - ''' - cmode = c_int(mode) - ret = self.dll.IsCountConvertModeAvailable(cmode) - return (ret) - - def IsInternalMechanicalShutter(self): - ''' - Description: - This function checks if an iXon camera has a mechanical shutter installed. - - - Synopsis: - (ret, internalShutter) = IsInternalMechanicalShutter() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Internal shutter state returned - DRV_NOT_AVAILABLE - Not an iXon Camera - DRV_P1INVALID - Parameter is NULL - internalShutter - Status of internal shutter: - 0 - Mechanical shutter not installed. - 1 - Mechanical shutter installed. - - C++ Equiv: - unsigned int IsInternalMechanicalShutter(int * internalShutter); - - Note: Available only on iXon - - ''' - cinternalShutter = c_int() - ret = self.dll.IsInternalMechanicalShutter(byref(cinternalShutter)) - return (ret, cinternalShutter.value) - - def IsPreAmpGainAvailable(self, channel, amplifier, index, pa): - ''' - Description: - This function checks that the AD channel exists, and that the amplifier, speed and gain are available for the AD channel. - - Synopsis: - (ret, status) = IsPreAmpGainAvailable(channel, amplifier, index, pa) - - Inputs: - channel - AD channel index. - amplifier - Type of output amplifier. - index - Channel speed index. - pa - PreAmpGain index. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - PreAmpGain status returned. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid channel. - DRV_P2INVALID - Invalid amplifier. - DRV_P3INVALID - Invalid speed index. - DRV_P4INVALID - Invalid gain. - status - PreAmpGain Status: - 0 - PreAmpGain not available. - 1 - PreAmpGain available. - - C++ Equiv: - unsigned int IsPreAmpGainAvailable(int channel, int amplifier, int index, int pa, int * status); - - See Also: - GetNumberPreAmpGains GetPreAmpGain SetPreAmpGain - - Note: Available only on iXon. - - ''' - cchannel = c_int(channel) - camplifier = c_int(amplifier) - cindex = c_int(index) - cpa = c_int(pa) - cstatus = c_int() - ret = self.dll.IsPreAmpGainAvailable(cchannel, camplifier, cindex, cpa, byref(cstatus)) - return (ret, cstatus.value) - - def IsTriggerModeAvailable(self, iTriggerMode): - ''' - Description: - This function checks if the hardware and current settings permit the use of the specified trigger mode. - - Synopsis: - ret = IsTriggerModeAvailable(iTriggerMode) - - Inputs: - iTriggerMode - Trigger mode to check. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode available - DRV_NOT_INITIALIZED - System not initialize - DRV_INVALID_MODE - Not a valid mode - - C++ Equiv: - unsigned int IsTriggerModeAvailable(int iTriggerMode); - - See Also: - SetTriggerMode - - ''' - ciTriggerMode = c_int(iTriggerMode) - ret = self.dll.IsTriggerModeAvailable(ciTriggerMode) - return (ret) - - def Merge(self, nOrder, nPoint, nPixel, fit, hbin): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr, coeff, output, start, step_Renamed) = Merge(nOrder, nPoint, nPixel, fit, hbin) - - Inputs: - nOrder - - nPoint - - nPixel - - fit - - hbin - - - Outputs: - ret - Function Return Code - arr - - coeff - - output - - start - - step_Renamed - - - C++ Equiv: - unsigned int Merge(const at_32 * arr, long nOrder, long nPoint, long nPixel, float * coeff, long fit, long hbin, at_32 * output, float * start, float * step_Renamed); - - ''' - carr = c_int() - cnOrder = c_int(nOrder) - cnPoint = c_int(nPoint) - cnPixel = c_int(nPixel) - ccoeff = c_float() - cfit = c_int(fit) - chbin = c_int(hbin) - coutput = c_int() - cstart = c_float() - cstep_Renamed = c_float() - ret = self.dll.Merge(byref(carr), cnOrder, cnPoint, cnPixel, byref(ccoeff), cfit, chbin, byref(coutput), byref(cstart), byref(cstep_Renamed)) - return (ret, carr.value, ccoeff.value, coutput.value, cstart.value, cstep_Renamed.value) - - def OA_AddMode(self, uiModeNameLen, pcModeDescription, uiModeDescriptionLen): - ''' - Description: - This function will add a mode name and description to memory. Note that this will not add the mode to file, a subsequent call to OA_WriteToFile must be made. - - Synopsis: - (ret, pcModeName) = OA_AddMode(uiModeNameLen, pcModeDescription, uiModeDescriptionLen) - - Inputs: - uiModeNameLen - Mode name string length. - pcModeDescription - A description of the user defined mode. - uiModeDescriptionLen - Mode Description string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_P1INVALID DRV_P3INVALID DRV_OA_INVALID_STRING_LENGTH - All parameters accepted Null mode name. Null mode description. One or more parameters have an invalid length, i.e. > 255. - DRV_OA_INVALID_NAMING - Mode and description have the same name, this is not valid. - DRV_OA_MODE_BUFFER_FULL DRV_OA_INVALID_CHARS_IN_NAME - Number of modes exceeds limit. Mode name and/or description contain invalid characters. - DRV_OA_MODE_ALREADY_EXISTS - Mode name already exists in the file. - DRV_OA_INVALID_CHARS_IN_NAME - Invalid charcters in Mode Name or Mode Description - pcModeName - A name for the mode to be defined. - - C++ Equiv: - unsigned int OA_AddMode(char * pcModeName, int uiModeNameLen, char * pcModeDescription, int uiModeDescriptionLen); - - See Also: - OA_DeleteMode OA_WriteToFile - - ''' - cpcModeName = create_string_buffer(uiModeNameLen) - cuiModeNameLen = c_int(uiModeNameLen) - cpcModeDescription = pcModeDescription - cuiModeDescriptionLen = c_int(uiModeDescriptionLen) - ret = self.dll.OA_AddMode(cpcModeName, cuiModeNameLen, cpcModeDescription, cuiModeDescriptionLen) - return (ret, cpcModeName) - - def OA_DeleteMode(self, pcModeName, uiModeNameLen): - ''' - Description: - This function will remove a mode from memory. To permanently remove a mode from file, call OA_WriteToFile after OA_DeleteMode. The Preset file will not be affected. - - Synopsis: - ret = OA_DeleteMode(pcModeName, uiModeNameLen) - - Inputs: - pcModeName - The name of the mode to be removed. - uiModeNameLen - Mode name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DRV_OA_MODE_DOES_NOT_EXIST - DRV_P1INVALID - All parameters accepted Null mode name. - DRV_OA_INVALID_STRING_LENGTH - The mode name parameter has an invalid length, i.e. > 256. - - C++ Equiv: - unsigned int OA_DeleteMode(const char * pcModeName, int uiModeNameLen); - - See Also: - OA_AddMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cuiModeNameLen = c_int(uiModeNameLen) - ret = self.dll.OA_DeleteMode(cpcModeName, cuiModeNameLen) - return (ret) - - def OA_EnableMode(self, pcModeName): - ''' - Description: - This function will set all the parameters associated with the specified mode to be used for all subsequent acquisitions. The mode specified by the user must be in either the Preset file or the User defined file. - - Synopsis: - ret = OA_EnableMode(pcModeName) - - Inputs: - pcModeName - The mode to be used for all subsequent acquisitions. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode name. - DRV_OA_MODE_DOES_NOT_EXIST - Mode name does not exist. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - - C++ Equiv: - unsigned int OA_EnableMode(const char * pcModeName); - - See Also: - OA_AddMode - - ''' - cpcModeName = pcModeName - ret = self.dll.OA_EnableMode(cpcModeName) - return (ret) - - def OA_GetFloat(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for floating point type acquisition parameters. - Values are retrieved from memory for the specified mode name. - - Synopsis: - (ret, fFloatValue) = OA_GetFloat(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted - DRV_P1INVALID - Null mode parameter. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null float value. - fFloatValue - The value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetFloat(const char * pcModeName, const char * pcModeParam, float * fFloatValue); - - See Also: - OA_SetFloat - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float() - ret = self.dll.OA_GetFloat(cpcModeName, cpcModeParam, byref(cfFloatValue)) - return (ret, cfFloatValue.value) - - def OA_GetInt(self, pcModeName, pcModeParam): - ''' - Description: - This function is used to get the values for integer type acquisition parameters. Values are retrieved from memory for the specified mode name. - - - Synopsis: - (ret, iintValue) = OA_GetInt(pcModeName, pcModeParam) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter - pcModeParam - The name of the acquisition parameter for which a value - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null integer value. - iintValue - The buffer to return the value of the acquisition. - - C++ Equiv: - unsigned int OA_GetInt(const char * pcModeName, const char * pcModeParam, int * iintValue); - - See Also: - OA_SetInt - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int() - ret = self.dll.OA_GetInt(cpcModeName, cpcModeParam, byref(ciintValue)) - return (ret, ciintValue.value) - - def OA_GetModeAcqParams(self, pcModeName): - ''' - Description: - This function will return all acquisition parameters associated with the specified mode. The mode specified by the user must be in either the Preset file or the User defined file. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfParams) = OA_GetModeAcqParams(pcModeName) - - Inputs: - pcModeName - The mode for which all acquisition parameters must be returned. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_NO_USER_DATA - No data for selected mode. - pcListOfParams - A user allocated array of characters for storage of the acquisition parameters. Parameters will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetModeAcqParams(const char * pcModeName, char * pcListOfParams); - - See Also: - OA_GetNumberOfAcqParams - - ''' - cpcModeName = pcModeName - cpcListOfParams = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetModeAcqParams(cpcModeName, cpcListOfParams) - return (ret, cpcListOfParams) - - def OA_GetNumberOfAcqParams(self, pcModeName): - ''' - Description: - This function will return the parameters associated with a specified mode. The mode must be present in either the Preset file or the User defined file. - - Synopsis: - (ret, puiNumberOfParams) = OA_GetNumberOfAcqParams(pcModeName) - - Inputs: - pcModeName - The mode to search for a list of acquisition parameters. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null number of parameters. - DRV_OA_NULL_ERROR - Invalid pointer. - puiNumberOfParams - The number of acquisition parameters for the specified mode. - - C++ Equiv: - unsigned int OA_GetNumberOfAcqParams(const char * pcModeName, unsigned int * puiNumberOfParams); - - See Also: - OA_GetModeAcqParams - - ''' - cpcModeName = pcModeName - cpuiNumberOfParams = c_uint() - ret = self.dll.OA_GetNumberOfAcqParams(cpcModeName, byref(cpuiNumberOfParams)) - return (ret, cpuiNumberOfParams.value) - - def OA_GetNumberOfPreSetModes(self): - ''' - Description: - This function will return the number of modes defined in the Preset file. The Preset file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfPreSetModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the Andor file. - - C++ Equiv: - unsigned int OA_GetNumberOfPreSetModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetPreSetModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfPreSetModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetNumberOfUserModes(self): - ''' - Description: - This function will return the number of modes defined in the User file. The user defined file must exist. - - Synopsis: - (ret, puiNumberOfModes) = OA_GetNumberOfUserModes() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null number of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - DRV_OA_BUFFER_FULL - Number of modes exceeds limit. - puiNumberOfModes - The number of modes in the user file. - - C++ Equiv: - unsigned int OA_GetNumberOfUserModes(unsigned int * puiNumberOfModes); - - See Also: - OA_GetUserModeNames - - ''' - cpuiNumberOfModes = c_uint() - ret = self.dll.OA_GetNumberOfUserModes(byref(cpuiNumberOfModes)) - return (ret, cpuiNumberOfModes.value) - - def OA_GetPreSetModeNames(self): - ''' - Description: - This function will return the available mode names from the Preset file. The mode and the Preset file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetPreSetModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetPreSetModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfPreSetModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetPreSetModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_GetString(self, pcModeName, pcModeParam, uiStringLen): - ''' - Description: - This function is used to get the values for string type acquisition parameters. Values - are retrieved from memory for the specified mode name. - - Synopsis: - (ret, pcStringValue) = OA_GetString(pcModeName, pcModeParam, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be retrieved. - pcModeParam - The name of the acquisition parameter for which a value will be retrieved. - uiStringLen - The length of the buffer. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - pcStringValue - The buffer to return the value of the acquisition parameter. - - C++ Equiv: - unsigned int OA_GetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_SetString - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = create_string_buffer(uiStringLen) - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_GetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret, cpcStringValue) - - def OA_GetUserModeNames(self): - ''' - Description: - This function will return the available mode names from a User defined file. The mode and the User defined file must exist. The user must allocate enough memory for all of the acquisition parameters. - - Synopsis: - (ret, pcListOfModes) = OA_GetUserModeNames() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null list of modes. - DRV_OA_NULL_ERROR - Invalid pointer. - pcListOfModes - A user allocated array of characters for storage of the mode names. Mode names will be delimited by a ','. - - C++ Equiv: - unsigned int OA_GetUserModeNames(char * pcListOfModes); - - See Also: - OA_GetNumberOfUserModes - - ''' - cpcListOfModes = create_string_buffer(MAX_PATH) - ret = self.dll.OA_GetUserModeNames(cpcListOfModes) - return (ret, cpcListOfModes) - - def OA_Initialize(self, pcFilename, uiFileNameLen): - ''' - Description: - This function will initialise the OptAcquire settings from a Preset file and a User defined file if it exists. - - Synopsis: - ret = OA_Initialize(pcFilename, uiFileNameLen) - - Inputs: - pcFilename - The name of a user xml file. If the file exists then data will be read from the file. If the file does not exist the file name may be used when the user calls WriteToFile(). - uiFileNameLen - The length of the filename. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename. - DRV_OA_CAMERA_NOT_SUPPORTED - Camera not supported. - DRV_OA_GET_CAMERA_ERROR - Unable to retrieve information about the - DRV_OA_INVALID_STRING_LENGTH - model of the Camera. - DRV_OA_ANDOR_FILE_NOT_LOADED - The parameter has an invalid length, i.e. > 255. - DRV_OA_USER_FILE_NOT_LOADED - Preset Andor file failed to load. - DRV_OA_FILE_ACCESS_ERROR - Supplied User file failed to load. - DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED - Failed to determine status of file. - - C++ Equiv: - unsigned int OA_Initialize(const char * pcFilename, int uiFileNameLen); - - See Also: - OA_WriteToFile - - ''' - cpcFilename = pcFilename - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_Initialize(cpcFilename, cuiFileNameLen) - return (ret) - - def OA_SetFloat(self, pcModeName, pcModeParam, fFloatValue): - ''' - Description: - This function is used to set values for floating point type acquisition parameters where - the new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetFloat(pcModeName, pcModeParam, fFloatValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - fFloatValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetFloat(const char * pcModeName, const char * pcModeParam, const float fFloatValue); - - See Also: - OA_GetFloat OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cfFloatValue = c_float(fFloatValue) - ret = self.dll.OA_SetFloat(cpcModeName, cpcModeParam, cfFloatValue) - return (ret) - - def OA_SetInt(self, pcModeName, pcModeParam, iintValue): - ''' - Description: - This function is used to set values for integer type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetInt(pcModeName, pcModeParam, iintValue) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter will be edited. - pcModeParam - The name of the acquisition parameter to be edited. - iintValue - The value to assign to the acquisition parameter. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetInt(const char * pcModeName, const char * pcModeParam, const int iintValue); - - See Also: - OA_GetInt OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - ciintValue = c_int(iintValue) - ret = self.dll.OA_SetInt(cpcModeName, cpcModeParam, ciintValue) - return (ret) - - def OA_SetString(self, pcModeName, pcModeParam, pcStringValue, uiStringLen): - ''' - Description: - This function is used to set values for string type acquisition parameters where the - new values are stored in memory. To commit changes to file call WriteToFile(). - - Synopsis: - ret = OA_SetString(pcModeName, pcModeParam, pcStringValue, uiStringLen) - - Inputs: - pcModeName - The name of the mode for which an acquisition parameter is to be edited. - pcModeParam - The name of the acquisition parameter to be edited. - pcStringValue - The value to assign to the acquisition parameter. - uiStringLen - The length of the input string. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null mode name. - DRV_P2INVALID - Null mode parameter. - DRV_P3INVALID - Null string value. - DRV_P4INVALID - Invalid string length - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_MODE_DOES_NOT_EXIST - The Mode does not exist. - - C++ Equiv: - unsigned int OA_SetString(const char * pcModeName, const char * pcModeParam, char * pcStringValue, const int uiStringLen); - - See Also: - OA_GetString OA_EnableMode OA_WriteToFile - - ''' - cpcModeName = pcModeName - cpcModeParam = pcModeParam - cpcStringValue = pcStringValue - cuiStringLen = c_int(uiStringLen) - ret = self.dll.OA_SetString(cpcModeName, cpcModeParam, cpcStringValue, cuiStringLen) - return (ret) - - def OA_WriteToFile(self, pcFileName, uiFileNameLen): - ''' - Description: - This function will write a User defined list of modes to the User file. The Preset file will not be affected. - - Synopsis: - ret = OA_WriteToFile(pcFileName, uiFileNameLen) - - Inputs: - pcFileName - The name of the file to be written to. - uiFileNameLen - File name string length. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_P1INVALID - Null filename - DRV_OA_INVALID_STRING_LENGTH - One or more of the string parameters has an invalid length, i.e. > 255. - DRV_OA_INVALID_FILE - Data cannot be written to the Preset Andor file. - DRV_ERROR_FILESAVE - Failed to save data to file. - DRV_OA_FILE_HAS_BEEN_MODIFIED - File to be written to has been modified since last write, local copy of file may not be the same. - DRV_OA_INVALID_CHARS_IN_NAME - File name contains invalid characters. - - C++ Equiv: - unsigned int OA_WriteToFile(const char * pcFileName, int uiFileNameLen); - - See Also: - OA_AddMode OA_DeleteMode - - ''' - cpcFileName = pcFileName - cuiFileNameLen = c_int(uiFileNameLen) - ret = self.dll.OA_WriteToFile(cpcFileName, cuiFileNameLen) - return (ret) - - def OutAuxPort(self, port, state): - ''' - Description: - This function sets the TTL Auxiliary Output port (P) on the Andor plug-in card to either ON/HIGH or OFF/LOW. - - Synopsis: - ret = OutAuxPort(port, state) - - Inputs: - port - Number of AUX out port on Andor card: - 1 - to 4 - state - state to put port in: - 0 - OFF/LOW - all - others ON/HIGH - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AUX port set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid port id. - - C++ Equiv: - unsigned int OutAuxPort(int port, int state); - - See Also: - InAuxPort - - ''' - cport = c_int(port) - cstate = c_int(state) - ret = self.dll.OutAuxPort(cport, cstate) - return (ret) - - def PostProcessCountConvert(self, iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to either Photons or Electrons based on the mode selected by the user. The input data should be in counts. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessCountConvert(iOutputBufferSize, iNumImages, iBaseline, iMode, iEmGain, fQE, fSensitivity, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The size of the output buffer.: - data - data - iNumImages - The number of images if a kinetic series is supplied as the input - iBaseline - The baseline associated with the image.: - 1 - - Convert to Electrons - 2 - - Convert to Photons - iMode - The mode to use to process the data. - iEmGain - The gain level of the input image. - fQE - The Quantum Efficiency of the sensor. - fSensitivity - The Sensitivity value used to acquire the image. - iHeight - The height of the image. - iWidth - The width of the image. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Number of images less than zero. - DRV_P5INVALID - Baseline less than zero. - DRV_P6INVALID - Invalid count convert mode. - DRV_P7INVALID - EMGain less than zero. - DRV_P8INVALID DRV_P9INVALID - QE less than zero. - DRV_P10INVALID - Sensitivity less than zero. - DRV_P11INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The output buffer to return the processed image. - - C++ Equiv: - unsigned int PostProcessCountConvert(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iBaseline, int iMode, int iEmGain, float fQE, float fSensitivity, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - ciEmGain = c_int(iEmGain) - cfQE = c_float(fQE) - cfSensitivity = c_float(fSensitivity) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessCountConvert(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciBaseline, ciMode, ciEmGain, cfQE, cfSensitivity, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessDataAveraging(self, iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessDataAveraging(iOutputBufferSize, iNumImages, iAveragingFilterMode, iHeight, iWidth, iFrameCount, iAveragingFactor) - - Inputs: - iOutputBufferSize - - iNumImages - - iAveragingFilterMode - - iHeight - - iWidth - - iFrameCount - - iAveragingFactor - - - Outputs: - ret - Function Return Code - pInputImage - - pOutputImage - - - C++ Equiv: - unsigned int PostProcessDataAveraging(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iAveragingFilterMode, int iHeight, int iWidth, int iFrameCount, int iAveragingFactor); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciAveragingFilterMode = c_int(iAveragingFilterMode) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ciFrameCount = c_int(iFrameCount) - ciAveragingFactor = c_int(iAveragingFactor) - ret = self.dll.PostProcessDataAveraging(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciAveragingFilterMode, ciHeight, ciWidth, ciFrameCount, ciAveragingFactor) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessNoiseFilter(self, iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth): - ''' - Description: - This function will apply a filter to the input image and return the processed image in the output buffer. The filter applied is chosen by the user by setting Mode to a permitted value. - - Synopsis: - (ret, pInputImage, pOutputImage) = PostProcessNoiseFilter(iOutputBufferSize, iBaseline, iMode, fThreshold, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The baseline associated with the image. - iBaseline - The mode to use to process the data.: - 1 - Use Median Filter. - 2 - Use Level Above Filter. - 3 - Use interquartile Range Filter. - 4 - Use Noise Threshold Filter. - iMode - This is the Threshold multiplier for the Median, interquartile: - and - Noise Threshold filters. For the Level Above filter this is - Threshold - count above the baseline. - fThreshold - The height of the image. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_SUPPORTED DRV_NOT_INITIALIZED - Camera does not support Noise filter processing. System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Baseline less than zero. - DRV_P5INVALID - Invalid Filter mode. - DRV_P6INVALID - Threshold value not valid for selected mode. - DRV_P7INVALID - Height less than zero. - DRV_P8INVALID DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - - C++ Equiv: - unsigned int PostProcessNoiseFilter(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iBaseline, int iMode, float fThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciBaseline = c_int(iBaseline) - ciMode = c_int(iMode) - cfThreshold = c_float(fThreshold) - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessNoiseFilter(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciBaseline, ciMode, cfThreshold, ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value) - - def PostProcessPhotonCounting(self, iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth): - ''' - Description: - This function will convert the input image data to photons and return the processed image in the output buffer. - - Synopsis: - (ret, pInputImage, pOutputImage, pfThreshold) = PostProcessPhotonCounting(iOutputBufferSize, iNumImages, iNumframes, iNumberOfThresholds, iHeight, iWidth) - - Inputs: - iOutputBufferSize - The number of images if a kinetic series is supplied as the input: - data - data - iNumImages - The number of frames per output image. - iNumframes - The number of thresholds provided by the user. - iNumberOfThresholds - The Thresholds used to define a photon. - iHeight - The width of the image. - iWidth - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS DRV_NOT_INITIALIZED - Acquisition prepared. - DRV_ACQUIRING - System not initialized. - DRV_P1INVALID - Acquisition in progress. - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Number of images less than zero. - DRV_P6INVALID - Invalid Number of Frames requested. - DRV_P7INVALID - Invalid number of thresholds. - DRV_P8INVALID - Invalid pointer (i.e. NULL). - DRV_P9INVALID - Height less than zero. - DRV_ERROR_BUFFSIZE - Width less than zero. - pInputImage - The input image data to be processed.: - at32 - * pOutputImage: The output buffer to return the processed image. - pOutputImage - The size of the output buffer. - pfThreshold - The height of the image. - - C++ Equiv: - unsigned int PostProcessPhotonCounting(at_32 * pInputImage, at_32 * pOutputImage, int iOutputBufferSize, int iNumImages, int iNumframes, int iNumberOfThresholds, float * pfThreshold, int iHeight, int iWidth); - - ''' - cpInputImage = c_int() - cpOutputImage = c_int() - ciOutputBufferSize = c_int(iOutputBufferSize) - ciNumImages = c_int(iNumImages) - ciNumframes = c_int(iNumframes) - ciNumberOfThresholds = c_int(iNumberOfThresholds) - cpfThreshold = c_float() - ciHeight = c_int(iHeight) - ciWidth = c_int(iWidth) - ret = self.dll.PostProcessPhotonCounting(byref(cpInputImage), byref(cpOutputImage), ciOutputBufferSize, ciNumImages, ciNumframes, ciNumberOfThresholds, byref(cpfThreshold), ciHeight, ciWidth) - return (ret, cpInputImage.value, cpOutputImage.value, cpfThreshold.value) - - def PrepareAcquisition(self): - ''' - Description: - This function reads the current acquisition setup and allocates and configures any memory that will be used during the acquisition. The function call is not required as it will be called automatically by the StartAcquisition function if it has not already been called externally. - However for long kinetic series acquisitions the time to allocate and configure any memory can be quite long which can result in a long delay between calling StartAcquisition and the acquisition actually commencing. For iDus, there is an additional delay caused by the camera being set-up with any new acquisition parameters. Calling PrepareAcquisition first will reduce this delay in the StartAcquisition call. - - Synopsis: - ret = PrepareAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition prepared. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_IOCERROR - integrate On Chip setup error. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int PrepareAcquisition(void); - - See Also: - StartAcquisition FreeInternalMemory - - ''' - ret = self.dll.PrepareAcquisition() - return (ret) - - def SaveAsBmp(self, path, palette, ymin, ymax): - ''' - Description: - This function saves the last acquisition as a bitmap file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the bitmap. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The ymin and ymax parameters indicate which data values will map to the first and last colors in the palette: - * All data values below or equal to ymin will be colored with the first color. - * All values above or equal to ymax will be colored with the last color - * All other palette colors will be scaled across values between these limits. - - Synopsis: - ret = SaveAsBmp(path, palette, ymin, ymax) - - Inputs: - path - The filename of the bitmap. - palette - The filename of a palette file (.PAL) for applying color to the bitmap. - ymin - Min data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - ymax - Max data value that palette will be scaled across. If ymin = 0 and ymax = 0 the palette will scale across the full range of values. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as bitmap. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsBmp(const char * path, const char * palette, long ymin, long ymax); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff - - Note: If the last acquisition was in Kinetic Series mode, each image will be saved in a separate Bitmap file. The filename specified will have an index number appended to it, indicating the position in the series. - - ''' - cpath = path - cpalette = palette - cymin = c_int(ymin) - cymax = c_int(ymax) - ret = self.dll.SaveAsBmp(cpath, cpalette, cymin, cymax) - return (ret) - - def SaveAsCommentedSif(self, path, comment): - ''' - Description: - This function will save the data from the last acquisition into a file. The comment text will be added to the user text portion of the Sif file. - - Synopsis: - ret = SaveAsCommentedSif(path, comment) - - Inputs: - path - pointer to a filename specified by the user. - comment - comment text to add to the sif file - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - - C++ Equiv: - unsigned int SaveAsCommentedSif(char * path, char * comment); - - See Also: - SetSifComment SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment - - Note: The comment used in SIF files created with this function is discarded once the call completes, i.e. future calls to SaveAsSif will not use this comment. To set a persistent comment use the SetSifComment function. - - ''' - cpath = path - ccomment = comment - ret = self.dll.SaveAsCommentedSif(cpath, ccomment) - return (ret) - - def SaveAsEDF(self, szPath, iMode): - ''' - Description: - This function saves the last acquisition in the European Synchotron Radiation Facility Data Format (*.edf). - - Synopsis: - ret = SaveAsEDF(szPath, iMode) - - Inputs: - szPath - the filename to save to. - iMode - option to save to multiple files.: - 0 - Save to 1 file - 1 - Save kinetic series to multiple files - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsEDF(char * szPath, int iMode); - - See Also: - SaveAsSif SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszPath = szPath - ciMode = c_int(iMode) - ret = self.dll.SaveAsEDF(cszPath, ciMode) - return (ret) - - def SaveAsFITS(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition in the FITS (Flexible Image Transport System) Data Format (*.fits) endorsed by NASA. - - Synopsis: - ret = SaveAsFITS(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 0 - Unsigned 16 - 1 - Unsigned 32 - 2 - Signed 16 - 3 - Signed 32 - 4 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsFITS(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsFITS(cszFileTitle, ctyp) - return (ret) - - def SaveAsRaw(self, szFileTitle, typ): - ''' - Description: - This function saves the last acquisition as a raw data file. - - Synopsis: - ret = SaveAsRaw(szFileTitle, typ) - - Inputs: - szFileTitle - the filename to save to. - typ - Data type: - 1 - Signed 16 - 2 - Signed 32 - 3 - Float - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid mode - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsRaw(char * szFileTitle, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cszFileTitle = szFileTitle - ctyp = c_int(typ) - ret = self.dll.SaveAsRaw(cszFileTitle, ctyp) - return (ret) - - def SaveAsSif(self, path): - ''' - Description: - This function will save the data from the last acquisition into a file, which can be read in by the main application. User text can be added to sif files using the SaveAsCommentedSif and SetSifComment functions. - - Synopsis: - ret = SaveAsSif(path) - - Inputs: - path - pointer to a filename specified by the user. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid filename. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSif(char * path); - - See Also: - SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp SetSifComment SaveAsCommentedSif - - ''' - cpath = path - ret = self.dll.SaveAsSif(cpath) - return (ret) - - def SaveAsSPC(self, path): - ''' - Description: - This function saves the last acquisition in the GRAMS .spc file format - - Synopsis: - ret = SaveAsSPC(path) - - Inputs: - path - the filename to save too. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsSPC(char * path); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsTiff SaveAsBmp - - ''' - cpath = path - ret = self.dll.SaveAsSPC(cpath) - return (ret) - - def SaveAsTiff(self, path, palette, position, typ): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. - The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively - - Synopsis: - ret = SaveAsTiff(path, palette, position, typ) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory. - - C++ Equiv: - unsigned int SaveAsTiff(char * path, char * palette, int position, int typ); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsBmp SaveAsTiffEx SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - ret = self.dll.SaveAsTiff(cpath, cpalette, cposition, ctyp) - return (ret) - - def SaveAsTiffEx(self, path, palette, position, typ, mode): - ''' - Description: - This function saves the last acquisition as a tiff file, which can be loaded into an imaging package. This is an extended version of the SaveAsTiff function. The palette parameter specifies the location of a .PAL file, which describes the colors to use in the tiff. This file consists of 256 lines of ASCII text; each line containing three numbers separated by spaces indicating the red, green and blue component of the respective color value. The parameter position can be changed to export different scans in a kinetic series. If the acquisition is any other mode, position should be set to 1. The parameter typ can be set to 0, 1 or 2 which correspond to 8-bit, 16-bit and color, respectively. The mode parameter specifies the mode of output. Data can be output scaled from the min and max count values across the entire range of values (mode 0) or can remain unchanged (mode 1).Of course if the count value is higher or lower than the output data range then even in mode 1 data will be scaled. - - Synopsis: - ret = SaveAsTiffEx(path, palette, position, typ, mode) - - Inputs: - path - The filename of the tiff. - palette - The filename of a palette file (.PAL) for applying color to the tiff. - position - The number in the series, should be 1 for a single scan. - typ - The type of tiff file to create. - mode - The output mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Data successfully saved as tiff - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Path invalid. - DRV_P2INVALID - Invalid palette file - DRV_P3INVALID - position out of range - DRV_P4INVALID - type not valid - DRV_P5INVALID - mode not valid - DRV_ERROR_PAGELOCK - File too large to be generated in memory - - C++ Equiv: - unsigned int SaveAsTiffEx(char * path, char * palette, int position, int typ, int mode); - - See Also: - SaveAsSif SaveAsEDF SaveAsFITS SaveAsRaw SaveAsSPC SaveAsTiff SaveAsBmp - - ''' - cpath = path - cpalette = palette - cposition = c_int(position) - ctyp = c_int(typ) - cmode = c_int(mode) - ret = self.dll.SaveAsTiffEx(cpath, cpalette, cposition, ctyp, cmode) - return (ret) - - def SaveEEPROMToFile(self, cFileName): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveEEPROMToFile(cFileName) - - Inputs: - cFileName - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveEEPROMToFile(char * cFileName); - - ''' - ccFileName = cFileName - ret = self.dll.SaveEEPROMToFile(ccFileName) - return (ret) - - def SaveToClipBoard(self, palette): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SaveToClipBoard(palette) - - Inputs: - palette - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SaveToClipBoard(char * palette); - - ''' - cpalette = palette - ret = self.dll.SaveToClipBoard(cpalette) - return (ret) - - def SelectDevice(self, devNum): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SelectDevice(devNum) - - Inputs: - devNum - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SelectDevice(int devNum); - - ''' - cdevNum = c_int(devNum) - ret = self.dll.SelectDevice(cdevNum) - return (ret) - - def SendSoftwareTrigger(self): - ''' - Description: - This function sends an event to the camera to take an acquisition when in Software Trigger mode. Not all cameras have this mode available to them. To check if your camera can operate in this mode check the GetCapabilities function for the Trigger Mode AC_TRIGGERMODE_CONTINUOUS. If this mode is physically possible and other settings are suitable (IsTriggerModeAvailable) and the camera is acquiring then this command will take an acquisition. - - Synopsis: - ret = SendSoftwareTrigger() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger sent - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - Not in SoftwareTrigger mode - DRV_IDLE - Not Acquiring - DRV_ERROR_CODES - Error communicating with camera - DRV_ERROR_ACK - Previous acquisition not complete - - C++ Equiv: - unsigned int SendSoftwareTrigger(void); - - See Also: - GetCapabilities IsTriggerModeAvailable SetAcquisitionMode SetReadMode SetTriggerMode - - Note: The settings of the camera must be as follows: - ReadOut mode is full image - RunMode is Run Till Abort - TriggerMode is 10 - - - - - ''' - ret = self.dll.SendSoftwareTrigger() - return (ret) - - def SetAccumulationCycleTime(self, time): - ''' - Description: - This function will set the accumulation cycle time to the nearest valid value not less than the given value. The actual cycle time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetAccumulationCycleTime(time) - - Inputs: - time - the accumulation cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure time invalid. - - C++ Equiv: - unsigned int SetAccumulationCycleTime(float time); - - See Also: - SetNumberAccumulations GetAcquisitionTimings - - ''' - ctime = c_float(time) - ret = self.dll.SetAccumulationCycleTime(ctime) - return (ret) - - def SetAcqStatusEvent(self, statusEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the camera has started exposing or that the camera has finished exposing. To determine what event has actually occurred call the GetCameraEventStatus funtion. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. The SetPCIMode function must be called to enable/disable the events from the driver. - - Synopsis: - ret = SetAcqStatusEvent(statusEvent) - - Inputs: - statusEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetAcqStatusEvent(at_32 statusEvent); - - See Also: - GetCameraEventStatus SetPCIMode - - Note: This is only available with the CCI23 PCI card. - - ''' - cstatusEvent = c_int(statusEvent) - ret = self.dll.SetAcqStatusEvent(cstatusEvent) - return (ret) - - def SetAcquisitionMode(self, mode): - ''' - Description: - This function will set the acquisition mode to be used on the next StartAcquisitionStartAcquisition. - - Synopsis: - ret = SetAcquisitionMode(mode) - - Inputs: - mode - the acquisition mode.: - 1 - Single Scan - 2 - Accumulate - 3 - Kinetics - 4 - Fast Kinetics - 5 - Run till abort - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid. - - C++ Equiv: - unsigned int SetAcquisitionMode(int mode); - - See Also: - StartAcquisition - - Note: In Mode 5 the system uses a Run Till Abort acquisition mode. In Mode 5 only, the camera continually acquires data until the AbortAcquisitionAbortAcquisition function is called. By using the SetDriverEventSetDriverEvent function you will be notified as each acquisition is completed. - - ''' - cmode = c_int(mode) - ret = self.dll.SetAcquisitionMode(cmode) - return (ret) - - def SetAcquisitionType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetAcquisitionType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetAcquisitionType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetAcquisitionType(ctyp) - return (ret) - - def SetADChannel(self, channel): - ''' - Description: - This function will set the AD channel to one of the possible A-Ds of the system. This AD channel will be used for all subsequent operations performed by the system. - - Synopsis: - ret = SetADChannel(channel) - - Inputs: - channel - the channel to be used 0 to GetNumberADChannelsGetNumberADChannels-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - AD channel set. - DRV_P1INVALID - Index is out of range. - - C++ Equiv: - unsigned int SetADChannel(int channel); - - See Also: - GetNumberADChannels - - ''' - cchannel = c_int(channel) - ret = self.dll.SetADChannel(cchannel) - return (ret) - - def SetAdvancedTriggerModeState(self, iState): - ''' - Description: - This function will set the state for the iCam functionality that some cameras are capable of. There may be some cases where we wish to prevent the software using the new functionality and just do it the way it was previously done. - - Synopsis: - ret = SetAdvancedTriggerModeState(iState) - - Inputs: - iState - 0: turn off iCam: - 1 - 1 Enable iCam. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set - DRV_NOT_INITIALIZED - System not initialized - DRV_P1INVALID - state invalid - - C++ Equiv: - unsigned int SetAdvancedTriggerModeState(int iState); - - See Also: - iCam - - Note: By default the advanced trigger functionality is enabled. - - ''' - ciState = c_int(iState) - ret = self.dll.SetAdvancedTriggerModeState(ciState) - return (ret) - - def SetBackground(self, size): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, arr) = SetBackground(size) - - Inputs: - size - - - Outputs: - ret - Function Return Code - arr - - - C++ Equiv: - unsigned int SetBackground(at_32 * arr, long size); - - ''' - carr = c_int() - csize = c_int(size) - ret = self.dll.SetBackground(byref(carr), csize) - return (ret, carr.value) - - def SetBaselineClamp(self, state): - ''' - Description: - This function turns on and off the baseline clamp functionality. With this feature enabled the baseline level of each scan in a kinetic series will be more consistent across the sequence. - - Synopsis: - ret = SetBaselineClamp(state) - - Inputs: - state - Enables/Disables Baseline clamp functionality: - 1 - Enable Baseline Clamp - 0 - Disable Baseline Clamp - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Baseline Clamp not supported on this camera - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetBaselineClamp(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetBaselineClamp(cstate) - return (ret) - - def SetBaselineOffset(self, offset): - ''' - Description: - This function allows the user to move the baseline level by the amount selected. For example +100 will add approximately 100 counts to the default baseline value. The value entered should be a multiple of 100 between -1000 and +1000 inclusively. - - Synopsis: - ret = SetBaselineOffset(offset) - - Inputs: - offset - Amount to offset baseline by - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Baseline Clamp not available for this camera - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Offset out of range - - C++ Equiv: - unsigned int SetBaselineOffset(int offset); - - Note: Only available on iXon range - - ''' - coffset = c_int(offset) - ret = self.dll.SetBaselineOffset(coffset) - return (ret) - - def SetCameraLinkMode(self, mode): - ''' - Description: - This function allows the user to enable or disable the Camera Link functionality for the camera. Enabling this functionality will start to stream all acquired data through the camera link interface. - - Synopsis: - ret = SetCameraLinkMode(mode) - - Inputs: - mode - Enables/Disables Camera Link mode: - 1 - Enable Camera Link - 0 - Disable Camera Link - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - Camera Link not supported by this Camera - DRV_P1INVALID - Mode was not zero or one. - - C++ Equiv: - unsigned int SetCameraLinkMode(int mode); - - Note: Only available with iXon Ultra. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCameraLinkMode(cmode) - return (ret) - - def SetCameraStatusEnable(self, Enable): - ''' - Description: - Use this function to Mask out certain types of acquisition status events. The default is to notify on every type of event but this may cause missed events if different types of event occur very close together. The bits in the mask correspond to the following event types: - Use0 - Fire pulse down event - Use1 - Fire pulse up event - Set the corresponding bit to 0 to disable the event type and 1 to enable the event type. - - Synopsis: - ret = SetCameraStatusEnable(Enable) - - Inputs: - Enable - bitmask with bits set for those events about which you wish to be notified. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mask Set. - DRV_VXDNOTINSTALLED - Device Driver not installed. - - C++ Equiv: - unsigned int SetCameraStatusEnable(DWORD Enable); - - See Also: - SetAcqStatusEvent SetPCIMode - - Note: Only available with PCI systems using the CCI-23 controller card. - - Fire pulse up event not available on USB systems. - - - ''' - cEnable = (Enable) - ret = self.dll.SetCameraStatusEnable(cEnable) - return (ret) - - def SetChargeShifting(self, NumberRows, NumberRepeats): - ''' - Description: - Use this function in External Charge Shifting trigger mode to configure how many rows to shift and how many times for each frame of data. The number of repeats must be a multiple of 2. - - Synopsis: - ret = SetChargeShifting(NumberRows, NumberRepeats) - - Inputs: - NumberRows - number of rows to shift after each external trigger - NumberRepeats - number of times to shift rows - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Trigger mode not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of rows invalid. - DRV_P2INVALID - Number of repeats invalid. - - C++ Equiv: - unsigned int SetChargeShifting(unsigned int NumberRows, unsigned int NumberRepeats); - - See Also: - SetTriggerMode GetCapabilities - - Note: Only available with certain iKon-M systems. - - ''' - cNumberRows = c_uint(NumberRows) - cNumberRepeats = c_uint(NumberRepeats) - ret = self.dll.SetChargeShifting(cNumberRows, cNumberRepeats) - return (ret) - - def SetComplexImage(self, numAreas): - ''' - Description: - This is a function that allows the setting up of random tracks with more options that the SetRandomTracks function. - The minimum number of tracks is 1. The maximum number of tracks is the number of vertical pixels. - There is a further limit to the number of tracks that can be set due to memory constraints in the camera. It is not a fixed number but depends upon the combinations of the tracks. For example, 20 tracks of different heights will take up more memory than 20 tracks of the same height. - If attempting to set a series of random tracks and the return code equals DRV_RANDOM_TRACK_ERROR, change the makeup of the tracks to have more repeating heights and gaps so less memory is needed. - Each track must be defined by a group of six integers. - -The top and bottom positions of the tracks. - -The left and right positions for the area of interest within each track - -The horizontal and vertical binning for each track. - The positions of the tracks are validated to ensure that the tracks are in increasing order. - The left and right positions for each track must be the same. - For iXon the range is between 8 and CCD width, inclusive - For idus the range must be between 257 and CCD width, inclusive. - Horizontal binning must be an integer between 1 and 64 inclusive, for iXon. - Horizontal binning is not implementated for iDus and must be set to 1. - Vertical binning is used in the following way. A track of: - 1 10 1 1024 1 2 - is actually implemented as 5 tracks of height 2. . Note that a vertical binning of 1 will have the effect of vertically binning the entire track; otherwise vertical binning will operate as normal. - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 - - Synopsis: - (ret, areas) = SetComplexImage(numAreas) - - Inputs: - numAreas - int * areas: - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_RANDOM_TRACK_ERROR - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_ERROR_FILELOAD - Serious internal error - areas - - - C++ Equiv: - unsigned int SetComplexImage(int numAreas, int * areas); - - See Also: - SetRandomTracks - - Note: Only available with iXon+ and USB cameras. - - ''' - cnumAreas = c_int(numAreas) - careas = c_int() - ret = self.dll.SetComplexImage(cnumAreas, byref(careas)) - return (ret, careas.value) - - def SetCoolerMode(self, mode): - ''' - Description: - This function determines whether the cooler is switched off when the camera is shut down. - - Synopsis: - ret = SetCoolerMode(mode) - - Inputs: - mode - : - 0 - Returns to ambient temperature on ShutDown - 1 - Temperature is maintained on ShutDown - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - DRV_NOT_SUPPORTED - Camera does not support - - C++ Equiv: - unsigned int SetCoolerMode(int mode); - - Note: Mode 0 not available on Luca R cameras always cooled to -20C. - - ''' - cmode = c_int(mode) - ret = self.dll.SetCoolerMode(cmode) - return (ret) - - def SetCountConvertMode(self, Mode): - ''' - Description: - This function configures the Count Convert mode. - - Synopsis: - ret = SetCountConvertMode(Mode) - - Inputs: - Mode - : - 0 - Data in Counts - 1 - Data in Electrons - 2 - Data in Photons - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - Count Convert not available for this camera - DRV_NOT_AVAILABLE - Count Convert mode not available with current settings - DRV_P1INVALID - Mode parameter was out of range. - - C++ Equiv: - unsigned int SetCountConvertMode(int Mode); - - See Also: - GetCapabilities SetCountConvertWavelength - - Note: Only available on Clara, iXon 3 and iXon Ultra. - - Modes 1 and 2 are only available when: - * Baseline Clamp active - * Isolated crop mode off - * EM gain must be greater than or equal to 10 and the lowest pre-amp not be selected - * For Clara systems the extended infra red mode can not be used - - - ''' - cMode = c_int(Mode) - ret = self.dll.SetCountConvertMode(cMode) - return (ret) - - def SetCountConvertWavelength(self, wavelength): - ''' - Description: - This function configures the wavelength used in Count Convert mode. - - Synopsis: - ret = SetCountConvertWavelength(wavelength) - - Inputs: - wavelength - wavelength used to determine QE - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Count Convert wavelength set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Count Convert not available for this camera - DRV_P1INVALID - Wavelength value was out of range. - - C++ Equiv: - unsigned int SetCountConvertWavelength(float wavelength); - - See Also: - GetCapabilities SetCountConvertMode - - ''' - cwavelength = c_float(wavelength) - ret = self.dll.SetCountConvertWavelength(cwavelength) - return (ret) - - def SetCropMode(self, active, cropHeight, reserved): - ''' - Description: - This function effectively reduces the height of the CCD by excluding some rows to achieve higher frame rates. This is currently only available on Newton cameras when the selected read mode is Full Vertical Binning. The cropHeight is the number of active rows measured from the bottom of the CCD. - Note: it is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetCropMode(active, cropHeight, reserved) - - Inputs: - active - Crop mode active: - 0 - Crop mode is OFF - 1 - Crop mode if ON - cropHeight - The selected crop height. This value must be between 1 and the CCD: - height - int reserved: This value should be set to 0. - reserved - This value should be set to 0 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIAILIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Active parameter is not zero or one. - DRV_P2INVALID - Cropheight parameter is less than one or greater than the CCD height. - DRV_P3INVALID - Reserved parameter is not equal to zero. - DRV_NOT_SUPPORTED - Either the camera is not a Newton or the read mode is not Full Vertical Binning. - - C++ Equiv: - unsigned int SetCropMode(int active, int cropHeight, int reserved); - - See Also: - GetDetector SetIsolatedCropMode - - Note: Available on Newton - - ''' - cactive = c_int(active) - ccropHeight = c_int(cropHeight) - creserved = c_int(reserved) - ret = self.dll.SetCropMode(cactive, ccropHeight, creserved) - return (ret) - - def SetCurrentCamera(self, cameraHandle): - ''' - Description: - When multiple Andor cameras are installed this function allows the user to select which camera is currently active. Once a camera has been selected the other functions can be called as normal but they will only apply to the selected camera. If only 1 camera is installed calling this function is not required since that camera will be selected by default. - - Synopsis: - ret = SetCurrentCamera(cameraHandle) - - Inputs: - cameraHandle - Selects the active camera - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Camera successfully selected. - DRV_P1INVALID - Invalid camera handle. - - C++ Equiv: - unsigned int SetCurrentCamera(long cameraHandle); - - See Also: - GetCurrentCamera GetAvailableCameras GetCameraHandle - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.SetCurrentCamera(ccameraHandle) - return (ret) - - def SetCustomTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning value to be used when the readout mode is set to Random Track. - - Synopsis: - ret = SetCustomTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetCustomTrackHBin(int bin); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cbin = c_int(bin) - ret = self.dll.SetCustomTrackHBin(cbin) - return (ret) - - def SetDACOutput(self, iOption, iResolution, iValue): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to set the required voltage. - - Synopsis: - ret = SetDACOutput(iOption, iResolution, iValue) - - Inputs: - iOption - DAC Output DAC Pin 1 or 2 (1/2). - iResolution - resolution of DAC can be set from 2 to 16-bit in steps of 2 - iValue - requested DAC value (for particular resolution) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available. - DRV_P1INVALID - DAC range value invalid. - DRV_P2INVALID - Resolution unavailable. - DRV_P3INVALID - Requested value not within DAC range. - - C++ Equiv: - unsigned int SetDACOutput(int iOption, int iResolution, int iValue); - - See Also: - SetDACOutputScale - - Note: Only available on Andor Clara - - ''' - ciOption = c_int(iOption) - ciResolution = c_int(iResolution) - ciValue = c_int(iValue) - ret = self.dll.SetDACOutput(ciOption, ciResolution, ciValue) - return (ret) - - def SetDACOutputScale(self, iScale): - ''' - Description: - Clara offers 2 configurable precision 16-bit DAC outputs. This function should be used to select the active one. - - Synopsis: - ret = SetDACOutputScale(iScale) - - Inputs: - iScale - 5 or 10 volt DAC range (1/2). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DAC Scale option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_AVAILABLE - Feature not available - DRV_P1INVALID - DAC Scale value invalid. - - C++ Equiv: - unsigned int SetDACOutputScale(int iScale); - - See Also: - SetDACOutput - - Note: Only available on Andor Clara - - ''' - ciScale = c_int(iScale) - ret = self.dll.SetDACOutputScale(ciScale) - return (ret) - - def SetDataType(self, typ): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDataType(typ) - - Inputs: - typ - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDataType(int typ); - - ''' - ctyp = c_int(typ) - ret = self.dll.SetDataType(ctyp) - return (ret) - - def SetDDGAddress(self, t0, t1, t2, t3, address): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGAddress(t0, t1, t2, t3, address) - - Inputs: - t0 - - t1 - - t2 - - t3 - - address - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGAddress(BYTE t0, BYTE t1, BYTE t2, BYTE t3, BYTE address); - - ''' - ct0 = c_ubyte(t0) - ct1 = c_ubyte(t1) - ct2 = c_ubyte(t2) - ct3 = c_ubyte(t3) - caddress = c_ubyte(address) - ret = self.dll.SetDDGAddress(ct0, ct1, ct2, ct3, caddress) - return (ret) - - def SetDDGExternalOutputEnabled(self, uiIndex, uiEnabled): - ''' - Description: - This function sets the state of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputPolarity(self, uiIndex, uiPolarity): - ''' - Description: - This function sets the polarity of a selected external output. - - Synopsis: - ret = SetDDGExternalOutputPolarity(uiIndex, uiPolarity) - - Inputs: - uiIndex - index of external output. - uiPolarity - polarity of external output (0 - Positive,1 - Negative). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Polarity set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputPolarity(at_u32 uiIndex, at_u32 uiPolarity); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputPolarity - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiPolarity = c_uint(uiPolarity) - ret = self.dll.SetDDGExternalOutputPolarity(cuiIndex, cuiPolarity) - return (ret) - - def SetDDGExternalOutputStepEnabled(self, uiIndex, uiEnabled): - ''' - Description: - Each external output has the option to track the gate step applied to the gater. This function can be used to set the state of this option. - - Synopsis: - ret = SetDDGExternalOutputStepEnabled(uiIndex, uiEnabled) - - Inputs: - uiIndex - index of external output. - uiEnabled - state of external output track step (0 - Off,1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid external output index. - - C++ Equiv: - unsigned int SetDDGExternalOutputStepEnabled(at_u32 uiIndex, at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputStepEnabled - - Note: Available on USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGExternalOutputStepEnabled(cuiIndex, cuiEnabled) - return (ret) - - def SetDDGExternalOutputTime(self, uiIndex, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the timings for a particular external output. - - Synopsis: - ret = SetDDGExternalOutputTime(uiIndex, uiDelay, uiWidth) - - Inputs: - uiIndex - index of external output. - uiDelay - external output delay time in picoseconds. - uiWidth - external output width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - External outputs not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with card. - DRV_P2INVALID - Invalid external output index. - DRV_P3INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGExternalOutputTime(at_u32 uiIndex, at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGExternalOutputEnabled GetDDGExternalOutputTime - - Note: Available in USB iStar. - - ''' - cuiIndex = c_uint(uiIndex) - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGExternalOutputTime(cuiIndex, cuiDelay, cuiWidth) - return (ret) - - def SetDDGGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetDDGGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetDDGGain(cgain) - return (ret) - - def SetDDGGateStep(self, step): - ''' - Description: - This function will set a constant value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGGateStep(step) - - Inputs: - step - gate step in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step invalid. - - C++ Equiv: - unsigned int SetDDGGateStep(double step); - - See Also: - SetDDGTimes SetDDGVariableGateStep - - Note: Available on iStar. - - ''' - cstep = c_double(step) - ret = self.dll.SetDDGGateStep(cstep) - return (ret) - - def SetDDGGateTime(self, uiDelay, uiWidth): - ''' - Description: - This function can be used to set the gate timings for a USB iStar. - - Synopsis: - ret = SetDDGGateTime(uiDelay, uiWidth) - - Inputs: - uiDelay - gate delay time in picoseconds. - uiWidth - gate width time in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Timings set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - USB iStar not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - DRV_P2INVALID - Invalid delay. - - C++ Equiv: - unsigned int SetDDGGateTime(at_u64 uiDelay, at_u64 uiWidth); - - See Also: - GetCapabilities GetDDGGateTime - - ''' - cuiDelay = c_ulonglong(uiDelay) - cuiWidth = c_ulonglong(uiWidth) - ret = self.dll.SetDDGGateTime(cuiDelay, cuiWidth) - return (ret) - - def SetDDGInsertionDelay(self, state): - ''' - Description: - This function controls the length of the insertion delay. - - Synopsis: - ret = SetDDGInsertionDelay(state) - - Inputs: - state - NORMAL/FAST switch for insertion delay.: - 0 - to set normal insertion delay. - 1 - to set fast insertion delay. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for delay accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGInsertionDelay(int state); - - See Also: - GetCapabilities SetDDGIntelligate - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGInsertionDelay(cstate) - return (ret) - - def SetDDGIntelligate(self, state): - ''' - Description: - This function controls the MCP gating. Not available when the fast insertion delay option is selected. - - Synopsis: - ret = SetDDGIntelligate(state) - - Inputs: - state - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - intelligate option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIntelligate(int state); - - See Also: - GetCapabilities SetDDGInsertionDelay - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIntelligate(cstate) - return (ret) - - def SetDDGIOC(self, state): - ''' - Description: - This function activates the integrate on chip (IOC) option. - - Synopsis: - ret = SetDDGIOC(state) - - Inputs: - state - ON/OFF switch for the IOC option.: - 0 - to switch IOC OFF. - 1 - to switch IOC ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGIOC(int state); - - See Also: - GetCapabilities SetDDGIOCFrequency GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses - - ''' - cstate = c_int(state) - ret = self.dll.SetDDGIOC(cstate) - return (ret) - - def SetDDGIOCFrequency(self, frequency): - ''' - Description: - This function sets the frequency of the integrate on chip option. It should be called once the conditions of the experiment have been setup in order for correct operation. The frequency should be limited to 5000Hz when intelligate is activated to prevent damage to the head and 50000Hz otherwise to prevent the gater from overheating. The recommended order is - ... - Experiment setup (exposure time, readout mode, gate parameters, ...) - ... - SetDDGIOCFrequency (x) - SetDDGIOCSetDDGIOC(true) - GetDDGIOCPulses(y) - StartAcquisitionStartAcquisition() - - Synopsis: - ret = SetDDGIOCFrequency(frequency) - - Inputs: - frequency - frequency of IOC option in Hz. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for frequency accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetDDGIOCFrequency(double frequency); - - See Also: - GetDDGIOCFrequency SetDDGIOCNumber GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cfrequency = c_double(frequency) - ret = self.dll.SetDDGIOCFrequency(cfrequency) - return (ret) - - def SetDDGIOCNumber(self, numberPulses): - ''' - Description: - This function allows the user to limit the number of pulses used in the integrate on chip option at a given frequency. It should be called once the conditions of the experiment have been setup in order for correct operation. - - Synopsis: - ret = SetDDGIOCNumber(numberPulses) - - Inputs: - numberPulses - the number of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for IOC number accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_NOT_SUPPORTED - IOC not supported - DRV_ERROR_ACK - Unable to communicate with card - - C++ Equiv: - unsigned int SetDDGIOCNumber(long numberPulses); - - See Also: - SetDDGIOCFrequency GetDDGIOCFrequency GetDDGIOCNumber GetDDGIOCPulses SetDDGIOC - - ''' - cnumberPulses = c_int(numberPulses) - ret = self.dll.SetDDGIOCNumber(cnumberPulses) - return (ret) - - def SetDDGIOCPeriod(self, period): - ''' - Description: - This function can be used to set the IOC period that will be triggered. It should only be called once all the conditions of the experiment have been defined. - - Synopsis: - ret = SetDDGIOCPeriod(period) - - Inputs: - period - the period of integrate on chip pulses triggered within the fire pulse. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC period set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid period. - - C++ Equiv: - unsigned int SetDDGIOCPeriod(at_u64 period); - - See Also: - GetCapabilities SetDDGIOC SetDDGIOCFrequency GetDDGIOCPeriod - - ''' - cperiod = c_ulonglong(period) - ret = self.dll.SetDDGIOCPeriod(cperiod) - return (ret) - - def SetDDGIOCTrigger(self, trigger): - ''' - Description: - This function can be used to select whether to trigger the IOC pulse train with either the rising edge of the fire pulse or an externally supplied trigger. - - Synopsis: - ret = SetDDGIOCTrigger(trigger) - - Inputs: - trigger - IOC Trigger Option: - 0 - Fire pulse - 1 - External Trigger - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IOC trigger set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - IOC not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid trigger. - - C++ Equiv: - unsigned int SetDDGIOCTrigger(at_u32 trigger); - - See Also: - GetCapabilities GetDDGIOCTrigger SetDDGIOC SetTriggerMode - - ''' - ctrigger = c_uint(trigger) - ret = self.dll.SetDDGIOCTrigger(ctrigger) - return (ret) - - def SetDDGLiteControlByte(self, channel, control): - ''' - Description: - THIS FUNCTION IS RESERVED - - Synopsis: - ret = SetDDGLiteControlByte(channel, control) - - Inputs: - channel - - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteControlByte(AT_DDGLiteChannelId channel, char control); - - ''' - cchannel = (channel) - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteControlByte(cchannel, ccontrol) - return (ret) - - def SetDDGLiteGlobalControlByte(self, control): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteGlobalControlByte(control) - - Inputs: - control - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteGlobalControlByte(char control); - - ''' - ccontrol = c_char(control) - ret = self.dll.SetDDGLiteGlobalControlByte(ccontrol) - return (ret) - - def SetDDGLiteInitialDelay(self, channel, fDelay): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLiteInitialDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInitialDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInitialDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLiteInterPulseDelay(self, channel, fDelay): - ''' - Description: - - - Synopsis: - ret = SetDDGLiteInterPulseDelay(channel, fDelay) - - Inputs: - channel - - fDelay - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLiteInterPulseDelay(AT_DDGLiteChannelId channel, float fDelay); - - ''' - cchannel = (channel) - cfDelay = c_float(fDelay) - ret = self.dll.SetDDGLiteInterPulseDelay(cchannel, cfDelay) - return (ret) - - def SetDDGLitePulsesPerExposure(self, channel, ui32Pulses): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulsesPerExposure(channel, ui32Pulses) - - Inputs: - channel - - ui32Pulses - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulsesPerExposure(AT_DDGLiteChannelId channel, at_u32 ui32Pulses); - - ''' - cchannel = (channel) - cui32Pulses = c_uint(ui32Pulses) - ret = self.dll.SetDDGLitePulsesPerExposure(cchannel, cui32Pulses) - return (ret) - - def SetDDGLitePulseWidth(self, channel, fWidth): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetDDGLitePulseWidth(channel, fWidth) - - Inputs: - channel - - fWidth - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetDDGLitePulseWidth(AT_DDGLiteChannelId channel, float fWidth); - - ''' - cchannel = (channel) - cfWidth = c_float(fWidth) - ret = self.dll.SetDDGLitePulseWidth(cchannel, cfWidth) - return (ret) - - def SetDDGOpticalWidthEnabled(self, uiEnabled): - ''' - Description: - This function can be used to configure a system to use optical gate width. - - Synopsis: - ret = SetDDGOpticalWidthEnabled(uiEnabled) - - Inputs: - uiEnabled - optical gate width option (0 - Off, 1 - On). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - State set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Optical gate width not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetDDGOpticalWidthEnabled(at_u32 uiEnabled); - - See Also: - GetCapabilities GetDDGTTLGateWidth GetDDGOpticalWidthEnabled - - ''' - cuiEnabled = c_uint(uiEnabled) - ret = self.dll.SetDDGOpticalWidthEnabled(cuiEnabled) - return (ret) - - def SetDDGStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - StartAcquisition SetDDGStepMode GetDDGStepMode GetDDGStepCoefficients - - Note: Available on iStar and USB iStar. - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGStepMode(self, mode): - ''' - Description: - This function will set the current gate step mode. - - Synopsis: - ret = SetDDGStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with system. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGStepMode(at_u32 mode); - - See Also: - StartAcquisition GetDDGStepMode SetDDGStepCoefficients GetDDGStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGStepMode(cmode) - return (ret) - - def SetDDGTimes(self, t0, t1, t2): - ''' - Description: - This function sets the properties of the gate pulse. t0 has a resolution of 16 nanoseconds whilst t1 and t2 have a resolution of 25 picoseconds. - - Synopsis: - ret = SetDDGTimes(t0, t1, t2) - - Inputs: - t0 - output A delay in nanoseconds. - t1 - gate delay in picoseconds. - t2 - pulse width in picoseconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Values for gate pulse accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Invalid output A delay. - DRV_P2INVALID - Invalid gate delay. - DRV_P3INVALID - Invalid pulse width. - - C++ Equiv: - unsigned int SetDDGTimes(double t0, double t1, double t2); - - See Also: - SetDDGGateStep - - Note: Available on iStar. - - ''' - ct0 = c_double(t0) - ct1 = c_double(t1) - ct2 = c_double(t2) - ret = self.dll.SetDDGTimes(ct0, ct1, ct2) - return (ret) - - def SetDDGTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode of the internal delay generator to either internal or External - - Synopsis: - ret = SetDDGTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetDDGTriggerMode(int mode); - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - ret = self.dll.SetDDGTriggerMode(cmode) - return (ret) - - def SetDDGVariableGateStep(self, mode, p1, p2): - ''' - Description: - This function will set a varying value for the gate step in a kinetic series. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds. - - Synopsis: - ret = SetDDGVariableGateStep(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 1 - Exponential (p1*exp(p2*n)) - 2 - Logarithmic (p1*log(p2*n)) - 3 - Linear (p1 + p2*n) - n - = 1, 2, ..., number in kinetic series - p1 - - p2 - - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGVariableGateStep(int mode, double p1, double p2); - - See Also: - StartAcquisition - - Note: Available on iStar. - - ''' - cmode = c_int(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGVariableGateStep(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepCoefficients(self, mode, p1, p2): - ''' - Description: - This function will configure the coefficients used in a kinetic series with gate width step active. The lowest available resolution is 25 picoseconds and the maximum permitted value is 25 seconds for a PCI iStar. - The lowest available resolution is 10 picoseconds and the maximum permitted value is 10 seconds for a USB iStar. - - Synopsis: - ret = SetDDGWidthStepCoefficients(mode, p1, p2) - - Inputs: - mode - the gate step mode.: - 0 - constant (p1*(n-1)). - 1 - exponential (p1*exp(p2*n)). - 2 - logarithmic (p1*log(p2*n)). - 3 - linear (p1 + p2*n). - - n = 1, 2, ..., number in kinetic series - p1 - The first coefficient - p2 - The second coefficient - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode coefficients set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Gate step mode invalid. - - C++ Equiv: - unsigned int SetDDGWidthStepCoefficients(at_u32 mode, double p1, double p2); - - See Also: - SetDDGWidthStepMode GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - cp1 = c_double(p1) - cp2 = c_double(p2) - ret = self.dll.SetDDGWidthStepCoefficients(cmode, cp1, cp2) - return (ret) - - def SetDDGWidthStepMode(self, mode): - ''' - Description: - This function will set the current gate width step mode. - - Synopsis: - ret = SetDDGWidthStepMode(mode) - - Inputs: - mode - the gate step mode.: - 0 - constant. - 1 - exponential. - 2 - logarithmic. - 3 - linear. - 100 - off. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gate step mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Gate step not supported. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid gate step mode. - - C++ Equiv: - unsigned int SetDDGWidthStepMode(at_u32 mode); - - See Also: - SetDDGWidthStepCoefficients GetDDGWidthStepMode GetDDGWidthStepCoefficients - - ''' - cmode = c_uint(mode) - ret = self.dll.SetDDGWidthStepMode(cmode) - return (ret) - - def SetDelayGenerator(self, board, address, typ): - ''' - Description: - This function sets parameters to control the delay generator through the GPIB card in your computer. - - Synopsis: - ret = SetDelayGenerator(board, address, typ) - - Inputs: - board - The GPIB board number of the card used to interface with the Delay Generator.: - short - address: The number that allows the GPIB board to identify and send commands to the delay generator. - address - The number that allows the GPIB board to identify and send commands to the delay generator. - - typ - The type of your Delay Generator. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Delay Generator set up. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - GPIB board invalid. - DRV_P2INVALID - GPIB address invalid - DRV_P3INVALID - Delay generator type invalid. - - C++ Equiv: - unsigned int SetDelayGenerator(int board, short address, int typ); - - See Also: - SetGate - - Note: Available on ICCD. - - ''' - cboard = c_int(board) - caddress = c_short(address) - ctyp = c_int(typ) - ret = self.dll.SetDelayGenerator(cboard, caddress, ctyp) - return (ret) - - def SetDMAParameters(self, MaxImagesPerDMA, SecondsPerDMA): - ''' - Description: - In order to facilitate high image readout rates the controller card may wait for multiple images to be acquired before notifying the SDK that new data is available. Without this facility, there is a chance that hardware interrupts may be lost as the operating system does not have enough time to respond to each interrupt. The drawback to this is that you will not get the data for an image until all images for that interrupt have been acquired. - There are 3 settings involved in determining how many images will be acquired for each notification (DMA interrupt) of the controller card and they are as follows: - 1. The size of the DMA buffer gives an upper limit on the number of images that can be stored within it and is usually set to the size of one full image when installing the software. This will usually mean that if you acquire full frames there will never be more than one image per DMA. - 2. A second setting that is used is the minimum amount of time (SecondsPerDMA) that should expire between interrupts. This can be used to give an indication of the reponsiveness of the operating system to interrupts. Decreasing this value will allow more interrupts per second and should only be done for faster pcs. The default value is 0.03s (30ms), finding the optimal value for your pc can only be done through experimentation. - 3. The third setting is an overide to the number of images calculated using the previous settings. If the number of images per dma is calculated to be greater than MaxImagesPerDMA then it will be reduced to MaxImagesPerDMA. This can be used to, for example, ensure that there is never more than 1 image per DMA by setting MaxImagesPerDMA to 1. Setting MaxImagesPerDMA to zero removes this limit. Care should be taken when modifying these parameters as missed interrupts may prevent the acquisition from completing. - - Synopsis: - ret = SetDMAParameters(MaxImagesPerDMA, SecondsPerDMA) - - Inputs: - MaxImagesPerDMA - Override to the number of images per DMA if the calculated value is higher than this. (Default=0, ie. no override) - SecondsPerDMA - Minimum amount of time to elapse between interrrupts. (Default=0.03s) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - DMA Parameters setup successfully. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - MaxImagesPerDMA invalid - DRV_P2INVALID - SecondsPerDMA invalid - - C++ Equiv: - unsigned int SetDMAParameters(int MaxImagesPerDMA, float SecondsPerDMA); - - ''' - cMaxImagesPerDMA = c_int(MaxImagesPerDMA) - cSecondsPerDMA = c_float(SecondsPerDMA) - ret = self.dll.SetDMAParameters(cMaxImagesPerDMA, cSecondsPerDMA) - return (ret) - - def SetDriverEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the SDK via which the the user software can be informed that something has occurred. For example the SDK can set the event when an acquisition has completed thus relieving the user code of having to continually pole to check on the status of the acquisition. - The event will be set under the follow conditions: - 1) Acquisition completed or aborted. - 2) As each scan during an acquisition is completed. - 3) Temperature as stabilized, drifted from stabilization or could not be reached. - When an event is triggered the user software can then use other SDK functions to determine what actually happened. - Condition 1 and 2 can be tested via GetStatusGetStatus function, while condition 3 checked via GetTemperatureGetTemperature function. - You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetDriverEvent with NULL as the parameter. - - Synopsis: - ret = SetDriverEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetDriverEvent(HANDLE driverEvent); - - See Also: - GetStatus GetTemperature GetAcquisitionProgress - - Note: Not all programming environments allow the use of multiple threads and WIN32 events. - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetDriverEvent(cdriverEvent) - return (ret) - - def SetDualExposureMode(self, mode): - ''' - Description: - This function turns on and off the option to acquire 2 frames for each external trigger pulse. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureMode(mode) - - Inputs: - mode - Enables/Disables dual exposure mode: - 1 - Enable mode - 0 - Disable mode - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode parameter was not zero or one. - - C++ Equiv: - unsigned int SetDualExposureMode(int mode); - - See Also: - GetCapabilities SetDualExposureTimes GetDualExposureTimes - - ''' - cmode = c_int(mode) - ret = self.dll.SetDualExposureMode(cmode) - return (ret) - - def SetDualExposureTimes(self, expTime1, expTime2): - ''' - Description: - This function configures the two exposure times used in dual exposure mode. This mode is only available for certain sensors in run till abort mode, external trigger, full image. - - Synopsis: - ret = SetDualExposureTimes(expTime1, expTime2) - - Inputs: - expTime1 - the exposure time in seconds for each odd numbered frame. - expTime2 - the exposure time in seconds for each even numbered frame. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Dual exposure mode not supported on this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - First exposure out of range. - DRV_P2INVALID - Second exposure out of range. - - C++ Equiv: - unsigned int SetDualExposureTimes(float expTime1, float expTime2); - - See Also: - GetCapabilities SetDualExposureMode GetDualExposureTimes - - ''' - cexpTime1 = c_float(expTime1) - cexpTime2 = c_float(expTime2) - ret = self.dll.SetDualExposureTimes(cexpTime1, cexpTime2) - return (ret) - - def SetEMAdvanced(self, state): - ''' - Description: - This function turns on and off access to higher EM gain levels within the SDK. Typically, optimal signal to noise ratio and dynamic range is achieved between x1 to x300 EM Gain. Higher gains of > x300 are recommended for single photon counting only. Before using higher levels, you should ensure that light levels do not exceed the regime of tens of photons per pixel, otherwise accelerated ageing of the sensor can occur. - - Synopsis: - ret = SetEMAdvanced(state) - - Inputs: - state - Enables/Disables access to higher EM gain levels: - 1 - Enable access - 1 - Disable access - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Advanced EM gain not available for this camera. - DRV_ACQUIRING. - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetEMAdvanced(int state); - - See Also: - GetCapabilities GetEMCCDGain SetEMCCDGain SetEMGainMode - - ''' - cstate = c_int(state) - ret = self.dll.SetEMAdvanced(cstate) - return (ret) - - def SetEMCCDGain(self, gain): - ''' - Description: - Allows the user to change the gain value. The valid range for the gain depends on what gain mode the camera is operating in. See SetEMGainMode to set the mode and GetEMGainRange to get the valid range to work with. To access higher gain values (>x300) see SetEMAdvanced. - - Synopsis: - ret = SetEMCCDGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetEMCCDGain(int gain); - - See Also: - GetEMCCDGain SetEMGainMode GetEMGainRange SetEMAdvanced - - Note: Only available on EMCCD sensor systems. - - ''' - cgain = c_int(gain) - ret = self.dll.SetEMCCDGain(cgain) - return (ret) - - def SetEMClockCompensation(self, EMClockCompensationFlag): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetEMClockCompensation(EMClockCompensationFlag) - - Inputs: - EMClockCompensationFlag - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetEMClockCompensation(int EMClockCompensationFlag); - - ''' - cEMClockCompensationFlag = c_int(EMClockCompensationFlag) - ret = self.dll.SetEMClockCompensation(cEMClockCompensationFlag) - return (ret) - - def SetEMGainMode(self, mode): - ''' - Description: - Set the EM Gain mode to one of the following possible settings. - Mode 0: The EM Gain is controlled by DAC settings in the range 0-255. Default mode. - 1: The EM Gain is controlled by DAC settings in the range 0-4095. - 2: Linear mode. - 3: Real EM gain - To access higher gain values (if available) it is necessary to enable advanced EM gain, see SetEMAdvanced. - - Synopsis: - ret = SetEMGainMode(mode) - - Inputs: - mode - EM Gain mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - EM Gain mode invalid. - - C++ Equiv: - unsigned int SetEMGainMode(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetEMGainMode(cmode) - return (ret) - - def SetExposureTime(self, time): - ''' - Description: - This function will set the exposure time to the nearest valid value not less than the given value. The actual exposure time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetExposureTime(time) - - Inputs: - time - the exposure time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Exposure time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Exposure Time invalid. - - C++ Equiv: - unsigned int SetExposureTime(float time); - - See Also: - GetAcquisitionTimings - - Note: For Classics, if the current acquisition mode is Single-Track, Multi-Track or Image then this function will actually set the Shutter Time. The actual exposure time used is obtained from the GetAcquisitionTimings functionGetAcquisitionTimings. - - ''' - ctime = c_float(time) - ret = self.dll.SetExposureTime(ctime) - return (ret) - - def SetExternalTriggerTermination(self, uiTermination): - ''' - Description: - This function can be used to set the external trigger termination mode. - - Synopsis: - ret = SetExternalTriggerTermination(uiTermination) - - Inputs: - uiTermination - trigger termination option.: - 0 - 50 ohm. - 1 - hi-Z. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Termination set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger termination not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetExternalTriggerTermination(at_u32 uiTermination); - - See Also: - GetCapabilities GetExternalTriggerTermination - - ''' - cuiTermination = c_uint(uiTermination) - ret = self.dll.SetExternalTriggerTermination(cuiTermination) - return (ret) - - def SetFanMode(self, mode): - ''' - Description: - Allows the user to control the mode of the camera fan. If the system is cooled, the fan should only be turned off for short periods of time. During this time the body of the camera will warm up which could compromise cooling capabilities. - If the camera body reaches too high a temperature, depends on camera, the buzzer will sound. If this happens, turn off the external power supply and allow the system to stabilize before continuing. - - Synopsis: - ret = SetFanMode(mode) - - Inputs: - mode - Fan mode setting: - 0 - Fan on full. - 1 - Fan on low. - 2 - Fan off, - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Mode value invalid. - - C++ Equiv: - unsigned int SetFanMode(int mode); - - See Also: - GetCapabilities - - ''' - cmode = c_int(mode) - ret = self.dll.SetFanMode(cmode) - return (ret) - - def SetFastExtTrigger(self, mode): - ''' - Description: - This function will enable fast external triggering. When fast external triggering is enabled the system will NOT wait until a Keep Clean cycle has been completed before accepting the next trigger. This setting will only have an effect if the trigger mode has been set to External via SetTriggerMode. - - Synopsis: - ret = SetFastExtTrigger(mode) - - Inputs: - mode - 0 Disabled: - 1 - Enabled - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters accepted. - - C++ Equiv: - unsigned int SetFastExtTrigger(int mode); - - See Also: - SetTriggerMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFastExtTrigger(cmode) - return (ret) - - def SetFastKinetics(self, exposedRows, seriesLength, time, mode, hbin, vbin): - ''' - Description: - This function will set the parameters to be used when taking a fast kinetics acquisition. - - Synopsis: - ret = SetFastKinetics(exposedRows, seriesLength, time, mode, hbin, vbin) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System not initialized. - DRV_NOT_INITIALIZED - Acquisition in progress. - DRV_ACQUIRING - Invalid height. - DRV_P1INVALID - Invalid number in series. - DRV_P2INVALID DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID DRV_P5INVALID - Mode must be equal to 0 or 4. - DRV_P6INVALID - Horizontal binning. - All parameters accepted. - Vertical binning. - - C++ Equiv: - unsigned int SetFastKinetics(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin); - - See Also: - SetFKVShiftSpeed SetFastKineticsEx SetFKVShiftSpeed - - Note: For classic cameras the vertical and horizontal binning must be 1 - For non classic cameras it is recommended that you use SetFastKineticsEx - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFastKinetics(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin) - return (ret) - - def SetFastKineticsEx(self, exposedRows, seriesLength, time, mode, hbin, vbin, offset): - ''' - Description: - This function is the same as SetFastKinetics with the addition of an Offset parameter, which will inform the SDK of the first row to be used. - - Synopsis: - ret = SetFastKineticsEx(exposedRows, seriesLength, time, mode, hbin, vbin, offset) - - Inputs: - exposedRows - sub-area height in rows. - seriesLength - number in series. - time - exposure time in seconds. - mode - binning mode (0 - FVB , 4 - Image). - hbin - horizontal binning. - vbin - vertical binning (only used when in image mode). - offset - offset of first row to be used in Fast Kinetics from the bottom of the CCD. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid height. - DRV_P2INVALID - Invalid number in series. - DRV_P3INVALID - Exposure time must be greater than 0. - DRV_P4INVALID - Mode must be equal to 0 or 4. - DRV_P5INVALID - Horizontal binning. - DRV_P6INVALID - Vertical binning. - DRV_P7INVALID - Offset not within CCD limits - - C++ Equiv: - unsigned int SetFastKineticsEx(int exposedRows, int seriesLength, float time, int mode, int hbin, int vbin, int offset); - - See Also: - SetFKVShiftSpeed SetFastKinetics SetFKVShiftSpeed - - Note: For classic cameras the offset must be 0 and the vertical and horizontal binning must be 1 - For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cexposedRows = c_int(exposedRows) - cseriesLength = c_int(seriesLength) - ctime = c_float(time) - cmode = c_int(mode) - chbin = c_int(hbin) - cvbin = c_int(vbin) - coffset = c_int(offset) - ret = self.dll.SetFastKineticsEx(cexposedRows, cseriesLength, ctime, cmode, chbin, cvbin, coffset) - return (ret) - - def SetFilterMode(self, mode): - ''' - Description: - This function will set the state of the cosmic ray filter mode for future acquisitions. If the filter mode is on, consecutive scans in an accumulation will be compared and any cosmic ray-like features that are only present in one scan will be replaced with a scaled version of the corresponding pixel value in the correct scan. - - Synopsis: - ret = SetFilterMode(mode) - - Inputs: - mode - current state of filter: - 0 - OFF - 2 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Filter mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is out off range. - - C++ Equiv: - unsigned int SetFilterMode(int mode); - - See Also: - GetFilterMode - - ''' - cmode = c_int(mode) - ret = self.dll.SetFilterMode(cmode) - return (ret) - - def SetFilterParameters(self, width, sensitivity, range, accept, smooth, noise): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFilterParameters(width, sensitivity, range, accept, smooth, noise) - - Inputs: - width - - sensitivity - - range - - accept - - smooth - - noise - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFilterParameters(int width, float sensitivity, int range, float accept, int smooth, int noise); - - ''' - cwidth = c_int(width) - csensitivity = c_float(sensitivity) - crange = c_int(range) - caccept = c_float(accept) - csmooth = c_int(smooth) - cnoise = c_int(noise) - ret = self.dll.SetFilterParameters(cwidth, csensitivity, crange, caccept, csmooth, cnoise) - return (ret) - - def SetFKVShiftSpeed(self, index): - ''' - Description: - This function will set the fast kinetics vertical shift speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetFKVShiftSpeed(index) - - Inputs: - index - the speed to be used: - 0 - to GetNumberFKVShiftSpeedsGetNumberFKVShiftSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Fast kinetics vertical shift speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetFKVShiftSpeed(int index); - - See Also: - GetNumberFKVShiftSpeeds GetFKVShiftSpeedF - - Note: Only available if camera is Classic or iStar. - - ''' - cindex = c_int(index) - ret = self.dll.SetFKVShiftSpeed(cindex) - return (ret) - - def SetFPDP(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetFPDP(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetFPDP(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetFPDP(cstate) - return (ret) - - def SetFrameTransferMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Frame Transfer Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetFrameTransferMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Frame transfer mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetFrameTransferMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is a Frame Transfer chip. - - ''' - cmode = c_int(mode) - ret = self.dll.SetFrameTransferMode(cmode) - return (ret) - - def SetFrontEndEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the Front End cooler has overheated or returned to a normal state. To determine what event has actually occurred call the GetFrontEndStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetFrontEndEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetFrontEndEvent(at_32 driverEvent); - - See Also: - GetFrontEndStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetFrontEndEvent(cdriverEvent) - return (ret) - - def SetFullImage(self, hbin, vbin): - ''' - Description: - Deprecated see Note: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetFullImage(hbin, vbin) - - Inputs: - hbin - number of pixels to bin horizontally - vbin - number of pixels to bin vertically - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning parameters accepted - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - Horizontal binning parameter invalid - DRV_P2INVALID - Vertical binning parameter invalid - - C++ Equiv: - unsigned int SetFullImage(int hbin, int vbin); // deprecated - - See Also: - SetReadMode - - Note: Deprecated by SetImageGetNumberHSSpeeds - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - ret = self.dll.SetFullImage(chbin, cvbin) - return (ret) - - def SetFVBHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Full Vertical Binned read mode. - - Synopsis: - ret = SetFVBHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetFVBHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetFVBHBin(cbin) - return (ret) - - def SetGain(self, gain): - ''' - Description: - Deprecated for SetMCPGain. - - Synopsis: - ret = SetGain(gain) - - Inputs: - gain - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetGain(int gain); // deprecated - - ''' - cgain = c_int(gain) - ret = self.dll.SetGain(cgain) - return (ret) - - def SetGate(self, delay, width, stepRenamed): - ''' - Description: - This function sets the Gater parameters for an ICCD system. The image intensifier of the Andor ICCD acts as a shutter on nanosecond time-scales using a process known as gating. - - Synopsis: - ret = SetGate(delay, width, stepRenamed) - - Inputs: - delay - Sets the delay(>=0) between the T0 and C outputs on the SRS box to delay nanoseconds. - width - Sets the width(>=0) of the gate in nanoseconds - stepRenamed - Sets the amount(<>0, in nanoseconds) by which the gate position is moved in time after each scan in a kinetic series. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gater parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_ACQUIRING - Acquisition in progress. - DRV_GPIBERROR - Error communicating with GPIB card. - DRV_P1INVALID - Invalid delay - DRV_P2INVALID - Invalid width. - DRV_P3INVALID - Invalid step. - - C++ Equiv: - unsigned int SetGate(float delay, float width, float stepRenamed); - - See Also: - SetDelayGenerator - - Note: Available on ICCD. - - ''' - cdelay = c_float(delay) - cwidth = c_float(width) - cstepRenamed = c_float(stepRenamed) - ret = self.dll.SetGate(cdelay, cwidth, cstepRenamed) - return (ret) - - def SetGateMode(self, gatemode): - ''' - Description: - Allows the user to control the photocathode gating mode. - - Synopsis: - ret = SetGateMode(gatemode) - - Inputs: - gatemode - the gate mode.: - 0 - Fire ANDed with the Gate input. - 1 - Gating controlled from Fire pulse only. - 2 - Gating controlled from SMB Gate input only. - 3 - Gating ON continuously. - 4 - Gating OFF continuously. - 5 - Gate using DDG - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Gating mode accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Gating mode invalid. - - C++ Equiv: - unsigned int SetGateMode(int gatemode); - - See Also: - GetCapabilities SetMCPGain SetMCPGating - - ''' - cgatemode = c_int(gatemode) - ret = self.dll.SetGateMode(cgatemode) - return (ret) - - def SetHighCapacity(self, state): - ''' - Description: - This function switches between high sensitivity and high capacity functionality. With high capacity enabled the output amplifier is switched to a mode of operation which reduces the responsivity thus allowing the reading of larger charge packets during binning operations. - - Synopsis: - ret = SetHighCapacity(state) - - Inputs: - state - Enables/Disables High Capacity functionality: - 1 - Enable High Capacity (Disable High Sensitivity) - 0 - Disable High Capacity (Enable High Sensitivity) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - State parameter was not zero or one. - - C++ Equiv: - unsigned int SetHighCapacity(int state); - - See Also: - GetCapabilities - - ''' - cstate = c_int(state) - ret = self.dll.SetHighCapacity(cstate) - return (ret) - - def SetHorizontalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the horizontal speed to one of the possible speeds of the system. It will be used for subsequent acquisitions. - - Synopsis: - ret = SetHorizontalSpeed(index) - - Inputs: - index - the horizontal speed to be used: - 0 - to GetNumberHorizontalSpeedsGetNumberHorizontalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHorizontalSpeed(int index); // deprecated - - See Also: - GetNumberHorizontalSpeeds GetHorizontalSpeed - - Note: Deprecated by SetHSSpeedGetNumberHSSpeeds - - ''' - cindex = c_int(index) - ret = self.dll.SetHorizontalSpeed(cindex) - return (ret) - - def SetHSSpeed(self, typ, index): - ''' - Description: - This function will set the speed at which the pixels are shifted into the output node during the readout phase of an acquisition. Typically your camera will be capable of operating at several horizontal shift speeds. To get the actual speed that an index corresponds to use the GetHSSpeed function. Ensure the desired A/D channel has been set with SetADChannel before calling SetHSSpeed. - - Synopsis: - ret = SetHSSpeed(typ, index) - - Inputs: - typ - output amplification.: - 0 - electron multiplication/Conventional(clara). - 1 - conventional/Extended NIR mode(clara). - index - the horizontal speed to be used: - 0 - to GetNumberHSSpeeds()GetNumberHSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Horizontal speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Mode is invalid. - DRV_P2INVALID - Index is out off range. - - C++ Equiv: - unsigned int SetHSSpeed(int typ, int index); - - See Also: - GetNumberHSSpeeds GetHSSpeed GetNumberAmp - - ''' - ctyp = c_int(typ) - cindex = c_int(index) - ret = self.dll.SetHSSpeed(ctyp, cindex) - return (ret) - - def SetImage(self, hbin, vbin, hstart, hend, vstart, vend): - ''' - Description: - This function will set the horizontal and vertical binning to be used when taking a full resolution image. - - Synopsis: - ret = SetImage(hbin, vbin, hstart, hend, vstart, vend) - - Inputs: - hbin - number of pixels to bin horizontally. - vbin - number of pixels to bin vertically. - hstart - Start column (inclusive). - hend - End column (inclusive). - vstart - Start row (inclusive). - vend - End row (inclusive). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Binning parameters invalid. - DRV_P2INVALID - Binning parameters invalid. - DRV_P3INVALID - Sub-area co-ordinate is invalid. - DRV_P4INVALID - Sub-area co-ordinate is invalid. - DRV_P5INVALID - Sub-area co-ordinate is invalid. - DRV_P6INVALID - Sub-area co-ordinate is invalid. - - C++ Equiv: - unsigned int SetImage(int hbin, int vbin, int hstart, int hend, int vstart, int vend); - - See Also: - SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - chbin = c_int(hbin) - cvbin = c_int(vbin) - chstart = c_int(hstart) - chend = c_int(hend) - cvstart = c_int(vstart) - cvend = c_int(vend) - ret = self.dll.SetImage(chbin, cvbin, chstart, chend, cvstart, cvend) - return (ret) - - def SetImageFlip(self, iHFlip, iVFlip): - ''' - Description: - This function will cause data output from the SDK to be flipped on one or both axes. This flip is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If flipping could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageFlip(iHFlip, iVFlip) - - Inputs: - iHFlip - Sets horizontal flipping. - iVFlip - Sets vertical flipping..: - 1 - Enables Flipping - 0 - Disables Flipping - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - HFlip parameter invalid. - DRV_P2INVALID - VFlip parameter invalid - - C++ Equiv: - unsigned int SetImageFlip(int iHFlip, int iVFlip); - - See Also: - SetImageRotate - - Note: If this function is used in conjunction with the SetImageRotate function the rotation will occur before the flip regardless of which order the functions are called. - - ''' - ciHFlip = c_int(iHFlip) - ciVFlip = c_int(iVFlip) - ret = self.dll.SetImageFlip(ciHFlip, ciVFlip) - return (ret) - - def SetImageRotate(self, iRotate): - ''' - Description: - This function will cause data output from the SDK to be rotated on one or both axes. This rotate is not done in the camera, it occurs after the data is retrieved and will increase processing overhead. If the rotation could be implemented by the user more efficiently then use of this function is not recomended. E.g writing to file or displaying on screen. - - Synopsis: - ret = SetImageRotate(iRotate) - - Inputs: - iRotate - Rotation setting: - 0 - No rotation. - 1 - Rotate 90 degrees clockwise. - 2 - Rotate 90 degrees anti-clockwise. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - All parameters accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_P1INVALID - Rotate parameter invalid. - - C++ Equiv: - unsigned int SetImageRotate(int iRotate); - - See Also: - SetImageFlip - - Note: If this function is used in conjunction with the SetImageFlip function the rotation will occur before the flip regardless of which order the functions are called. 180 degree rotation can be achieved using the SetImageFlip function by selecting both horizontal and vertical flipping. - - ''' - ciRotate = c_int(iRotate) - ret = self.dll.SetImageRotate(ciRotate) - return (ret) - - def SetIODirection(self, index, iDirection): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIODirection(index, iDirection) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iDirection - requested direction for this index.: - 0 - 0 Output - 1 - 1 Input - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO direction set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid direction. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIODirection(int index, int iDirection); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIOLevel - - ''' - cindex = c_int(index) - ciDirection = c_int(iDirection) - ret = self.dll.SetIODirection(cindex, ciDirection) - return (ret) - - def SetIOLevel(self, index, iLevel): - ''' - Description: - Available in some systems are a number of IOs that can be configured to be inputs or outputs. This function sets the current state of a particular IO. - - Synopsis: - ret = SetIOLevel(index, iLevel) - - Inputs: - index - IO index: - 0 - to GetNumberIO() - 1 - iLevel - current level for this index.: - 0 - 0 Low - 1 - 1 High - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - IO level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid index. - DRV_P2INVALID - Invalid level. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetIOLevel(int index, int iLevel); - - See Also: - GetNumberIO GetIOLevel GetIODirection SetIODirection - - ''' - cindex = c_int(index) - ciLevel = c_int(iLevel) - ret = self.dll.SetIOLevel(cindex, ciLevel) - return (ret) - - def SetIsolatedCropMode(self, active, cropheight, cropwidth, vbin, hbin): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. In isolated crop mode iXon, Newton and iKon cameras can operate in either Full Vertical Binning or Imaging read modes. iDus can operate in Full Vertical Binning read mode only. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - - Synopsis: - ret = SetIsolatedCropMode(active, cropheight, cropwidth, vbin, hbin) - - Inputs: - active - Crop mode active: - 1 - Crop mode is ON. - Crop - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - The selected vertical binning. - hbin - The selected horizontal binning. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_NOT_SUPPORTED - Either the camera does not support isolated Crop mode or the read mode is invalid - - C++ Equiv: - unsigned int SetIsolatedCropMode(int active, int cropheight, int cropwidth, int vbin, int hbin); - - See Also: - GetDetector SetReadMode - - Note: For iDus, it is recommended that you set horizontal binning to 1 - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ret = self.dll.SetIsolatedCropMode(cactive, ccropheight, ccropwidth, cvbin, chbin) - return (ret) - - def SetIsolatedCropModeEx(self, active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom): - ''' - Description: - This function effectively reduces the dimensions of the CCD by excluding some rows or columns to achieve higher throughput. This feature is currently only available for iXon Ultra and can only be used in Image readout mode with the EM output amplifier. - Note: It is important to ensure that no light falls on the excluded region otherwise the acquired data will be corrupted. - The following centralized regions of interest are recommended to be used with this mode to achieve the fastest possible frame rates. The table below shows the optimally positioned ROI coordinates recommended to be used with this mode: - ROI - Crop Left Start Position - Crop Right Position - Crop Bottom Start Position - Crop Top Position - 32 x 32 - 241 - 272 - 240 - 271 - 64 x 64 - 219 - 282 - 224 - 287 - 96 x 96 - 209 - 304 - 208 - 303 - 128 x 128 - 189 - 316 - 192 - 319 - 192 x 192 - 157 - 348 - 160 - 351 - 256 x 256 - 123 - 378 - 128 - 383 - 496 x 4 - 8 - 503 - 254 - 257 - 496 x 8 - 8 - 503 - 252 - 259 - 496 x 16 - 8 - 503 - 249 - 262 - - Synopsis: - ret = SetIsolatedCropModeEx(active, cropheight, cropwidth, vbin, hbin, cropleft, cropbottom) - - Inputs: - active - Crop mode active.: - 1 - Crop mode is ON. - 0 - Crop mode is OFF. - cropheight - The selected crop height. This value must be between 1 and the CCD height. - cropwidth - The selected crop width. This value must be between 1 and the CCD width. - vbin - vbinThe selected vertical binning. - hbin - hbinThe selected horizontal binning. - cropleft - The selected crop left start position - cropbottom - The selected crop bottom start position - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_P1INVALID - active parameter was not zero or one - DRV_P2INVALID - Invalid crop height - DRV_P3INVALID - Invalid crop width - DRV_P4INVALID - Invalid vertical binning - DRV_P5INVALID - Invalid horizontal binning - DRV_P6INVALID - Invalid crop left start position - DRV_P7INVALID - Invalid crop bottom start position - DRV_NOT_SUPPORTED - The camera does not support isolated crop mode - DRV_NOT_AVAILABLE - Invalid read mode - - C++ Equiv: - unsigned int SetIsolatedCropModeEx(int active, int cropheight, int cropwidth, int vbin, int hbin, int cropleft, int cropbottom); - - See Also: - GetDetector SetReadMode - - ''' - cactive = c_int(active) - ccropheight = c_int(cropheight) - ccropwidth = c_int(cropwidth) - cvbin = c_int(vbin) - chbin = c_int(hbin) - ccropleft = c_int(cropleft) - ccropbottom = c_int(cropbottom) - ret = self.dll.SetIsolatedCropModeEx(cactive, ccropheight, ccropwidth, cvbin, chbin, ccropleft, ccropbottom) - return (ret) - - def SetKineticCycleTime(self, time): - ''' - Description: - This function will set the kinetic cycle time to the nearest valid value not less than the given value. The actual time used is obtained by GetAcquisitionTimingsGetAcquisitionTimings. . Please refer to SECTION 5 - ACQUISITION MODES for further information. - - Synopsis: - ret = SetKineticCycleTime(time) - - Inputs: - time - the kinetic cycle time in seconds. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Cycle time accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Time invalid. - - C++ Equiv: - unsigned int SetKineticCycleTime(float time); - - See Also: - SetNumberKinetics - - ''' - ctime = c_float(time) - ret = self.dll.SetKineticCycleTime(ctime) - return (ret) - - def SetMCPGain(self, gain): - ''' - Description: - Allows the user to control the voltage across the microchannel plate. Increasing the gain increases the voltage and so amplifies the signal. The gain range can be returned using GetMCPGainRange. - - Synopsis: - ret = SetMCPGain(gain) - - Inputs: - gain - amount of gain applied. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gain accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with device. - DRV_P1INVALID - Gain value invalid. - - C++ Equiv: - unsigned int SetMCPGain(int gain); - - See Also: - GetMCPGainRange SetGateMode SetMCPGating - - Note: Available on iStar. - - ''' - cgain = c_int(gain) - ret = self.dll.SetMCPGain(cgain) - return (ret) - - def SetMCPGating(self, gating): - ''' - Description: - This function controls the MCP gating. - - Synopsis: - ret = SetMCPGating(gating) - - Inputs: - gating - ON/OFF switch for the MCP gating.: - 0 - to switch MCP gating OFF. - 1 - to switch MCP gating ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Value for gating accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_I2CTIMEOUT - I2C command timed out. - DRV_I2CDEVNOTFOUND - I2C device not present. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Value for gating invalid. - - C++ Equiv: - unsigned int SetMCPGating(int gating); - - See Also: - SetMCPGain SetGateMode - - Note: Available on some ICCD models. - - ''' - cgating = c_int(gating) - ret = self.dll.SetMCPGating(cgating) - return (ret) - - def SetMessageWindow(self, wnd): - ''' - Description: - This function is reserved. - - Synopsis: - ret = SetMessageWindow(wnd) - - Inputs: - wnd - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMessageWindow(at_32 wnd); - - ''' - cwnd = c_int(wnd) - ret = self.dll.SetMessageWindow(cwnd) - return (ret) - - def SetMetaData(self, state): - ''' - Description: - This function activates the meta data option. - - Synopsis: - ret = SetMetaData(state) - - Inputs: - state - ON/OFF switch for the meta data option.: - 0 - to switch meta data OFF. - 1 - to switch meta data ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Meta data option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid state. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetMetaData(int state); - - See Also: - GetMetaDataInfo - - ''' - cstate = c_int(state) - ret = self.dll.SetMetaData(cstate) - return (ret) - - def SetMultiTrack(self, number, height, offset): - ''' - Description: - This function will set the multi-Track parameters. The tracks are automatically spread evenly over the detector. Validation of the parameters is carried out in the following order: - * Number of tracks, - * Track height - * Offset. - The first pixels row of the first track is returned via bottom. - The number of rows between each track is returned via gap. - - Synopsis: - (ret, bottom, gap) = SetMultiTrack(number, height, offset) - - Inputs: - number - number tracks (1 to number of vertical pixels) - height - height of each track (>0 (maximum depends on number of tracks)) - offset - vertical displacement of tracks. (depends on number of tracks and track height) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track height invalid. - DRV_P3INVALID - Offset invalid. - bottom - first pixels row of the first track - gap - number of rows between each track (could be 0) - - C++ Equiv: - unsigned int SetMultiTrack(int number, int height, int offset, int * bottom, int * gap); - - See Also: - SetReadMode StartAcquisition SetRandomTracks - - ''' - cnumber = c_int(number) - cheight = c_int(height) - coffset = c_int(offset) - cbottom = c_int() - cgap = c_int() - ret = self.dll.SetMultiTrack(cnumber, cheight, coffset, byref(cbottom), byref(cgap)) - return (ret, cbottom.value, cgap.value) - - def SetMultiTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Multi-Track read mode. - - Synopsis: - ret = SetMultiTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetMultiTrackHBin(int bin); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - Note: 1) If the multitrack range is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetMultiTrackHBin(cbin) - return (ret) - - def SetMultiTrackHRange(self, iStart, iEnd): - ''' - Description: - This function sets the horizontal range used when acquiring in Multi Track read mode. - - Synopsis: - ret = SetMultiTrackHRange(iStart, iEnd) - - Inputs: - iStart - First horizontal pixel in multi track mode. - iEnd - iEndLast horizontal pixel in multi track mode. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Range set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Feature not available for this camera. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid start position. - DRV_P2INVALID - Invalid end position. - - C++ Equiv: - unsigned int SetMultiTrackHRange(int iStart, int iEnd); - - See Also: - SetReadMode SetMultiTrack SetReadMode - - ''' - ciStart = c_int(iStart) - ciEnd = c_int(iEnd) - ret = self.dll.SetMultiTrackHRange(ciStart, ciEnd) - return (ret) - - def SetMultiTrackScan(self, trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetMultiTrackScan(trackHeight, numberTracks, iSIHStart, iSIHEnd, trackHBinning, trackVBinning, trackGap, trackOffset, trackSkip, numberSubFrames) - - Inputs: - trackHeight - - numberTracks - - iSIHStart - - iSIHEnd - - trackHBinning - - trackVBinning - - trackGap - - trackOffset - - trackSkip - - numberSubFrames - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetMultiTrackScan(int trackHeight, int numberTracks, int iSIHStart, int iSIHEnd, int trackHBinning, int trackVBinning, int trackGap, int trackOffset, int trackSkip, int numberSubFrames); - - ''' - ctrackHeight = c_int(trackHeight) - cnumberTracks = c_int(numberTracks) - ciSIHStart = c_int(iSIHStart) - ciSIHEnd = c_int(iSIHEnd) - ctrackHBinning = c_int(trackHBinning) - ctrackVBinning = c_int(trackVBinning) - ctrackGap = c_int(trackGap) - ctrackOffset = c_int(trackOffset) - ctrackSkip = c_int(trackSkip) - cnumberSubFrames = c_int(numberSubFrames) - ret = self.dll.SetMultiTrackScan(ctrackHeight, cnumberTracks, ciSIHStart, ciSIHEnd, ctrackHBinning, ctrackVBinning, ctrackGap, ctrackOffset, ctrackSkip, cnumberSubFrames) - return (ret) - - def SetNextAddress(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNextAddress16(self, lowAdd, highAdd, length, physical): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - (ret, data) = SetNextAddress16(lowAdd, highAdd, length, physical) - - Inputs: - lowAdd - - highAdd - - length - - physical - - - Outputs: - ret - Function Return Code - data - - - C++ Equiv: - unsigned int SetNextAddress16(at_32 * data, long lowAdd, long highAdd, long length, long physical); - - ''' - cdata = c_int() - clowAdd = c_int(lowAdd) - chighAdd = c_int(highAdd) - clength = c_int(length) - cphysical = c_int(physical) - ret = self.dll.SetNextAddress16(byref(cdata), clowAdd, chighAdd, clength, cphysical) - return (ret, cdata.value) - - def SetNumberAccumulations(self, number): - ''' - Description: - This function will set the number of scans accumulated in memory. This will only take effect if the acquisition mode is either Accumulate or Kinetic Series. - - Synopsis: - ret = SetNumberAccumulations(number) - - Inputs: - number - number of scans to accumulate - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Accumulations set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of accumulates. - - C++ Equiv: - unsigned int SetNumberAccumulations(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberKinetics - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberAccumulations(cnumber) - return (ret) - - def SetNumberKinetics(self, number): - ''' - Description: - This function will set the number of scans (possibly accumulated scans) to be taken during a single acquisition sequence. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberKinetics(number) - - Inputs: - number - number of scans to store - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number in series invalid. - - C++ Equiv: - unsigned int SetNumberKinetics(int number); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime - - ''' - cnumber = c_int(number) - ret = self.dll.SetNumberKinetics(cnumber) - return (ret) - - def SetNumberPrescans(self, iNumber): - ''' - Description: - This function will set the number of scans acquired before data is to be retrieved. This will only take effect if the acquisition mode is Kinetic Series. - - Synopsis: - ret = SetNumberPrescans(iNumber) - - Inputs: - iNumber - number of scans to ignore - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Prescans set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of prescans invalid. - - C++ Equiv: - unsigned int SetNumberPrescans(int iNumber); - - See Also: - GetAcquisitionTimings SetAcquisitionMode SetKineticCycleTime SetNumberKinetics - - ''' - ciNumber = c_int(iNumber) - ret = self.dll.SetNumberPrescans(ciNumber) - return (ret) - - def SetOutputAmplifier(self, typ): - ''' - Description: - Some EMCCD systems have the capability to use a second output amplifier. This function will set the type of output amplifier to be used when reading data from the head for these systems. - - Synopsis: - ret = SetOutputAmplifier(typ) - - Inputs: - typ - the type of output amplifier.: - 0 - Standard EMCCD gain register (default)/Conventional(clara). - 1 - Conventional CCD register/Extended NIR mode(clara). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Series length set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Output amplifier type invalid. - - C++ Equiv: - unsigned int SetOutputAmplifier(int typ); - - Note: 1. Available in Clara, iXon & Newton. - 2. If the current camera HSSpeed is not available when the amplifier is set then it will default to the maximum HSSpeed that is. - - - ''' - ctyp = c_int(typ) - ret = self.dll.SetOutputAmplifier(ctyp) - return (ret) - - def SetOverlapMode(self, mode): - ''' - Description: - This function will set whether an acquisition will readout in Overlap Mode. If the acquisition mode is Single Scan or Fast Kinetics this call will have no affect. - - Synopsis: - ret = SetOverlapMode(mode) - - Inputs: - mode - mode: - 0 - OFF - 1 - ON - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Overlap mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid parameter. - - C++ Equiv: - unsigned int SetOverlapMode(int mode); - - See Also: - SetAcquisitionMode - - Note: Only available if CCD is an Overlap sensor. - - ''' - cmode = c_int(mode) - ret = self.dll.SetOverlapMode(cmode) - return (ret) - - def SetPCIMode(self, mode, value): - ''' - Description: - With the CCI23 card, events can be sent when the camera is starting to expose and when it has finished exposing. This function will control whether those events happen or not. - - Synopsis: - ret = SetPCIMode(mode, value) - - Inputs: - mode - currently must be set to 1 - value - 0 to disable the events, 1 to enable - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Acquisition Mode invalid - - C++ Equiv: - unsigned int SetPCIMode(int mode, int value); - - See Also: - SetAcqStatusEvent SetCameraStatusEnable - - Note: This is only supported by the CCI23 card. The software must register its event via the SetAcqStatusEvent. To specify which event the software is interested in use the SetCameraStatusEnable. - - ''' - cmode = c_int(mode) - cvalue = c_int(value) - ret = self.dll.SetPCIMode(cmode, cvalue) - return (ret) - - def SetPhosphorEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the phosphor has saturated or returned to a normal state. To determine what event has actually occurred call the GetPhosphorStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetPhosphorEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetPhosphorEvent(at_32 driverEvent); - - See Also: - GetPhosphorStatus - - ''' - cdriverEvent = c_int(driverEvent) - ret = self.dll.SetPhosphorEvent(cdriverEvent) - return (ret) - - def SetPhotonCounting(self, state): - ''' - Description: - This function activates the photon counting option. - - Synopsis: - ret = SetPhotonCounting(state) - - Inputs: - state - ON/OFF switch for the photon counting option.: - 0 - to switch photon counting OFF. - 1 - to switch photon counting ON. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - photon counting option accepted. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCounting(int state); - - See Also: - SetPhotonCountingThreshold - - ''' - cstate = c_int(state) - ret = self.dll.SetPhotonCounting(cstate) - return (ret) - - def SetPhotonCountingDivisions(self, noOfDivisions): - ''' - Description: - This function sets the thresholds for the photon counting option. - - Synopsis: - (ret, divisions) = SetPhotonCountingDivisions(noOfDivisions) - - Inputs: - noOfDivisions - number of thresholds to be used. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Number of thresholds outside valid range - DRV_P2INVALID - Thresholds outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Feature not supported. - divisions - threshold levels. - - C++ Equiv: - unsigned int SetPhotonCountingDivisions(at_u32 noOfDivisions, at_32 * divisions); - - See Also: - SetPhotonCounting GetNumberPhotonCountingDivisions - - ''' - cnoOfDivisions = c_uint(noOfDivisions) - cdivisions = c_int() - ret = self.dll.SetPhotonCountingDivisions(cnoOfDivisions, byref(cdivisions)) - return (ret, cdivisions.value) - - def SetPhotonCountingThreshold(self, min, max): - ''' - Description: - This function sets the minimum and maximum threshold for the photon counting option. - - Synopsis: - ret = SetPhotonCountingThreshold(min, max) - - Inputs: - min - minimum threshold in counts for photon counting. - max - maximum threshold in counts for photon counting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thresholds accepted. - DRV_P1INVALID - Minimum threshold outside valid range (1-65535) - DRV_P2INVALID - Maximum threshold outside valid range - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - - C++ Equiv: - unsigned int SetPhotonCountingThreshold(long min, long max); - - See Also: - SetPhotonCounting - - ''' - cmin = c_int(min) - cmax = c_int(max) - ret = self.dll.SetPhotonCountingThreshold(cmin, cmax) - return (ret) - - def SetPixelMode(self, bitdepth, colormode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetPixelMode(bitdepth, colormode) - - Inputs: - bitdepth - - colormode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetPixelMode(int bitdepth, int colormode); - - ''' - cbitdepth = c_int(bitdepth) - ccolormode = c_int(colormode) - ret = self.dll.SetPixelMode(cbitdepth, ccolormode) - return (ret) - - def SetPreAmpGain(self, index): - ''' - Description: - This function will set the pre amp gain to be used for subsequent acquisitions. The actual gain factor that will be applied can be found through a call to the GetPreAmpGain function. - The number of Pre Amp Gains available is found by calling the GetNumberPreAmpGains function. - - Synopsis: - ret = SetPreAmpGain(index) - - Inputs: - index - index pre amp gain table: - 0 - to GetNumberPreAmpGainsGetNumberPreAmpGains-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Pre amp gain set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetPreAmpGain(int index); - - See Also: - IsPreAmpGainAvailable GetNumberPreAmpGains GetPreAmpGain - - Note: Available on iDus, iXon & Newton. - - ''' - cindex = c_int(index) - ret = self.dll.SetPreAmpGain(cindex) - return (ret) - - def SetRandomTracks(self, numTracks): - ''' - Description: - This function will set the Random-Track parameters. The positions of the tracks are validated to ensure that the tracks are in increasing order and do not overlap. The horizontal binning is set via the SetCustomTrackHBin function. The vertical binning is set to the height of each track. - Some cameras need to have at least 1 row in between specified tracks. Ixon+ and the USB cameras allow tracks with no gaps in between. - Example: - Tracks specified as 20 30 31 40 tells the SDK that the first track starts at row 20 in the CCD and finishes at row 30. The next track starts at row 31 (no gap between tracks) and ends at row 40. - - Synopsis: - (ret, areas) = SetRandomTracks(numTracks) - - Inputs: - numTracks - number tracks: - 1 - to number of vertical pixels/2 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Number of tracks invalid. - DRV_P2INVALID - Track positions invalid. - DRV_RANDOM_TRACK_ERROR - Invalid combination of tracks, out of memory or mode not available. - areas - pointer to an array of track positions. The array has the form: - bottom1 - bottom1 top1, bottom2, top2 ... bottomN, topN - - C++ Equiv: - unsigned int SetRandomTracks(int numTracks, int * areas); - - See Also: - SetCustomTrackHBin SetReadMode StartAcquisition SetComplexImage - - ''' - cnumTracks = c_int(numTracks) - careas = c_int() - ret = self.dll.SetRandomTracks(cnumTracks, byref(careas)) - return (ret, careas.value) - - def SetReadMode(self, mode): - ''' - Description: - This function will set the readout mode to be used on the subsequent acquisitions. - - Synopsis: - ret = SetReadMode(mode) - - Inputs: - mode - readout mode: - 0 - Full Vertical Binning - 1 - Multi-Track - 2 - Random-Track - 3 - Single-Track - 4 - Image - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadMode(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadMode(cmode) - return (ret) - - def SetReadoutRegisterPacking(self, mode): - ''' - Description: - This function will configure whether data is packed into the readout register to improve frame rates for sub-images. - Note: It is important to ensure that no light falls outside of the sub-image area otherwise the acquired data will be corrupted. Only currently available on iXon+ and iXon3. - - Synopsis: - ret = SetReadoutRegisterPacking(mode) - - Inputs: - mode - register readout mode: - 0 - Packing Off - 1 - Packing On - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Readout mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid readout mode passed. - - C++ Equiv: - unsigned int SetReadoutRegisterPacking(int mode); - - See Also: - GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetKineticCycleTime SetNumberAccumulations SetNumberKinetics - - ''' - cmode = c_int(mode) - ret = self.dll.SetReadoutRegisterPacking(cmode) - return (ret) - - def SetRegisterDump(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetRegisterDump(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetRegisterDump(int mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetRegisterDump(cmode) - return (ret) - - def SetRingExposureTimes(self, numTimes): - ''' - Description: - This function will send up an array of exposure times to the camera if the hardware supports the feature. See GetCapabilities. Each acquisition will then use the next exposure in the ring looping round to the start again when the end is reached. There can be a maximum of 16 exposures. - - Synopsis: - (ret, times) = SetRingExposureTimes(numTimes) - - Inputs: - numTimes - The number of exposures - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_NOTAVAILABLE - DRV_SUCCESS - Success - DRV_NOT_INITIALIZED - System not initialized - DRV_INVALID_MODE - This mode is not available. - DRV_P1INVALID - Must be between 1 and 16 exposures inclusive - DRV_P2INVALID - The exposures times are invalid. - times - A predeclared pointer to an array of numTimes floats - - C++ Equiv: - unsigned int SetRingExposureTimes(int numTimes, float * times); - - See Also: - GetCapabilities GetNumberRingExposureTimes GetAdjustedRingExposureTimes GetRingExposureRange IsTriggerModeAvailable - - ''' - cnumTimes = c_int(numTimes) - ctimes = c_float() - ret = self.dll.SetRingExposureTimes(cnumTimes, byref(ctimes)) - return (ret, ctimes.value) - - def SetSaturationEvent(self, saturationEvent): - ''' - Description: - This is only supported with the CCI-23 PCI card. USB cameras do not have this feature. - This function passes a Win32 Event handle to the driver via which the driver can inform the main software that an acquisition has saturated the sensor to a potentially damaging level. You must reset the event after it has been handled in order to receive additional triggers. Before deleting the event you must call SetEvent with NULL as the parameter. - - Synopsis: - ret = SetSaturationEvent(saturationEvent) - - Inputs: - saturationEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED - Function not supported for operating system - - C++ Equiv: - unsigned int SetSaturationEvent(HANDLE saturationEvent); - - See Also: - SetDriverEvent - - Note: The programmer must reset the event after it has been handled in order to receive additional triggers, unless the event has been created with auto-reset, e.g. event = CreateEvent(NULL, FALSE, FALSE, NULL). Also, NOT all programming environments allow the use of multiple threads and Win32 events. - Only supported with the CCI-23 card. - USB cameras do not have this feature. - - - - ''' - csaturationEvent = c_void_p(saturationEvent) - ret = self.dll.SetSaturationEvent(csaturationEvent) - return (ret) - - def SetShutter(self, typ, mode, closingtime, openingtime): - ''' - Description: - This function controls the behaviour of the shutter. - The typ parameter allows the user to control the TTL signal output to an external shutter. The mode parameter configures whether the shutter opens & closes automatically (controlled by the camera) or is permanently open or permanently closed. - The opening and closing time specify the time required to open and close the shutter (this information is required for calculating acquisition timings (see SHUTTER TRANSFER TIME). - - Synopsis: - ret = SetShutter(typ, mode, closingtime, openingtime) - - Inputs: - typ - shutter type: - 1 - Output TTL high signal to open shutter - 0 - Output TTL low signal to open shutter - mode - Shutter mode: - 0 - Automatic - 1 - Open - 2 - Close - closingtime - Time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED DRV_ACQUIRING - System not initialized. - DRV_ERROR_ACK - Acquisition in progress. - DRV_NOT_SUPPORTED - Unable to communicate with card. - DRV_P1INVALID - Camera does not support shutter control. - DRV_P2INVALID - Invalid TTL type. - DRV_P3INVALID - Invalid mode. - DRV_P4INVALID - Invalid time to open. - - C++ Equiv: - unsigned int SetShutter(int typ, int mode, int closingtime, int openingtime); - - See Also: - SetShutterEx - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - ret = self.dll.SetShutter(ctyp, cmode, cclosingtime, copeningtime) - return (ret) - - def SetShutterEx(self, typ, mode, closingtime, openingtime, extmode): - ''' - Description: - This function expands the control offered by SetShutter to allow an external shutter and internal shutter to be controlled independently (only available on some cameras - please consult your Camera User Guide). The typ parameter allows the user to control the TTL signal output to an external shutter. The opening and closing times specify the length of time required to open and close the shutter (this information is required for calculating acquisition timings - see SHUTTER TRANSFER TIME). - The mode and extmode parameters control the behaviour of the internal and external shutters. To have an external shutter open and close automatically in an experiment, set the mode parameter to Open and set the extmode parameter to Auto. To have an internal shutter open and close automatically in an experiment, set the extmode parameter to Open and set the mode parameter to Auto. - To not use any shutter in the experiment, set both shutter modes to permanently open. - - Synopsis: - ret = SetShutterEx(typ, mode, closingtime, openingtime, extmode) - - Inputs: - typ - Shutter type: - 0 - Output TTL low signal to open shutter - 1 - Output TTL high signal to open shutter - mode - Internal shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - closingtime - time shutter takes to close (milliseconds) - openingtime - Time shutter takes to open (milliseconds) - extmode - External shutter mode.: - 0 - Auto - 1 - Open - 2 - Close - - Outputs: - ret - Function Return Code: - Unsigned int - DRV_P5INVALID - DRV_SUCCESS - Shutter set. - DRV_NOT_INITIALIZED - System not initialized - DRV_ACQUIRING - Acquisition in progress - DRV_ERROR_ACK - Unable to communicate with card. - DRV_NOT_SUPPORTED - Camera does not support shutter control. - DRV_P1INVALID - Invalid TTL type. - DRV_P2INVALID - Invalid internal mode - DRV_P3INVALID - Invalid time to open. - DRV_P4INVALID - Invalid time to close - - C++ Equiv: - unsigned int SetShutterEx(int typ, int mode, int closingtime, int openingtime, int extmode); - - See Also: - SetShutter - - Note: 1. The opening and closing time can be different. - 2. For cameras capable of controlling the internal and external shutter independently (capability AC_FEATURES_SHUTTEREX) you MUST use SetShutterEx. - 3. Cameras with an internal shutter (use function IsInternalMechanicalShutter to test) but no independent shutter control (capability AC_FEATURES_SHUTTEREX) will always output a "HIGH to open" TTL signal through the external shutter port. - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cextmode = c_int(extmode) - ret = self.dll.SetShutterEx(ctyp, cmode, cclosingtime, copeningtime, cextmode) - return (ret) - - def SetShutters(self, typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetShutters(typ, mode, closingtime, openingtime, exttype, extmode, dummy1, dummy2) - - Inputs: - typ - - mode - - closingtime - - openingtime - - exttype - - extmode - - dummy1 - - dummy2 - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetShutters(int typ, int mode, int closingtime, int openingtime, int exttype, int extmode, int dummy1, int dummy2); - - ''' - ctyp = c_int(typ) - cmode = c_int(mode) - cclosingtime = c_int(closingtime) - copeningtime = c_int(openingtime) - cexttype = c_int(exttype) - cextmode = c_int(extmode) - cdummy1 = c_int(dummy1) - cdummy2 = c_int(dummy2) - ret = self.dll.SetShutters(ctyp, cmode, cclosingtime, copeningtime, cexttype, cextmode, cdummy1, cdummy2) - return (ret) - - def SetSifComment(self, comment): - ''' - Description: - This function will set the user text that will be added to any sif files created with the SaveAsSif function. The stored comment can be cleared by passing NULL or an empty text string. - - Synopsis: - ret = SetSifComment(comment) - - Inputs: - comment - The comment to add to new sif files. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Sif comment set. - - C++ Equiv: - unsigned int SetSifComment(char * comment); - - See Also: - SaveAsSif SaveAsCommentedSif SaveAsSif SetReadMode - - Note: To add a comment to a SIF file that will not be used in any future SIF files that are saved, use the function SaveAsCommentedSif. - - ''' - ccomment = comment - ret = self.dll.SetSifComment(ccomment) - return (ret) - - def SetSingleTrack(self, centre, height): - ''' - Description: - This function will set the single track parameters. The parameters are validated in the following order: centre row and then track height. - - Synopsis: - ret = SetSingleTrack(centre, height) - - Inputs: - centre - centre row of track: - Valid - range 0 to number of vertical pixels. - height - height of track: - Valid - range > 1 (maximum value depends on centre row and number of vertical pixels). - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Center row invalid. - DRV_P2INVALID - Track height invalid. - - C++ Equiv: - unsigned int SetSingleTrack(int centre, int height); - - See Also: - SetReadMode - - ''' - ccentre = c_int(centre) - cheight = c_int(height) - ret = self.dll.SetSingleTrack(ccentre, cheight) - return (ret) - - def SetSingleTrackHBin(self, bin): - ''' - Description: - This function sets the horizontal binning used when acquiring in Single Track read mode. - - Synopsis: - ret = SetSingleTrackHBin(bin) - - Inputs: - bin - Binning size. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Binning set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid binning size. - - C++ Equiv: - unsigned int SetSingleTrackHBin(int bin); - - See Also: - SetReadMode - - Note: 1) If the detector width is not a multiple of the binning DRV_BINNING_ERROR will be returned from PrepareAcquisition and/or StartAcquisition - 2) For iDus, it is recommended that you set horizontal binning to 1 - - - ''' - cbin = c_int(bin) - ret = self.dll.SetSingleTrackHBin(cbin) - return (ret) - - def SetSpool(self, active, method, path, framebuffersize): - ''' - Description: - This function will enable and disable the spooling of acquired data to the hard disk or to the RAM. - With spooling method 0, each scan in the series will be saved to a separate file composed of a sequence of 32-bit integers. - With spooling method 1 the type of data in the output files depends on what type of acquisition is taking place (see below). - Spooling method 2 writes out the data to file as 16-bit integers. - Spooling method 3 creates a directory structure for storing images where multiple images may appear in each file within the directory structure and the files may be spread across multiple directories. Like method 1 the data type of the image pixels depends on whether accumulate mode is being used. - Method 4 Creates a RAM disk for storing images so you should ensure that there is enough free RAM to store the full acquisition. - Methods 5, 6 and 7 can be used to directly spool out to a particular file type, either FITS, SIF or TIFF respectively. In the case of FITS and TIFF the data will be written out as 16-bit values. - Method 8 is similar to method 3, however the data is first compressed before writing to disk. In some circumstances this may improve the maximum rate of writing images to disk, however as the compression can be very CPU intensive this option may not be suitable on slower processors. - The data is stored in row order starting with the row nearest the readout register. With the exception of methods 5, 6 and 7, the data acquired during a spooled acquisition can be retrieved through the normal functions. This is a change to previous versions; it is no longer necessary to load the data from disk from your own application. - - Synopsis: - ret = SetSpool(active, method, path, framebuffersize) - - Inputs: - active - Enable/disable spooling: - 0 - Disable spooling. - 1 - Enable spooling. - method - Indicates the format of the files written to disk: - 0 - Files contain sequence of 32-bit integers - 1 - Format of data in files depends on whether multiple accumulations are being taken for each scan. Format will be 32-bit integer if data is being accumulated each scan; otherwise the format will be 16-bit integer. - 2 - Files contain sequence of 16-bit integers. - 3 - Multiple directory structure with multiple images per file and multiple files per directory. - 4 - Spool to RAM disk. - 5 - Spool to 16-bit Fits File. - 6 - Spool to Andor Sif format. - 7 - Spool to 16-bit Tiff File. - 8 - Similar to method 3 but with data compression. - path - String containing the filename stem. May also contain the path to the directory into which the files are to be stored. - framebuffersize - This sets the size of an internal circular buffer used as temporary storage. The value is the total number images the buffer can hold, not the size in bytes. Typical value would be 10. This value would be increased in situations where the computer is not able to spool the data to disk at the required rate. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Parameters set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - - C++ Equiv: - unsigned int SetSpool(int active, int method, char * path, int framebuffersize); - - See Also: - GetSpoolProgress - - Note: Spooled images will not be post processed, i.e. flipped or rotated. - - ''' - cactive = c_int(active) - cmethod = c_int(method) - cpath = path - cframebuffersize = c_int(framebuffersize) - ret = self.dll.SetSpool(cactive, cmethod, cpath, cframebuffersize) - return (ret) - - def SetSpoolThreadCount(self, count): - ''' - Description: - This function sets the number of parallel threads used for writing data to disk when spooling is enabled. Increasing this to a value greater than the default of 1, can sometimes improve the data rate to the hard disk particularly with Solid State hard disks. In other cases increasing this value may actually reduce the rate at which data is written to disk. - - Synopsis: - ret = SetSpoolThreadCount(count) - - Inputs: - count - The number of threads to use. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Thread count is set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid thread count. - - C++ Equiv: - unsigned int SetSpoolThreadCount(int count); - - See Also: - SetSpool - - Note: This feature is currently only available when using the Neo camera. - - ''' - ccount = c_int(count) - ret = self.dll.SetSpoolThreadCount(ccount) - return (ret) - - def SetStorageMode(self, mode): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetStorageMode(mode) - - Inputs: - mode - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetStorageMode(long mode); - - ''' - cmode = c_int(mode) - ret = self.dll.SetStorageMode(cmode) - return (ret) - - def SetTECEvent(self, driverEvent): - ''' - Description: - This function passes a Win32 Event handle to the driver via which the driver can inform the user software that the TEC has overheated or returned to a normal state. To determine what event has actually occurred call the GetTECStatus function. This may give the user software an opportunity to perform other actions that will not affect the readout of the current acquisition. - - Synopsis: - ret = SetTECEvent(driverEvent) - - Inputs: - driverEvent - Win32 event handle. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Event set - DRV_NOT_INITIALIZED - System not initialized - DRV_NOT_AVAILABLE - Function not supported for operating system - - C++ Equiv: - unsigned int SetTECEvent(HANDLE driverEvent); - - See Also: - GetTECStatus - - ''' - cdriverEvent = c_void_p(driverEvent) - ret = self.dll.SetTECEvent(cdriverEvent) - return (ret) - - def SetTemperature(self, temperature): - ''' - Description: - This function will set the desired temperature of the detector. To turn the cooling ON and OFF use the CoolerONCoolerON and CoolerOFFCoolerOFF function respectively. - - Synopsis: - ret = SetTemperature(temperature) - - Inputs: - temperature - the temperature in Centigrade.: - Valid - range is given by GetTemperatureRangeGetTemperatureRange - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Temperature set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_P1INVALID - Temperature invalid. - DRV_NOT_SUPPORTED - The camera does not support setting the temperature. - - C++ Equiv: - unsigned int SetTemperature(int temperature); - - See Also: - CoolerOFF CoolerON GetTemperature GetTemperatureF GetTemperatureRange - - Note: Not available on Luca R cameras - automatically cooled to -20C. - - ''' - ctemperature = c_int(temperature) - ret = self.dll.SetTemperature(ctemperature) - return (ret) - - def SetTemperatureEvent(self, temperatureEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetTemperatureEvent(temperatureEvent) - - Inputs: - temperatureEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetTemperatureEvent(at_32 temperatureEvent); - - ''' - ctemperatureEvent = c_int(temperatureEvent) - ret = self.dll.SetTemperatureEvent(ctemperatureEvent) - return (ret) - - def SetTriggerInvert(self, mode): - ''' - Description: - This function will set whether an acquisition will be triggered on a rising or falling edge external trigger. - - Synopsis: - ret = SetTriggerInvert(mode) - - Inputs: - mode - trigger mode: - 0 - Rising Edge - 1 - Falling Edge - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - DRV_NOT_AVAILABLE - Feature not available. - - C++ Equiv: - unsigned int SetTriggerInvert(int mode); - - See Also: - Trigger Modes SetTriggerMode SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerInvert(cmode) - return (ret) - - def SetTriggerLevel(self, f_level): - ''' - Description: - This function sets the trigger voltage which the system will use. - - Synopsis: - ret = SetTriggerLevel(f_level) - - Inputs: - f_level - trigger voltage - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Level set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_SUPPORTED DRV_ACQUIRING - Trigger levels not supported. - DRV_ERROR_ACK - Acquisition in progress. - DRV_P1INVALID - Unable to communicate with system. - - C++ Equiv: - unsigned int SetTriggerLevel(float f_level); - - See Also: - GetCapabilities GetTriggerLevelRange - - ''' - cf_level = c_float(f_level) - ret = self.dll.SetTriggerLevel(cf_level) - return (ret) - - def SetTriggerMode(self, mode): - ''' - Description: - This function will set the trigger mode that the camera will operate in. - - Synopsis: - ret = SetTriggerMode(mode) - - Inputs: - mode - trigger mode: - 0 - internal - 1 - External - 6 - External Start - 7 - External Exposure (Bulb) - 9 - External FVB EM (only valid for EM Newton models in FVB mode) 10. Software Trigger - 12 - External Charge Shifting - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Trigger mode set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Trigger mode invalid. - - C++ Equiv: - unsigned int SetTriggerMode(int mode); - - See Also: - Trigger Modes SetFastExtTrigger - - ''' - cmode = c_int(mode) - ret = self.dll.SetTriggerMode(cmode) - return (ret) - - def SetUserEvent(self, userEvent): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUserEvent(userEvent) - - Inputs: - userEvent - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUserEvent(at_32 userEvent); - - ''' - cuserEvent = c_int(userEvent) - ret = self.dll.SetUserEvent(cuserEvent) - return (ret) - - def SetUSGenomics(self, width, height): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetUSGenomics(width, height) - - Inputs: - width - - height - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetUSGenomics(long width, long height); - - ''' - cwidth = c_int(width) - cheight = c_int(height) - ret = self.dll.SetUSGenomics(cwidth, cheight) - return (ret) - - def SetVerticalRowBuffer(self, rows): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVerticalRowBuffer(rows) - - Inputs: - rows - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVerticalRowBuffer(int rows); - - ''' - crows = c_int(rows) - ret = self.dll.SetVerticalRowBuffer(crows) - return (ret) - - def SetVerticalSpeed(self, index): - ''' - Description: - Deprecated see Note: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVerticalSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVerticalSpeedsGetNumberVerticalSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVerticalSpeed(int index); // deprecated - - See Also: - GetNumberVerticalSpeeds GetVerticalSpeed - - Note: Deprecated by SetVSSpeedSetVSSpeed. - - ''' - cindex = c_int(index) - ret = self.dll.SetVerticalSpeed(cindex) - return (ret) - - def SetVirtualChip(self, state): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = SetVirtualChip(state) - - Inputs: - state - - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int SetVirtualChip(int state); - - ''' - cstate = c_int(state) - ret = self.dll.SetVirtualChip(cstate) - return (ret) - - def SetVSAmplitude(self, index): - ''' - Description: - If you choose a high readout speed (a low readout time), then you should also consider increasing the amplitude of the Vertical Clock Voltage. - There are five levels of amplitude available for you to choose from: - * Normal - * +1 - * +2 - * +3 - * +4 - Exercise caution when increasing the amplitude of the vertical clock voltage, since higher clocking voltages may result in increased clock-induced charge (noise) in your signal. In general, only the very highest vertical clocking speeds are likely to benefit from an increased vertical clock voltage amplitude. - - Synopsis: - ret = SetVSAmplitude(index) - - Inputs: - index - desired Vertical Clock Voltage Amplitude: - 0 - Normal - 1 ->4 - Increasing Clock voltage Amplitude - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Amplitude set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_NOT_AVAILABLE - Your system does not support this feature - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Invalid amplitude parameter. - - C++ Equiv: - unsigned int SetVSAmplitude(int index); - - Note: Available in iXon, iKon and Newton - full range of amplitude levels is not available on all compatible cameras. - - ''' - cindex = c_int(index) - ret = self.dll.SetVSAmplitude(cindex) - return (ret) - - def SetVSSpeed(self, index): - ''' - Description: - This function will set the vertical speed to be used for subsequent acquisitions - - Synopsis: - ret = SetVSSpeed(index) - - Inputs: - index - index into the vertical speed table: - 0 - to GetNumberVSSpeedsGetNumberVSSpeeds-1 - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Vertical speed set. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_P1INVALID - Index out of range. - - C++ Equiv: - unsigned int SetVSSpeed(int index); - - See Also: - GetNumberVSSpeeds GetVSSpeed GetFastestRecommendedVSSpeed - - ''' - cindex = c_int(index) - ret = self.dll.SetVSSpeed(cindex) - return (ret) - - def ShutDown(self): - ''' - Description: - This function will close the AndorMCD system down. - - Synopsis: - ret = ShutDown() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - System shut down. - - C++ Equiv: - unsigned int ShutDown(void); - - See Also: - CoolerOFF CoolerON SetTemperature GetTemperature - - Note: 1. For Classic & ICCD systems, the temperature of the detector should be above -20C before shutting down the system. - 2. When dynamically loading a DLL which is statically linked to the SDK library, ShutDown MUST be called before unloading. - - ''' - ret = self.dll.ShutDown() - return (ret) - - def StartAcquisition(self): - ''' - Description: - This function starts an acquisition. The status of the acquisition can be monitored via GetStatus(). - - Synopsis: - ret = StartAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition started. - DRV_NOT_INITIALIZED - System not initialized. - DRV_ACQUIRING - Acquisition in progress. - DRV_VXDNOTINSTALLED - VxD not loaded. - DRV_ERROR_ACK - Unable to communicate with card. - DRV_INIERROR - Error reading DETECTOR.INI. - DRV_ACQERROR - Acquisition settings invalid. - DRV_ERROR_PAGELOCK - Unable to allocate memory. - DRV_INVALID_FILTER - Filter not available for current acquisition. - DRV_BINNING_ERROR - Range not multiple of horizontal binning. - DRV_SPOOLSETUPERROR - Error with spool settings. - - C++ Equiv: - unsigned int StartAcquisition(void); - - See Also: - GetStatus GetAcquisitionTimings SetAccumulationCycleTime SetAcquisitionMode SetExposureTime SetHSSpeed SetKineticCycleTime SetMultiTrack SetNumberAccumulations SetNumberKinetics SetReadMode SetSingleTrack SetTriggerMode SetVSSpeed - - ''' - ret = self.dll.StartAcquisition() - return (ret) - - def UnMapPhysicalAddress(self): - ''' - Description: - THIS FUNCTION IS RESERVED. - - Synopsis: - ret = UnMapPhysicalAddress() - - Inputs: - None - - Outputs: - ret - Function Return Code - - C++ Equiv: - unsigned int UnMapPhysicalAddress(void); - - ''' - ret = self.dll.UnMapPhysicalAddress() - return (ret) - - def WaitForAcquisition(self): - ''' - Description: - WaitForAcquisition can be called after an acquisition is started using StartAcquisitionStartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. - Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWaitCancelWait. - An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - If a second event occurs before the first one has been acknowledged, the first one will be ignored. Care should be taken in this case, as you may have to use CancelWaitCancelWait to exit the function. - - Synopsis: - ret = WaitForAcquisition() - - Inputs: - None - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred - DRV_NOT_INITIALIZED - System not initialized. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(e.g. CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisition(void); - - See Also: - StartAcquisition CancelWait - - ''' - ret = self.dll.WaitForAcquisition() - return (ret) - - def WaitForAcquisitionByHandle(self, cameraHandle): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. - - Synopsis: - ret = WaitForAcquisitionByHandle(cameraHandle) - - Inputs: - cameraHandle - handle of camera to put into wait state. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandle(long cameraHandle); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionTimeOut WaitForAcquisitionByHandleTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ret = self.dll.WaitForAcquisitionByHandle(ccameraHandle) - return (ret) - - def WaitForAcquisitionByHandleTimeOut(self, cameraHandle, iTimeOutMs): - ''' - Description: - Whilst using multiple cameras WaitForAcquisitionByHandle can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionByHandleTimeOut(cameraHandle, iTimeOutMs) - - Inputs: - cameraHandle - handle of camera to put into wait state. - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_P1INVALID - Handle not valid. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionByHandleTimeOut(long cameraHandle, int iTimeOutMs); - - See Also: - CancelWait GetCameraHandle StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionTimeOut - - ''' - ccameraHandle = c_int(cameraHandle) - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionByHandleTimeOut(ccameraHandle, ciTimeOutMs) - return (ret) - - def WaitForAcquisitionTimeOut(self, iTimeOutMs): - ''' - Description: - WaitForAcquisitionTimeOut can be called after an acquisition is started using StartAcquisition to put the calling thread to sleep until an Acquisition Event occurs. This can be used as a simple alternative to the functionality provided by the SetDriverEvent function, as all Event creation and handling is performed internally by the SDK library. Like the SetDriverEvent functionality it will use less processor resources than continuously polling with the GetStatus function. If you wish to restart the calling thread without waiting for an Acquisition event, call the function CancelWait. An Acquisition Event occurs each time a new image is acquired during an Accumulation, Kinetic Series or Run-Till-Abort acquisition or at the end of a Single Scan Acquisition. If an Acquisition Event does not occur within _TimeOutMs milliseconds, WaitForAcquisitionTimeOut returns DRV_NO_NEW_DATA - - Synopsis: - ret = WaitForAcquisitionTimeOut(iTimeOutMs) - - Inputs: - iTimeOutMs - Time before returning DRV_NO_NEW_DATA if no Acquisition Event occurs. - - Outputs: - ret - Function Return Code: - DRV_SUCCESS - Acquisition Event occurred. - DRV_NO_NEW_DATA - Non-Acquisition Event occurred.(eg CancelWait () called, time out) - - C++ Equiv: - unsigned int WaitForAcquisitionTimeOut(int iTimeOutMs); - - See Also: - CancelWait StartAcquisition WaitForAcquisition WaitForAcquisitionByHandle WaitForAcquisitionByHandleTimeOut - - ''' - ciTimeOutMs = c_int(iTimeOutMs) - ret = self.dll.WaitForAcquisitionTimeOut(ciTimeOutMs) - return (ret) - - def WhiteBalance(self): - ''' - Description: - For colour sensors only - Calculates the red and blue relative to green factors to white balance a colour image using the parameters stored in info. - Before passing the address of an WhiteBalanceInfo structure to the function the iSize member of the structure should be set to the size of the structure. In C++ this can be done with the line: - nfo-> iSize = sizeof(WhiteBalanceInfo); - Below is the WhiteBalanceInfo structure definition and a description of its members: - struct WHITEBALANCEINFO { - int iSize; // Structure size. - int iX; // Number of X pixels. Must be >2. - int iY; // Number of Y pixels. Must be >2. - int iAlgorithm; // Algorithm to used to calculate white balance. - int iROI_left; // Region Of interest from which white balance is calculated - int iROI_right; // Region Of interest from which white balance is calculated - int iROI_top; // Region Of interest from which white balance is calculated - int iROI_bottom; // Region Of interest from which white balance is calculated - WhiteBalanceInfo; - iX and iY are the image dimensions. The number of elements of the input, red, green and blue arrays are iX x iY. - iAlgorithm sets the algorithm to use. The function sums all the colour values per each colour field within the Region Of interest (ROI) and calculates the relative to green values as: 0) _fRelR = GreenSum / RedSum and _fRelB = GreenSum / BlueSum; 1) _fRelR = 2/3 GreenSum / RedSum and _fRelB = 2/3 GreenSum / BlueSum, giving more importance to the green field. - iROI_left, iROI_right, iROI_top and iROI_bottom define the ROI with the constraints: - iROI_left0 <= iROI_left < iROI_right <= iX and 0 <= iROI_ bottom < iROI_ top <= iX - - Synopsis: - (ret, wRed, wGreen, wBlue, fRelR, fRelB, info) = WhiteBalance() - - Inputs: - None - - Outputs: - ret - Function Return Code: - SUCCESS - White balance calculated. - DRV_P1INVALID - Invalid pointer (i.e. NULL). - DRV_P2INVALID - Invalid pointer (i.e. NULL). - DRV_P3INVALID - Invalid pointer (i.e. NULL). - DRV_P4INVALID - Invalid pointer (i.e. NULL). - DRV_P5INVALID - Invalid pointer (i.e. NULL). - DRV_P6INVALID - One or more parameters in info is out of range - DRV_DIVIDE_BY_ZERO_ERROR - The sum of the green field within the ROI is zero. _fRelR and _fRelB are set to 1 - wRed - pointer to red field. - wGreen - pointer to green field. - wBlue - pointer to blue field. - fRelR - pointer to the relative to green red factor. - fRelB - pointer to the relative to green blue factor. - info - pointer to white balance information structure - - C++ Equiv: - unsigned int WhiteBalance(WORD * wRed, WORD * wGreen, WORD * wBlue, float * fRelR, float * fRelB, WhiteBalanceInfo * info); - - See Also: - DemosaicImage GetMostRecentColorImage16 - - ''' - cwRed = c_short() - cwGreen = c_short() - cwBlue = c_short() - cfRelR = c_float() - cfRelB = c_float() - cinfo = WhiteBalanceInfo() - ret = self.dll.WhiteBalance(byref(cwRed), byref(cwGreen), byref(cwBlue), byref(cfRelR), byref(cfRelB), byref(cinfo)) - return (ret, cwRed.value, cwGreen.value, cwBlue.value, cfRelR.value, cfRelB.value, cinfo) - diff --git a/Andor/sdk's/sdk3/CameraInformation.py b/Andor/sdk's/sdk3/CameraInformation.py deleted file mode 100644 index 1758e15..0000000 --- a/Andor/sdk's/sdk3/CameraInformation.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -from atcore import * - -print("Camera Information Example") - -print("Intialising SDK3") -sdk3 = ATCore() # Initialise SDK3 -deviceCount = sdk3.get_int(sdk3.AT_HNDL_SYSTEM,"DeviceCount"); - -print("Found : ",deviceCount," device(s)"); - -for i in range(0,deviceCount) : - - try : - print(" Opening device ",(i+1)); - hndl = sdk3.open(i); - - serial = sdk3.get_string(hndl,"SerialNumber"); - print(" Serial No : ",serial); - - - model = sdk3.get_string(hndl,"CameraModel"); - print(" Model No : ",model); - - except ATCoreException as err : - print(" SDK3 Error {0}".format(err)); - print(" Closing device ",(i+1)); - sdk3.close(hndl); diff --git a/Andor/sdk's/sdk3/README b/Andor/sdk's/sdk3/README deleted file mode 100644 index 0108275..0000000 --- a/Andor/sdk's/sdk3/README +++ /dev/null @@ -1,16 +0,0 @@ -Python Wrapper Readme - -The python module which wraps the SDK3 is atcore.py - -There are two examples: -* SingleScan.py - Performs a Single image acquisition -* CameraInformation.py - Prints basic information about cameras attached. - -To use the wrapper, copy the following files from your SDK3 installation to the same directory as the atcore.py: -* atcore.dll -* atdevregcam.dll -* atblkbx.dll -* atcl_bitflow.dll -* atusb_libusb10.dll -* atcore.h -* atcorem.h, this needs to be renamed atcore.lib \ No newline at end of file diff --git a/Andor/sdk's/sdk3/SingleScan.py b/Andor/sdk's/sdk3/SingleScan.py deleted file mode 100644 index a183ba0..0000000 --- a/Andor/sdk's/sdk3/SingleScan.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -from atcore import * -import numpy as np - -def main() : - - print("Single Scan Example") - - print("Intialising SDK3") - sdk3 = ATCore() # Initialise SDK3 - deviceCount = sdk3.get_int(sdk3.AT_HNDL_SYSTEM,"DeviceCount"); - - print("Found : ",deviceCount," device(s)"); - - if deviceCount > 0 : - - try : - print(" Opening camera "); - hndl = sdk3.open(0); - - print(" Configuring Acquisition"); - sdk3.set_enumerated_string(hndl,"SimplePreAmpGainControl","16-bit (low noise & high well capacity)"); - - print(" Queuing Buffer"); - imageSizeBytes = sdk3.get_int(hndl,"ImageSizeBytes"); - buf = np.empty((imageSizeBytes,), dtype='B') - sdk3.queue_buffer(hndl,buf.ctypes.data,imageSizeBytes); - - print(" Acquiring Frame"); - sdk3.command(hndl,"AcquisitionStart"); - (returnedBuf, returnedSize) = sdk3.wait_buffer(hndl); - - print(" Frame Returned, first 10 pixels"); - pixels = buf.view(dtype='H'); - for i in range(0,10) : - print(" Pixel ",i," value ",pixels[i]) - - sdk3.command(hndl,"AcquisitionStop"); - - except ATCoreException as err : - print(" SDK3 Error {0}".format(err)); - print(" Closing camera"); - sdk3.close(hndl); - else : - print("Could not connect to camera"); - -main(); diff --git a/Andor/sdk's/sdk3/atcore.py b/Andor/sdk's/sdk3/atcore.py deleted file mode 100644 index 28e7931..0000000 --- a/Andor/sdk's/sdk3/atcore.py +++ /dev/null @@ -1,395 +0,0 @@ -import sys -if sys.version < '3': - import codecs - def u(x): - return codecs.unicode_escape_decode(x)[0] -else: - def u(x): - return x - -class ATCoreException(Exception): pass - -class ATCore(object): - - _ERRORS = { - 0: 'AT_SUCCESS', - 1: 'AT_ERR_NOTINITIALISED', - 2: 'AT_ERR_NOTIMPLEMENTED', - 3: 'AT_ERR_READONLY', - 4: 'AT_ERR_NOTREADABLE', - 5: 'AT_ERR_NOTWRITABLE', - 6: 'AT_ERR_OUTOFRANGE', - 7: 'AT_ERR_INDEXNOTAVAILABLE', - 8: 'AT_ERR_INDEXNOTIMPLEMENTED', - 9: 'AT_ERR_EXCEEDEDMAXSTRINGLENGTH', - 10: 'AT_ERR_CONNECTION', - 11: 'AT_ERR_NODATA', - 12: 'AT_ERR_INVALIDHANDLE', - 13: 'AT_ERR_TIMEDOUT', - 14: 'AT_ERR_BUFFERFULL', - 15: 'AT_ERR_INVALIDSIZE', - 16: 'AT_ERR_INVALIDALIGNMENT', - 17: 'AT_ERR_COMM', - 18: 'AT_ERR_STRINGNOTAVAILABLE', - 19: 'AT_ERR_STRINGNOTIMPLEMENTED', - 20: 'AT_ERR_NULL_FEATURE', - 21: 'AT_ERR_NULL_HANDLE', - 22: 'AT_ERR_NULL_IMPLEMENTED_VAR', - 23: 'AT_ERR_NULL_READABLE_VAR', - 24: 'AT_ERR_NULL_READONLY_VAR', - 25: 'AT_ERR_NULL_WRITABLE_VAR', - 26: 'AT_ERR_NULL_MINVALUE', - 27: 'AT_ERR_NULL_MAXVALUE', - 28: 'AT_ERR_NULL_VALUE', - 29: 'AT_ERR_NULL_STRING', - 30: 'AT_ERR_NULL_COUNT_VAR', - 31: 'AT_ERR_NULL_ISAVAILABLE_VAR', - 32: 'AT_ERR_NULL_MAXSTRINGLENGTH', - 33: 'AT_ERR_NULL_EVCALLBACK', - 34: 'AT_ERR_NULL_QUEUE_PTR', - 35: 'AT_ERR_NULL_WAIT_PTR', - 36: 'AT_ERR_NULL_PTRSIZE', - 37: 'AT_ERR_NOMEMORY', - 38: 'AT_AT_ERR_DEVICEINUSE', - 100: 'AT_ERR_HARDWARE_OVERFLOW', - } - __version__ = '0.1' - LIBRARY_NAME = 'atcore' - AT_INFINITE=0xFFFFFFFF - - AT_CALLBACK_SUCCESS = 0 - - AT_TRUE = 1 - AT_FALSE = 0 - - AT_SUCCESS = 0 - AT_ERR_NOTINITIALISED = 1 - AT_ERR_NOTIMPLEMENTED = 2 - AT_ERR_READONLY = 3 - AT_ERR_NOTREADABLE = 4 - AT_ERR_NOTWRITABLE = 5 - AT_ERR_OUTOFRANGE= 6 - AT_ERR_INDEXNOTAVAILABLE= 7 - AT_ERR_INDEXNOTIMPLEMENTED= 8 - AT_ERR_EXCEEDEDMAXSTRINGLENGTH= 9 - AT_ERR_CONNECTION= 10 - AT_ERR_NODATA= 11 - AT_ERR_INVALIDHANDLE= 12 - AT_ERR_TIMEDOUT= 13 - AT_ERR_BUFFERFULL= 14 - AT_ERR_INVALIDSIZE= 15 - AT_ERR_INVALIDALIGNMENT= 16 - AT_ERR_COMM= 17 - AT_ERR_STRINGNOTAVAILABLE= 18 - AT_ERR_STRINGNOTIMPLEMENTED= 19 - - AT_ERR_NULL_FEATURE= 20 - AT_ERR_NULL_HANDLE= 21 - AT_ERR_NULL_IMPLEMENTED_VAR= 22 - AT_ERR_NULL_READABLE_VAR= 23 - AT_ERR_NULL_READONLY_VAR= 24 - AT_ERR_NULL_WRITABLE_VAR= 25 - AT_ERR_NULL_MINVALUE= 26 - AT_ERR_NULL_MAXVALUE= 27 - AT_ERR_NULL_VALUE= 28 - AT_ERR_NULL_STRING= 29 - AT_ERR_NULL_COUNT_VAR= 30 - AT_ERR_NULL_ISAVAILABLE_VAR= 31 - AT_ERR_NULL_MAXSTRINGLENGTH= 32 - AT_ERR_NULL_EVCALLBACK= 33 - AT_ERR_NULL_QUEUE_PTR= 34 - AT_ERR_NULL_WAIT_PTR= 35 - AT_ERR_NULL_PTRSIZE= 36 - AT_ERR_NOMEMORY= 37 - AT_ERR_DEVICEINUSE= 38 - AT_ERR_DEVICENOTFOUND= 39 - - AT_ERR_HARDWARE_OVERFLOW= 100 - - AT_HANDLE_UNINITIALISED= -1 - AT_HNDL_SYSTEM = 1 - - def __init__(self): - from cffi import FFI - self.ffi = FFI() - self.ffi.set_unicode(True) - self.C = self.ffi.cdef(""" - typedef int AT_H; - typedef int AT_BOOL; - typedef long long AT_64; - typedef unsigned char AT_U8; - typedef wchar_t AT_WC; - - int AT_InitialiseLibrary(); - int AT_FinaliseLibrary(); - - int AT_Open(int CameraIndex, AT_H *Hndl); - int AT_Close(AT_H Hndl); - - int AT_IsImplemented(AT_H Hndl, const AT_WC* Feature, AT_BOOL* Implemented); - int AT_IsReadable(AT_H Hndl, const AT_WC* Feature, AT_BOOL* Readable); - int AT_IsWritable(AT_H Hndl, const AT_WC* Feature, AT_BOOL* Writable); - int AT_IsReadOnly(AT_H Hndl, const AT_WC* Feature, AT_BOOL* ReadOnly); - - int AT_SetInt(AT_H Hndl, const AT_WC* Feature, AT_64 Value); - int AT_GetInt(AT_H Hndl, const AT_WC* Feature, AT_64* Value); - int AT_GetIntMax(AT_H Hndl, const AT_WC* Feature, AT_64* MaxValue); - int AT_GetIntMin(AT_H Hndl, const AT_WC* Feature, AT_64* MinValue); - - int AT_SetFloat(AT_H Hndl, const AT_WC* Feature, double Value); - int AT_GetFloat(AT_H Hndl, const AT_WC* Feature, double* Value); - int AT_GetFloatMax(AT_H Hndl, const AT_WC* Feature, double* MaxValue); - int AT_GetFloatMin(AT_H Hndl, const AT_WC* Feature, double* MinValue); - - int AT_SetBool(AT_H Hndl, const AT_WC* Feature, AT_BOOL Value); - int AT_GetBool(AT_H Hndl, const AT_WC* Feature, AT_BOOL* Value); - - int AT_SetEnumerated(AT_H Hndl, const AT_WC* Feature, int Value); - int AT_SetEnumeratedString(AT_H Hndl, const AT_WC* Feature, const AT_WC* String); - int AT_GetEnumerated(AT_H Hndl, const AT_WC* Feature, int* Value); - int AT_GetEnumeratedCount(AT_H Hndl,const AT_WC* Feature, int* Count); - int AT_IsEnumeratedIndexAvailable(AT_H Hndl, const AT_WC* Feature, int Index, AT_BOOL* Available); - int AT_IsEnumeratedIndexImplemented(AT_H Hndl, const AT_WC* Feature, int Index, AT_BOOL* Implemented); - int AT_GetEnumeratedString(AT_H Hndl, const AT_WC* Feature, int Index, AT_WC* String, int StringLength); - - int AT_SetEnumIndex(AT_H Hndl, const AT_WC* Feature, int Value); - int AT_SetEnumString(AT_H Hndl, const AT_WC* Feature, const AT_WC* String); - int AT_GetEnumIndex(AT_H Hndl, const AT_WC* Feature, int* Value); - int AT_GetEnumCount(AT_H Hndl,const AT_WC* Feature, int* Count); - int AT_IsEnumIndexAvailable(AT_H Hndl, const AT_WC* Feature, int Index, AT_BOOL* Available); - int AT_IsEnumIndexImplemented(AT_H Hndl, const AT_WC* Feature, int Index, AT_BOOL* Implemented); - int AT_GetEnumStringByIndex(AT_H Hndl, const AT_WC* Feature, int Index, AT_WC* String, int StringLength); - - int AT_Command(AT_H Hndl, const AT_WC* Feature); - - int AT_SetString(AT_H Hndl, const AT_WC* Feature, const AT_WC* String); - int AT_GetString(AT_H Hndl, const AT_WC* Feature, AT_WC* String, int StringLength); - int AT_GetStringMaxLength(AT_H Hndl, const AT_WC* Feature, int* MaxStringLength); - - int AT_QueueBuffer(AT_H Hndl, AT_U8* Ptr, int PtrSize); - int AT_WaitBuffer(AT_H Hndl, AT_U8** Ptr, int* PtrSize, unsigned int Timeout); - int AT_Flush(AT_H Hndl); - - """) - - self.lib = self.ffi.verify('#include "atcore.h"', include_dirs=["."], libraries=["atcore"]) - - self.handle_return(self.lib.AT_InitialiseLibrary()) - - def __del__(self): - self.handle_return(self.lib.AT_FinaliseLibrary()) - - def handle_return(self,ret_value): - if ret_value != 0: - raise ATCoreException('{} ({})'.format(ret_value, self._ERRORS[ret_value])) - return ret_value - - def get_version(self): - return self.__version__ - - def open(self, index): - """Open camera AT_H. - """ - result = self.ffi.new("AT_H *") - self.handle_return(self.lib.AT_Open(index, result)) - - return result[0] - - def close(self, AT_H): - """Close camera AT_H. - """ - self.handle_return(self.lib.AT_Close(AT_H)) - - def is_implemented(self, AT_H, command): - """Checks if command is implemented. - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsImplemented(AT_H, u(command), result)) - return result[0] - - def is_readable(self, AT_H, command): - """Checks if command is readable. - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsReadable(AT_H, u(command), result)) - return result[0] - - def is_writable(self, AT_H, command): - """Checks if command is writable. - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsWritable(AT_H, u(command), result)) - return result[0] - - def is_readonly(self, AT_H, command): - """Checks if command is read only. - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsReadOnly(AT_H, u(command), result)) - return result[0] - - def set_int(self, AT_H, command, value): - """SetInt function. - """ - self.handle_return(self.lib.AT_SetInt(AT_H, u(command), value)) - - def get_int(self, AT_H, command): - """Run command and get Int return value. - """ - result = self.ffi.new("AT_64 *") - self.handle_return(self.lib.AT_GetInt(AT_H, u(command), result)) - return result[0] - - def get_int_max(self, AT_H, command): - """Run command and get maximum Int return value. - """ - result = self.ffi.new("AT_64 *") - self.handle_return(self.lib.AT_GetIntMax(AT_H, u(command), result)) - return result[0] - - def get_int_min(self, AT_H, command): - """Run command and get minimum Int return value. - """ - result = self.ffi.new("AT_64 *") - self.handle_return(self.lib.AT_GetIntMin(AT_H, u(command), result)) - return result[0] - - def set_float(self, AT_H, command, value): - """Set command with Float value parameter. - """ - self.handle_return(self.lib.AT_SetFloat(AT_H, u(command), value)) - - def get_float(self, AT_H, command): - """Run command and get float return value. - """ - result = self.ffi.new("double *") - self.handle_return(self.lib.AT_GetFloat(AT_H, u(command), result)) - return result[0] - - def get_float_max(self, AT_H, command): - """Run command and get maximum float return value. - """ - result = self.ffi.new("double *") - self.handle_return(self.lib.AT_GetFloatMax(AT_H, u(command), result)) - return result[0] - - def get_float_min(self, AT_H, command): - """Run command and get minimum float return value. - """ - result = self.ffi.new("double *") - self.handle_return(self.lib.AT_GetFloatMin(AT_H, u(command), result)) - return result[0] - - def get_bool(self, AT_H, command): - """Run command and get Bool return value. - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_GetBool(AT_H, u(command), result)) - return result[0] - - def set_bool(self, AT_H, command, value): - """Set command with Bool value parameter. - """ - self.handle_return(self.lib.AT_SetBool(AT_H, u(command), value)) - - def set_enumerated(self, AT_H, command, value): - """Set command with Enumerated value parameter. - """ - self.handle_return(self.lib.AT_SetEnumerated(AT_H, u(command), value)) - - def set_enumerated_string(self, AT_H, command, item): - """Set command with EnumeratedString value parameter. - """ - self.handle_return(self.lib.AT_SetEnumeratedString(AT_H, u(command), u(item))) - - def get_enumerated(self, AT_H, command): - """Run command and set Enumerated return value. - """ - result = self.ffi.new("int *") - self.handle_return(self.lib.AT_GetEnumerated(AT_H, u(command), result)) - return result[0] - - def get_enumerated_string_options(self, AT_H, command) : - """Get list of option strings - """ - count = self.get_enumerated_count(AT_H, command) - strings = [] - for i in range(0, count): - strings.append(self.get_enumerated_string_by_index(AT_H, u(command),i)) - return strings - - def get_enumerated_string(self, AT_H, command, result_length=128): - """Run command and set Enumerated return value. - """ - ret = self.get_enumerated(AT_H, command) - return self.get_enumerated_string_by_index(AT_H, u(command), ret) - - def get_enumerated_count(self, AT_H, command): - """Run command and set Enumerated return value. - """ - result = self.ffi.new("int *") - self.handle_return(self.lib.AT_GetEnumeratedCount(AT_H, u(command), result)) - return result[0] - - def is_enumerated_index_available(self, AT_H, command, index): - """Check if enumerated index is available - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsEnumeratedIndexAvailable(AT_H, u(command), index, result)) - return result[0] - - def is_enumerated_index_implemented(self, AT_H, command, index): - """Check if enumerated index is implemented - """ - result = self.ffi.new("AT_BOOL *") - self.handle_return(self.lib.AT_IsEnumeratedIndexImplemented(AT_H, u(command), index, result)) - return result[0] - - def get_enumerated_string_by_index(self, AT_H, command, index, result_length=128): - """Get command with EnumeratedString value parameter. - """ - result = self.ffi.new("AT_WC [%s]" % result_length) - self.handle_return(self.lib.AT_GetEnumStringByIndex(AT_H, u(command), index, result, result_length)) - return self.ffi.string(result) - - def command(self, AT_H, command): - """Run command. - """ - self.handle_return(self.lib.AT_Command(AT_H, u(command))) - - def set_string(self, AT_H, command, strvalue): - """SetString function. - """ - self.handle_return(self.lib.AT_SetString(AT_H, u(command), u(strvalue))) - - def get_string(self, AT_H, command, result_length=128): - """Run command and get string return value. - """ - result = self.ffi.new("AT_WC [%s]" % result_length) - self.handle_return(self.lib.AT_GetString(AT_H, u(command), result, result_length)) - return self.ffi.string(result, result_length) - - def get_string_max_length(self, AT_H, command): - """Run command and get maximum Int return value. - """ - result = self.ffi.new("int *") - self.handle_return(self.lib.AT_GetStringMaxLength(AT_H, u(command), result)) - return result[0] - - def queue_buffer(self, AT_H, buf_ptr, buffer_size): - """Put buffer in queue. - """ - self.handle_return(self.lib.AT_QueueBuffer(AT_H, self.ffi.cast("AT_U8 *", buf_ptr), buffer_size)) - - def wait_buffer(self, AT_H, timeout=20000): - """Wait for next buffer to fill. - """ - buf_ptr = self.ffi.new("AT_U8 **") - buffer_size = self.ffi.new("int *") - self.handle_return(self.lib.AT_WaitBuffer(AT_H, buf_ptr, buffer_size, int(timeout))) - return (buf_ptr, buffer_size[0]) - - def flush(self, AT_H): - self.handle_return(self.lib.AT_Flush(AT_H)) - - diff --git a/FLIR/Backup of Artiq Code (stable)/artiq_session.py b/FLIR/Backup of Artiq Code (stable)/artiq_session.py deleted file mode 100644 index a474ffe..0000000 --- a/FLIR/Backup of Artiq Code (stable)/artiq_session.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import sys -import subprocess -from artiq import __version__ as artiq_version -import artiq.flir_repo.flir.aqctl_flir - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ session manager. " - "Automatically runs the master, dashboard and " - "local controller manager on the current machine. " - "The latter requires the artiq-comtools package to " - "be installed.") - parser.add_argument("--version", action="version", - version="ARTIQ v{}".format(artiq_version), - help="print the ARTIQ version number") - parser.add_argument("-m", action="append", default=[], - help="add argument to the master command line") - parser.add_argument("-d", action="append", default=[], - help="add argument to the dashboard command line") - parser.add_argument("-c", action="append", default=[], - help="add argument to the controller manager command line") - parser.add_argument("-f", action="append", default=[], - help="add argument to the controller manager command line") - return parser - - -def main(): - args = get_argparser().parse_args() - - master_cmd = [sys.executable, "-u", "-m", "artiq.frontend.artiq_master"] - dashboard_cmd = [sys.executable, "-m", "artiq.frontend.artiq_dashboard"] - ctlmgr_cmd = [sys.executable, "-m", "artiq_comtools.artiq_ctlmgr"] - flir_cmd = [sys.executable, "-u", "-m", "artiq.flir_repo.flir.aqctl_flir"] - - master_cmd += args.m - dashboard_cmd += args.d - ctlmgr_cmd += args.c - flir_cmd += args.f - - with subprocess.Popen(master_cmd, - stdout=subprocess.PIPE, universal_newlines=True, - bufsize=1) as master: - master_ready = False - for line in iter(master.stdout.readline, ""): - sys.stdout.write(line) - if line.rstrip() == "ARTIQ master is now ready.": - master_ready = True - break - if master_ready: - with subprocess.Popen(dashboard_cmd): - with subprocess.Popen(ctlmgr_cmd): - with subprocess.Popen(flir_cmd): - for line in iter(master.stdout.readline, ""): - sys.stdout.write(line) - - - - else: - print("session: master failed to start, exiting.") - - -if __name__ == "__main__": - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquireAndDisplay.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Acquisition.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquisitionMultipleCamera.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/BufferHandling.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ChunkData.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/CounterAndTimer.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/DeviceEvents.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/EnumerationEvents.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Exposure_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/FileAccess_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/HighDynamicRange.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageChannelStatistics.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageEvents.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Inference.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification.raw b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection.raw b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Logging.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/LookupTable.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Classification b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Detection b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapCallback.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SaveToAvi.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Sequencer.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SpinUpdate.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-0.jpg b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-0.jpg deleted file mode 100644 index 1a24b00..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-0.jpg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-1.jpg b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-1.jpg deleted file mode 100644 index 8869161..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-1.jpg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-2.jpg b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-2.jpg deleted file mode 100644 index 9e72433..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger-20343286-2.jpg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger.py deleted file mode 100644 index aac40ff..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger_QuickSpin.py deleted file mode 100644 index a1eb67e..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/README.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/README.txt deleted file mode 100644 index 42057f3..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/README.txt +++ /dev/null @@ -1,342 +0,0 @@ -============================================================================= -Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5, 3.6, and 3.7. To - download Python, visit https://www.python.org/downloads/. Note that the - Python website defaults to 32-bit interpreters, so if you want a 64-bit - version of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python37\, you would add the following entry - to the PATH variable: - - C:\Python37\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. py -3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.7, run a preinstalled example -using the following: - - ex. py -3.7 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.chm b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.pdf b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/FFmpeg_compliance_doc.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl b/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl deleted file mode 100644 index bd0497a..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/Trigger_QuickSpin.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/__init__.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/__pycache__/__init__.cpython-38.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e02bac7..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/__init__.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir(old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir(old).py deleted file mode 100644 index be65248..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir(old).py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) -print("prepreinit") - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - print("preinit") - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - - - -print(__name__) - -if __name__ == "__main__": - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir.py deleted file mode 100644 index c5c73ac..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/aqctl_flir.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - #print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("FLIR server startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - truthcounter=1 - finally: - print("Closing server...") - #dev.close() - -if __name__ == "__main__": - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup_old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(complex).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver.py deleted file mode 100644 index 0ec0a05..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/driver.py +++ /dev/null @@ -1,289 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time -import numpy as np -from PIL import Image - -GAIN_VALUE = 23.8 #in dB, 0-40; -#GAMMA_VALUE = 0.5 #0.25-1 - -# MOT_OFFSET_HEIGHT = 0 #These corrections are for a MOT that is not at the center of the frame -# MOT_OFFSET_WIDTH = 0 -#OFFSET = 964 #52 #652 #This will be the pixel width and height of the roi -IMAGE_HEIGHT = 964 #964 #OFFSET #964 pixels default -IMAGE_WIDTH = 1288 #1288 #OFFSET #1288 pixels default -# HEIGHT_OFFSET = round((964+1-IMAGE_HEIGHT-MOT_OFFSET_HEIGHT)/2)#(964-IMAGE_HEIGHT)/2) # Y, to keep in middle of sensor -# WIDTH_OFFSET = round((1288+1-IMAGE_WIDTH-MOT_OFFSET_WIDTH)/2)#(1288-IMAGE_WIDTH)/2) # X, to keep in middle of sensor - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - # try: - - # Set camera serial numbers - serial_1 = '20343286' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - cam_1 = self.cam_list.GetBySerial(serial_1) - - Initial_EXPOSURE_TIME=1000 #in microseconds - # Initialize cameras - cam_1.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - cam_1.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - cam_1.ExposureMode.SetValue(PySpin.ExposureMode_Timed) #Timed or TriggerWidth (must comment out trigger parameters other that Line) - cam_1.ExposureTime.SetValue(Initial_EXPOSURE_TIME) - cam_1.GainAuto.SetValue(PySpin.GainAuto_Off) - cam_1.Gain.SetValue(GAIN_VALUE) - - #cam_1.Gamma.SetValue(GAMMA_VALUE) #always fails? - #cam_1.AdcBitDepth.SetValue(PySpin.AdcBitDepth_Bit16) #always fails? - - cam_1.PixelFormat.SetValue(PySpin.PixelFormat_Mono16) - cam_1.Width.SetValue(IMAGE_WIDTH) - cam_1.Height.SetValue(IMAGE_HEIGHT) - # cam_1.OffsetX.SetValue(WIDTH_OFFSET) - # cam_1.OffsetY.SetValue(HEIGHT_OFFSET) - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - cam_1.BeginAcquisition() - cam_1.EndAcquisition() - - cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - cam_1.TriggerSelector.SetValue(PySpin.TriggerSelector_FrameStart) - cam_1.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge) - - self.cam_1=cam_1 - - print("FLIR driver initialization successful...") - # except: - # print("Error in __init__(), try restarting artiq") - - def await_trigger(self, EXPOSURE_TIME): - try: - self.cam_1.ExposureTime.SetValue(int(EXPOSURE_TIME)) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - - # This is a trigger test - # for i in range(1000): - # if self.cam_1.LineStatus() == True: - # self.postpicture() - # self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - # time.sleep(1) - # else: - # time.sleep(0.01) - # print("Trying again or exiting") - - - print("Awaiting trigger...") - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in await_trigger(), try restarting artiq") - - - - def convert_image(self,num_of_im): - try: - # Acquire images - images=[] - for i in range(num_of_im): - image = self.cam_1.GetNextImage() - #print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - images.append(np.array(image.GetData(),dtype="uint16").reshape((image.GetHeight(),image.GetWidth()))) #convert PySpin ImagePtr into numpy array - image.Release() - - self.cam_1.EndAcquisition() - return images - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in convert_image(), try restarting artiq") - - - def save_image(self, imagearray):#,image_1, image_2): - try: - # Ensure image completion - - image = Image.fromarray(imagearray) - - # Save images - msec = str(time.time())[11:14] - filename = 'H%s_M%d_S%g_MS' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - filename = filename+msec - ##########################Save locally############################################ - pre1 = time.time() - if os.path.isfile(r"S:\flir_images\Image_"+filename+".png") == True: - image.save(r"S:\flir_images\Image_"+filename+"(2).png") - post1=time.time()-pre1 - print("Saved image "+filename+"(2).png locally in",post1*1000, "millisecond") - else: - image.save(r"S:\flir_images\Image_"+filename+".png") - post1=time.time()-pre1 - print("Saved image "+filename+".png locally in",post1*1000, "millisecond") - ##########################Save locally############################################ - - #########################Save to datadepot############################################ - # pre2 = time.time() - # if os.path.isfile(r"N:\data\flir_images\Image_"+filename+".png") == True: - # image.save(r"N:\data\flir_images\Image_"+filename+"(2).png") - # post2=time.time()-pre2 - # print("Saved image "+filename+"(2).png to datadepot in",post2*1000, "millisecond") - # else: - # image.save(r"N:\data\flir_images\Image_"+filename+".png") - # post2=time.time()-pre2 - # print("Saved image "+filename+".png to datadepot in",post2*1000, "millisecond") - #########################Save to datadepot############################################ - - # print((post2-post1)*1000, "millisecond lag between datadepot and local saves") - - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in save_image(), try restarting artiq") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1. Get image -# 2. Convert to array immediately -# 3. Bin it (roi) (trash most of array) -# 4. (For abs imaging: background ) - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev1.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev2.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/build/lib/flir/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.5.egg b/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.5.egg deleted file mode 100644 index 82bb8da..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.5.egg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.7.egg b/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.7.egg deleted file mode 100644 index e41e83d..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.7.egg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.8.egg b/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.8.egg deleted file mode 100644 index 5fe06f6..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/dist/flir-0.0.0-py3.8.egg and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/Makefile b/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/conf.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/conf.py deleted file mode 100644 index 6cdd72e..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'FLIR' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'FLIRdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'FLIR.tex', 'FLIR Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'flir', 'FLIR Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'FLIR', 'FLIR Documentation', - author, 'FLIR', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/index.rst b/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/index.rst deleted file mode 100644 index a92b827..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: flir.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: flir.aqctl_flir.get_argparser - :prog: aqctl_flir - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/PKG-INFO b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/PKG-INFO deleted file mode 100644 index bfed401..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: flir -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/SOURCES.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/SOURCES.txt deleted file mode 100644 index c7fb78e..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -setup.py -flir/__init__.py -flir/aqctl_flir.py -flir/driver.py -flir.egg-info/PKG-INFO -flir.egg-info/SOURCES.txt -flir.egg-info/dependency_links.txt -flir.egg-info/entry_points.txt -flir.egg-info/top_level.txt \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/dependency_links.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/entry_points.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/entry_points.txt deleted file mode 100644 index 62c21bb..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_flir = flir.aqctl_flir:main - diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/top_level.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/top_level.txt deleted file mode 100644 index c523cfe..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -flir diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__init__.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/__init__.cpython-38.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 814003d..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/aqctl_flir.cpython-38.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/aqctl_flir.cpython-38.pyc deleted file mode 100644 index 79addbb..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/aqctl_flir.cpython-38.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-37.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-37.pyc deleted file mode 100644 index d0f4f64..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-37.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-38.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-38.pyc deleted file mode 100644 index 6db7bf7..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/driver.cpython-38.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/examplev2.cpython-37.pyc b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/examplev2.cpython-37.pyc deleted file mode 100644 index 9ee1b6c..0000000 Binary files a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/__pycache__/examplev2.cpython-37.pyc and /dev/null differ diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/aqctl_flir.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/aqctl_flir.py deleted file mode 100644 index c5c73ac..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/aqctl_flir.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - #print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("FLIR server startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - truthcounter=1 - finally: - print("Closing server...") - #dev.close() - -if __name__ == "__main__": - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/driver.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/driver.py deleted file mode 100644 index 0ec0a05..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/driver.py +++ /dev/null @@ -1,289 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time -import numpy as np -from PIL import Image - -GAIN_VALUE = 23.8 #in dB, 0-40; -#GAMMA_VALUE = 0.5 #0.25-1 - -# MOT_OFFSET_HEIGHT = 0 #These corrections are for a MOT that is not at the center of the frame -# MOT_OFFSET_WIDTH = 0 -#OFFSET = 964 #52 #652 #This will be the pixel width and height of the roi -IMAGE_HEIGHT = 964 #964 #OFFSET #964 pixels default -IMAGE_WIDTH = 1288 #1288 #OFFSET #1288 pixels default -# HEIGHT_OFFSET = round((964+1-IMAGE_HEIGHT-MOT_OFFSET_HEIGHT)/2)#(964-IMAGE_HEIGHT)/2) # Y, to keep in middle of sensor -# WIDTH_OFFSET = round((1288+1-IMAGE_WIDTH-MOT_OFFSET_WIDTH)/2)#(1288-IMAGE_WIDTH)/2) # X, to keep in middle of sensor - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - # try: - - # Set camera serial numbers - serial_1 = '20343286' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - cam_1 = self.cam_list.GetBySerial(serial_1) - - Initial_EXPOSURE_TIME=1000 #in microseconds - # Initialize cameras - cam_1.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - cam_1.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - cam_1.ExposureMode.SetValue(PySpin.ExposureMode_Timed) #Timed or TriggerWidth (must comment out trigger parameters other that Line) - cam_1.ExposureTime.SetValue(Initial_EXPOSURE_TIME) - cam_1.GainAuto.SetValue(PySpin.GainAuto_Off) - cam_1.Gain.SetValue(GAIN_VALUE) - - #cam_1.Gamma.SetValue(GAMMA_VALUE) #always fails? - #cam_1.AdcBitDepth.SetValue(PySpin.AdcBitDepth_Bit16) #always fails? - - cam_1.PixelFormat.SetValue(PySpin.PixelFormat_Mono16) - cam_1.Width.SetValue(IMAGE_WIDTH) - cam_1.Height.SetValue(IMAGE_HEIGHT) - # cam_1.OffsetX.SetValue(WIDTH_OFFSET) - # cam_1.OffsetY.SetValue(HEIGHT_OFFSET) - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - cam_1.BeginAcquisition() - cam_1.EndAcquisition() - - cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - cam_1.TriggerSelector.SetValue(PySpin.TriggerSelector_FrameStart) - cam_1.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge) - - self.cam_1=cam_1 - - print("FLIR driver initialization successful...") - # except: - # print("Error in __init__(), try restarting artiq") - - def await_trigger(self, EXPOSURE_TIME): - try: - self.cam_1.ExposureTime.SetValue(int(EXPOSURE_TIME)) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - - # This is a trigger test - # for i in range(1000): - # if self.cam_1.LineStatus() == True: - # self.postpicture() - # self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - # time.sleep(1) - # else: - # time.sleep(0.01) - # print("Trying again or exiting") - - - print("Awaiting trigger...") - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in await_trigger(), try restarting artiq") - - - - def convert_image(self,num_of_im): - try: - # Acquire images - images=[] - for i in range(num_of_im): - image = self.cam_1.GetNextImage() - #print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - images.append(np.array(image.GetData(),dtype="uint16").reshape((image.GetHeight(),image.GetWidth()))) #convert PySpin ImagePtr into numpy array - image.Release() - - self.cam_1.EndAcquisition() - return images - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in convert_image(), try restarting artiq") - - - def save_image(self, imagearray):#,image_1, image_2): - try: - # Ensure image completion - - image = Image.fromarray(imagearray) - - # Save images - msec = str(time.time())[11:14] - filename = 'H%s_M%d_S%g_MS' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - filename = filename+msec - ##########################Save locally############################################ - pre1 = time.time() - if os.path.isfile(r"S:\flir_images\Image_"+filename+".png") == True: - image.save(r"S:\flir_images\Image_"+filename+"(2).png") - post1=time.time()-pre1 - print("Saved image "+filename+"(2).png locally in",post1*1000, "millisecond") - else: - image.save(r"S:\flir_images\Image_"+filename+".png") - post1=time.time()-pre1 - print("Saved image "+filename+".png locally in",post1*1000, "millisecond") - ##########################Save locally############################################ - - #########################Save to datadepot############################################ - # pre2 = time.time() - # if os.path.isfile(r"N:\data\flir_images\Image_"+filename+".png") == True: - # image.save(r"N:\data\flir_images\Image_"+filename+"(2).png") - # post2=time.time()-pre2 - # print("Saved image "+filename+"(2).png to datadepot in",post2*1000, "millisecond") - # else: - # image.save(r"N:\data\flir_images\Image_"+filename+".png") - # post2=time.time()-pre2 - # print("Saved image "+filename+".png to datadepot in",post2*1000, "millisecond") - #########################Save to datadepot############################################ - - # print((post2-post1)*1000, "millisecond lag between datadepot and local saves") - - except: - try: - self.cam_1.EndAcquisition() - except: - pass - print("Error in save_image(), try restarting artiq") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 1. Get image -# 2. Convert to array immediately -# 3. Bin it (roi) (trash most of array) -# 4. (For abs imaging: background ) - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/aqctl_flir(old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/aqctl_flir(old).py deleted file mode 100644 index be65248..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/aqctl_flir(old).py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) -print("prepreinit") - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - print("preinit") - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - - - -print(__name__) - -if __name__ == "__main__": - main() diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(backup_old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(old).py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev1.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev2.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/flir/old/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/readme.txt b/FLIR/Backup of Artiq Code (stable)/flir_repo/readme.txt deleted file mode 100644 index 6f15efb..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -v1.0 was a failure based on the simplistic code of the manual. Scrapped. -v2.0 was a copy-paste of novatech code with all names and unique functions REMOVED -v3.0 is v2.0 but with the addition of the flir camera functions. Methods are working without the camera. Call "sipyco_rpctool ::1 3200 call picture" to get trigger picture. -v3.1 I dont want to ruin v3.0 stability when hardware testing. v3.1 is hardware testing. Camera initialization and parent class problems. -v3.2 Attempt at initializing camera once and passing object to server. - - -Installation: -1. Install Spinnaker with python3.8 -conda install python3.8 -2. In Flircodevx.x directory, run: - -conda install sipyco -conda install asyncserial -python setup.py build -python setup.py install - -3. Change directories to flir and start server with: - -python aqctl_flir.py - -4. In another anaconda window, in the flir directory, take picture with: - -sipyco_rpctool ::1 3200 call picture \ No newline at end of file diff --git a/FLIR/Backup of Artiq Code (stable)/flir_repo/setup.py b/FLIR/Backup of Artiq Code (stable)/flir_repo/setup.py deleted file mode 100644 index 91e6954..0000000 --- a/FLIR/Backup of Artiq Code (stable)/flir_repo/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="flir", - install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_flir = flir.aqctl_flir:main", - ], - }, -) diff --git a/FLIR/Backup of Artiq Code (stable)/readme.txt b/FLIR/Backup of Artiq Code (stable)/readme.txt deleted file mode 100644 index 7faff03..0000000 --- a/FLIR/Backup of Artiq Code (stable)/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -1. Put artiq_session.py into C:\Users\...\.conda\envs\artiq\Lib\site-packages\artiq\frontend -2. Put flir_repo folder into C:\Users\...\.conda\envs\artiq\Lib\site-packages\artiq -3. Within flir_repo, do: -python setup.py build -python setup.py install - -It should run when artiq starts. If there is an error it will show it in the artiq_session command terminal. \ No newline at end of file diff --git a/FLIR/old/DavidsReadme.txt b/FLIR/old/DavidsReadme.txt deleted file mode 100644 index 1b8fbf9..0000000 --- a/FLIR/old/DavidsReadme.txt +++ /dev/null @@ -1,5 +0,0 @@ -Since it was less than 100mb, I copied the entire python SDK here. You must have it locally installed to be able to run it from here! -The OneNote has instructions on how to install. Dont use their install guide! - -FLIRcodev3.0 is the first version I released. It is stable on the software end but the hardware end is untested. v3.1 is the hardware testing end. -v3.3 is a rewriting of 3.2 code to clean it up and simplify. \ No newline at end of file diff --git a/FLIR/old/Examples/AcquireAndDisplay.py b/FLIR/old/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Acquisition.py b/FLIR/old/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/AcquisitionMultipleCamera.py b/FLIR/old/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/Examples/BufferHandling.py b/FLIR/old/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/Examples/ChunkData.py b/FLIR/old/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/CounterAndTimer.py b/FLIR/old/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/DeviceEvents.py b/FLIR/old/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Enumeration.py b/FLIR/old/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/EnumerationEvents.py b/FLIR/old/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/old/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/Examples/Enumeration_QuickSpin.py b/FLIR/old/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/Examples/Exposure_QuickSpin.py b/FLIR/old/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/FileAccess_QuickSpin.py b/FLIR/old/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/Examples/HighDynamicRange.py b/FLIR/old/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/ImageChannelStatistics.py b/FLIR/old/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/Examples/ImageEvents.py b/FLIR/old/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/ImageFormatControl.py b/FLIR/old/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/ImageFormatControl_QuickSpin.py b/FLIR/old/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Inference.py b/FLIR/old/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/Examples/Injected_Image_Classification.raw b/FLIR/old/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/old/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/Examples/Injected_Image_Detection.raw b/FLIR/old/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/Examples/Logging.py b/FLIR/old/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/Examples/LookupTable.py b/FLIR/old/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Network_Classification b/FLIR/old/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/old/Examples/Network_Detection b/FLIR/old/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/old/Examples/NodeMapCallback.py b/FLIR/old/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/NodeMapInfo.py b/FLIR/old/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/NodeMapInfo_QuickSpin.py b/FLIR/old/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/SaveToAvi.py b/FLIR/old/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Sequencer.py b/FLIR/old/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/SpinUpdate.py b/FLIR/old/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Trigger.py b/FLIR/old/Examples/Trigger.py deleted file mode 100644 index aac40ff..0000000 --- a/FLIR/old/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/Examples/Trigger_QuickSpin.py b/FLIR/old/Examples/Trigger_QuickSpin.py deleted file mode 100644 index a1eb67e..0000000 --- a/FLIR/old/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquireAndDisplay.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Acquisition.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquisitionMultipleCamera.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/BufferHandling.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ChunkData.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/CounterAndTimer.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/DeviceEvents.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/EnumerationEvents.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Exposure_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/FileAccess_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/HighDynamicRange.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageChannelStatistics.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageEvents.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Inference.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification.raw b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection.raw b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Logging.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/LookupTable.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Classification b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Detection b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapCallback.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SaveToAvi.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Sequencer.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SpinUpdate.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger.py deleted file mode 100644 index aac40ff..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger_QuickSpin.py deleted file mode 100644 index a1eb67e..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/README.txt b/FLIR/old/FLIRcodev3.1/Spinnaker/README.txt deleted file mode 100644 index 42057f3..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/README.txt +++ /dev/null @@ -1,342 +0,0 @@ -============================================================================= -Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5, 3.6, and 3.7. To - download Python, visit https://www.python.org/downloads/. Note that the - Python website defaults to 32-bit interpreters, so if you want a 64-bit - version of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python37\, you would add the following entry - to the PATH variable: - - C:\Python37\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. py -3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.7, run a preinstalled example -using the following: - - ex. py -3.7 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.chm b/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.pdf b/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt b/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl b/FLIR/old/FLIRcodev3.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl deleted file mode 100644 index bd0497a..0000000 Binary files a/FLIR/old/FLIRcodev3.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev3.1/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/old/FLIRcodev3.1/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.1/build/lib/flir/__init__.py b/FLIR/old/FLIRcodev3.1/build/lib/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev3.1/build/lib/flir/aqctl_flir.py b/FLIR/old/FLIRcodev3.1/build/lib/flir/aqctl_flir.py deleted file mode 100644 index 1148c02..0000000 --- a/FLIR/old/FLIRcodev3.1/build/lib/flir/aqctl_flir.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - - if args.device is None: - print("Starting in Simulation mode...") - dev = FLIR(args.device if not args.simulation else None) - - asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev3.1/build/lib/flir/driver(complex).py b/FLIR/old/FLIRcodev3.1/build/lib/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/old/FLIRcodev3.1/build/lib/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/old/FLIRcodev3.1/build/lib/flir/driver.py b/FLIR/old/FLIRcodev3.1/build/lib/flir/driver.py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev3.1/build/lib/flir/driver.py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.5.egg b/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.5.egg deleted file mode 100644 index 82bb8da..0000000 Binary files a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.5.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.7.egg b/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.7.egg deleted file mode 100644 index 01cece7..0000000 Binary files a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.7.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.8.egg b/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.8.egg deleted file mode 100644 index c8be4c1..0000000 Binary files a/FLIR/old/FLIRcodev3.1/dist/flir-0.0.0-py3.8.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.1/doc/Makefile b/FLIR/old/FLIRcodev3.1/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/FLIR/old/FLIRcodev3.1/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/doc/conf.py b/FLIR/old/FLIRcodev3.1/doc/conf.py deleted file mode 100644 index 6cdd72e..0000000 --- a/FLIR/old/FLIRcodev3.1/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'FLIR' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'FLIRdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'FLIR.tex', 'FLIR Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'flir', 'FLIR Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'FLIR', 'FLIR Documentation', - author, 'FLIR', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/FLIR/old/FLIRcodev3.1/doc/index.rst b/FLIR/old/FLIRcodev3.1/doc/index.rst deleted file mode 100644 index a92b827..0000000 --- a/FLIR/old/FLIRcodev3.1/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: flir.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: flir.aqctl_flir.get_argparser - :prog: aqctl_flir - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/FLIR/old/FLIRcodev3.1/flir.egg-info/PKG-INFO b/FLIR/old/FLIRcodev3.1/flir.egg-info/PKG-INFO deleted file mode 100644 index bfed401..0000000 --- a/FLIR/old/FLIRcodev3.1/flir.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: flir -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/FLIR/old/FLIRcodev3.1/flir.egg-info/SOURCES.txt b/FLIR/old/FLIRcodev3.1/flir.egg-info/SOURCES.txt deleted file mode 100644 index 30e0303..0000000 --- a/FLIR/old/FLIRcodev3.1/flir.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -setup.py -flir/__init__.py -flir/aqctl_flir.py -flir/driver(complex).py -flir/driver.py -flir.egg-info/PKG-INFO -flir.egg-info/SOURCES.txt -flir.egg-info/dependency_links.txt -flir.egg-info/entry_points.txt -flir.egg-info/top_level.txt \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/flir.egg-info/dependency_links.txt b/FLIR/old/FLIRcodev3.1/flir.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/FLIR/old/FLIRcodev3.1/flir.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/FLIR/old/FLIRcodev3.1/flir.egg-info/entry_points.txt b/FLIR/old/FLIRcodev3.1/flir.egg-info/entry_points.txt deleted file mode 100644 index 62c21bb..0000000 --- a/FLIR/old/FLIRcodev3.1/flir.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_flir = flir.aqctl_flir:main - diff --git a/FLIR/old/FLIRcodev3.1/flir.egg-info/top_level.txt b/FLIR/old/FLIRcodev3.1/flir.egg-info/top_level.txt deleted file mode 100644 index c523cfe..0000000 --- a/FLIR/old/FLIRcodev3.1/flir.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -flir diff --git a/FLIR/old/FLIRcodev3.1/flir/__init__.py b/FLIR/old/FLIRcodev3.1/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev3.1/flir/aqctl_flir.py b/FLIR/old/FLIRcodev3.1/flir/aqctl_flir.py deleted file mode 100644 index 1148c02..0000000 --- a/FLIR/old/FLIRcodev3.1/flir/aqctl_flir.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - - if args.device is None: - print("Starting in Simulation mode...") - dev = FLIR(args.device if not args.simulation else None) - - asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev3.1/flir/driver(complex).py b/FLIR/old/FLIRcodev3.1/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/old/FLIRcodev3.1/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/old/FLIRcodev3.1/flir/driver.py b/FLIR/old/FLIRcodev3.1/flir/driver.py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev3.1/flir/driver.py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/readme.txt b/FLIR/old/FLIRcodev3.1/readme.txt deleted file mode 100644 index 45a965e..0000000 --- a/FLIR/old/FLIRcodev3.1/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -v1.0 was a failure based on the simplistic code of the manual. Scrapped. -v2.0 was a copy-paste of novatech code with all names and unique functions REMOVED -v3.0 is v2.0 but with the addition of the flir camera functions. Methods are working without the camera. Call "sipyco_rpctool ::1 3200 call picture" to get trigger picture. -v3.1 I dont want to ruin v3.0 stability when hardware testing. v3.1 is hardware testing. - - -Installation: -1. Install Spinnaker with python3.8 -conda install python3.8 -2. In Flircodevx.x directory, run: - -conda install sipyco -conda install asyncserial -python setup.py build -python setup.py install - -3. Change directories to flir and start server with: - -python aqctl_flir.py - -4. In another anaconda window, in the flir directory, take picture with: - -sipyco_rpctool ::1 3200 call picture \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.1/setup.py b/FLIR/old/FLIRcodev3.1/setup.py deleted file mode 100644 index 91e6954..0000000 --- a/FLIR/old/FLIRcodev3.1/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="flir", - install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_flir = flir.aqctl_flir:main", - ], - }, -) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquireAndDisplay.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Acquisition.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquisitionMultipleCamera.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/BufferHandling.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ChunkData.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/CounterAndTimer.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/DeviceEvents.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/EnumerationEvents.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Exposure_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/FileAccess_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/HighDynamicRange.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageChannelStatistics.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageEvents.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Inference.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification.raw b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection.raw b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Logging.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/LookupTable.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Classification b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Detection b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapCallback.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SaveToAvi.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Sequencer.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SpinUpdate.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-0.jpg b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-0.jpg deleted file mode 100644 index 1a24b00..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-0.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-1.jpg b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-1.jpg deleted file mode 100644 index 8869161..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-1.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-2.jpg b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-2.jpg deleted file mode 100644 index 9e72433..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger-20343286-2.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger.py deleted file mode 100644 index aac40ff..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger_QuickSpin.py deleted file mode 100644 index a1eb67e..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/README.txt b/FLIR/old/FLIRcodev3.2/Spinnaker/README.txt deleted file mode 100644 index 42057f3..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/README.txt +++ /dev/null @@ -1,342 +0,0 @@ -============================================================================= -Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5, 3.6, and 3.7. To - download Python, visit https://www.python.org/downloads/. Note that the - Python website defaults to 32-bit interpreters, so if you want a 64-bit - version of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python37\, you would add the following entry - to the PATH variable: - - C:\Python37\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. py -3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.7, run a preinstalled example -using the following: - - ex. py -3.7 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.chm b/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.pdf b/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/FFmpeg_compliance_doc.txt b/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl b/FLIR/old/FLIRcodev3.2/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl deleted file mode 100644 index bd0497a..0000000 Binary files a/FLIR/old/FLIRcodev3.2/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev3.2/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/old/FLIRcodev3.2/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev3.2/build/lib/flir/__init__.py b/FLIR/old/FLIRcodev3.2/build/lib/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev3.2/build/lib/flir/aqctl_flir.py b/FLIR/old/FLIRcodev3.2/build/lib/flir/aqctl_flir.py deleted file mode 100644 index fb086a9..0000000 --- a/FLIR/old/FLIRcodev3.2/build/lib/flir/aqctl_flir.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR(args.num) - asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(backup).py b/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(backup).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(backup).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(complex).py b/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver.py b/FLIR/old/FLIRcodev3.2/build/lib/flir/driver.py deleted file mode 100644 index b3a5d83..0000000 --- a/FLIR/old/FLIRcodev3.2/build/lib/flir/driver.py +++ /dev/null @@ -1,714 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -trigtype=5 -SOFTWARE = 1 -HARDWARE = 2 - -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - for i, cam in enumerate(cam_list): - - print('Defining camera %d...' % i) - - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - # Retrieve TL device nodemap and print device information - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - # Initialize camera - cam.Init() - # Retrieve GenICam nodemap - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - #return result - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - - # Configure trigger - if self.configure_trigger(cam) is False: - return False - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - # Reset trigger - result &= self.reset_trigger(cam) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.5.egg b/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.5.egg deleted file mode 100644 index 82bb8da..0000000 Binary files a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.5.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.7.egg b/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.7.egg deleted file mode 100644 index 01cece7..0000000 Binary files a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.7.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.8.egg b/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.8.egg deleted file mode 100644 index 6470df7..0000000 Binary files a/FLIR/old/FLIRcodev3.2/dist/flir-0.0.0-py3.8.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/doc/Makefile b/FLIR/old/FLIRcodev3.2/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/FLIR/old/FLIRcodev3.2/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/doc/conf.py b/FLIR/old/FLIRcodev3.2/doc/conf.py deleted file mode 100644 index 6cdd72e..0000000 --- a/FLIR/old/FLIRcodev3.2/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'FLIR' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'FLIRdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'FLIR.tex', 'FLIR Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'flir', 'FLIR Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'FLIR', 'FLIR Documentation', - author, 'FLIR', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/FLIR/old/FLIRcodev3.2/doc/index.rst b/FLIR/old/FLIRcodev3.2/doc/index.rst deleted file mode 100644 index a92b827..0000000 --- a/FLIR/old/FLIRcodev3.2/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: flir.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: flir.aqctl_flir.get_argparser - :prog: aqctl_flir - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/FLIR/old/FLIRcodev3.2/flir.egg-info/PKG-INFO b/FLIR/old/FLIRcodev3.2/flir.egg-info/PKG-INFO deleted file mode 100644 index bfed401..0000000 --- a/FLIR/old/FLIRcodev3.2/flir.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: flir -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/FLIR/old/FLIRcodev3.2/flir.egg-info/SOURCES.txt b/FLIR/old/FLIRcodev3.2/flir.egg-info/SOURCES.txt deleted file mode 100644 index 7f7dce7..0000000 --- a/FLIR/old/FLIRcodev3.2/flir.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -setup.py -flir/__init__.py -flir/aqctl_flir.py -flir/driver(backup).py -flir/driver.py -flir.egg-info/PKG-INFO -flir.egg-info/SOURCES.txt -flir.egg-info/dependency_links.txt -flir.egg-info/entry_points.txt -flir.egg-info/top_level.txt \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/flir.egg-info/dependency_links.txt b/FLIR/old/FLIRcodev3.2/flir.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/FLIR/old/FLIRcodev3.2/flir.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/FLIR/old/FLIRcodev3.2/flir.egg-info/entry_points.txt b/FLIR/old/FLIRcodev3.2/flir.egg-info/entry_points.txt deleted file mode 100644 index 62c21bb..0000000 --- a/FLIR/old/FLIRcodev3.2/flir.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_flir = flir.aqctl_flir:main - diff --git a/FLIR/old/FLIRcodev3.2/flir.egg-info/top_level.txt b/FLIR/old/FLIRcodev3.2/flir.egg-info/top_level.txt deleted file mode 100644 index c523cfe..0000000 --- a/FLIR/old/FLIRcodev3.2/flir.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -flir diff --git a/FLIR/old/FLIRcodev3.2/flir/__init__.py b/FLIR/old/FLIRcodev3.2/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev3.2/flir/__pycache__/driver.cpython-38.pyc b/FLIR/old/FLIRcodev3.2/flir/__pycache__/driver.cpython-38.pyc deleted file mode 100644 index b1ebf2b..0000000 Binary files a/FLIR/old/FLIRcodev3.2/flir/__pycache__/driver.cpython-38.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev3.2/flir/aqctl_flir.py b/FLIR/old/FLIRcodev3.2/flir/aqctl_flir.py deleted file mode 100644 index fb086a9..0000000 --- a/FLIR/old/FLIRcodev3.2/flir/aqctl_flir.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR(args.num) - asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev3.2/flir/driver(backup).py b/FLIR/old/FLIRcodev3.2/flir/driver(backup).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev3.2/flir/driver(backup).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/flir/driver.py b/FLIR/old/FLIRcodev3.2/flir/driver.py deleted file mode 100644 index bfc1eb1..0000000 --- a/FLIR/old/FLIRcodev3.2/flir/driver.py +++ /dev/null @@ -1,684 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - num=NUM_IMAGES - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/readme.txt b/FLIR/old/FLIRcodev3.2/readme.txt deleted file mode 100644 index 6f15efb..0000000 --- a/FLIR/old/FLIRcodev3.2/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -v1.0 was a failure based on the simplistic code of the manual. Scrapped. -v2.0 was a copy-paste of novatech code with all names and unique functions REMOVED -v3.0 is v2.0 but with the addition of the flir camera functions. Methods are working without the camera. Call "sipyco_rpctool ::1 3200 call picture" to get trigger picture. -v3.1 I dont want to ruin v3.0 stability when hardware testing. v3.1 is hardware testing. Camera initialization and parent class problems. -v3.2 Attempt at initializing camera once and passing object to server. - - -Installation: -1. Install Spinnaker with python3.8 -conda install python3.8 -2. In Flircodevx.x directory, run: - -conda install sipyco -conda install asyncserial -python setup.py build -python setup.py install - -3. Change directories to flir and start server with: - -python aqctl_flir.py - -4. In another anaconda window, in the flir directory, take picture with: - -sipyco_rpctool ::1 3200 call picture \ No newline at end of file diff --git a/FLIR/old/FLIRcodev3.2/setup.py b/FLIR/old/FLIRcodev3.2/setup.py deleted file mode 100644 index 91e6954..0000000 --- a/FLIR/old/FLIRcodev3.2/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="flir", - install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_flir = flir.aqctl_flir:main", - ], - }, -) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquireAndDisplay.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Acquisition.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquisitionMultipleCamera.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/BufferHandling.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ChunkData.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/CounterAndTimer.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/DeviceEvents.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/EnumerationEvents.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Exposure_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/FileAccess_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/HighDynamicRange.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageChannelStatistics.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageEvents.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Inference.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification.raw b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection.raw b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Logging.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/LookupTable.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Classification b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Detection b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapCallback.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SaveToAvi.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Sequencer.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SpinUpdate.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-0.jpg b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-0.jpg deleted file mode 100644 index 1a24b00..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-0.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-1.jpg b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-1.jpg deleted file mode 100644 index 8869161..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-1.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-2.jpg b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-2.jpg deleted file mode 100644 index 9e72433..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger-20343286-2.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger.py deleted file mode 100644 index aac40ff..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger_QuickSpin.py deleted file mode 100644 index a1eb67e..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,419 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/README.txt b/FLIR/old/FLIRcodev4.0/Spinnaker/README.txt deleted file mode 100644 index 42057f3..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/README.txt +++ /dev/null @@ -1,342 +0,0 @@ -============================================================================= -Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5, 3.6, and 3.7. To - download Python, visit https://www.python.org/downloads/. Note that the - Python website defaults to 32-bit interpreters, so if you want a 64-bit - version of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python37\, you would add the following entry - to the PATH variable: - - C:\Python37\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. py -3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.7, run a preinstalled example -using the following: - - ex. py -3.7 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.chm b/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.pdf b/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/FFmpeg_compliance_doc.txt b/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl b/FLIR/old/FLIRcodev4.0/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl deleted file mode 100644 index bd0497a..0000000 Binary files a/FLIR/old/FLIRcodev4.0/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev4.0/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/old/FLIRcodev4.0/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/__init__.py b/FLIR/old/FLIRcodev4.0/build/lib/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/aqctl_flir.py b/FLIR/old/FLIRcodev4.0/build/lib/flir/aqctl_flir.py deleted file mode 100644 index edc43e6..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/aqctl_flir.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from GitHub.Instruments.FLIR.FLIRcodev40.flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup).py b/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup_old).py b/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(complex).py b/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(old).py b/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver.py b/FLIR/old/FLIRcodev4.0/build/lib/flir/driver.py deleted file mode 100644 index df94acd..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/driver.py +++ /dev/null @@ -1,179 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - try: - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - self.cam_1 = self.cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - self.cam_1.Init() - ##### cam_2.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - self.cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - self.cam_1.EndAcquisition() - - ## Set up primary camera trigger - # self.cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - # self.cam_1.V3_3Enable.SetValue(True) - - print("Initialization successful...") - except: - print("Error in __init__()") - - def await_trigger(self): - try: - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - #self.cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - #self.cam_1.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - self.cam_1.BeginAcquisition() - - print("Awaiting trigger...") - - self.postpicture() - except: - print("Error in await_trigger()") - - def postpicture(self): - try: - # Acquire images - self.image_1 = self.cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Ensure image completion - if self.image_1.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Save images - filename = 'Image_H%s_M%d_S%g.png' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - self.image_1.Save(filename) - ##### image_2.Save('cam_2.png') - - # Release images - self.image_1.Release() - ##### image_2.Release() - - # end acquisition - self.cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() - print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - except: - print("Error in postpicture()") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev1.py b/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev2.py b/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/old/FLIRcodev4.0/build/lib/flir/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.5.egg b/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.5.egg deleted file mode 100644 index 82bb8da..0000000 Binary files a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.5.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.7.egg b/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.7.egg deleted file mode 100644 index e41e83d..0000000 Binary files a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.7.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.8.egg b/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.8.egg deleted file mode 100644 index 7bbdd8f..0000000 Binary files a/FLIR/old/FLIRcodev4.0/dist/flir-0.0.0-py3.8.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/doc/Makefile b/FLIR/old/FLIRcodev4.0/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/FLIR/old/FLIRcodev4.0/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/doc/conf.py b/FLIR/old/FLIRcodev4.0/doc/conf.py deleted file mode 100644 index 6cdd72e..0000000 --- a/FLIR/old/FLIRcodev4.0/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'FLIR' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'FLIRdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'FLIR.tex', 'FLIR Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'flir', 'FLIR Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'FLIR', 'FLIR Documentation', - author, 'FLIR', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/FLIR/old/FLIRcodev4.0/doc/index.rst b/FLIR/old/FLIRcodev4.0/doc/index.rst deleted file mode 100644 index a92b827..0000000 --- a/FLIR/old/FLIRcodev4.0/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: flir.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: flir.aqctl_flir.get_argparser - :prog: aqctl_flir - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/FLIR/old/FLIRcodev4.0/flir.egg-info/PKG-INFO b/FLIR/old/FLIRcodev4.0/flir.egg-info/PKG-INFO deleted file mode 100644 index bfed401..0000000 --- a/FLIR/old/FLIRcodev4.0/flir.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: flir -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/FLIR/old/FLIRcodev4.0/flir.egg-info/SOURCES.txt b/FLIR/old/FLIRcodev4.0/flir.egg-info/SOURCES.txt deleted file mode 100644 index 6a7d17b..0000000 --- a/FLIR/old/FLIRcodev4.0/flir.egg-info/SOURCES.txt +++ /dev/null @@ -1,13 +0,0 @@ -setup.py -flir/__init__.py -flir/aqctl_flir.py -flir/driver(backup_old).py -flir/driver(old).py -flir/driver.py -flir/examplev1.py -flir/examplev2.py -flir.egg-info/PKG-INFO -flir.egg-info/SOURCES.txt -flir.egg-info/dependency_links.txt -flir.egg-info/entry_points.txt -flir.egg-info/top_level.txt \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/flir.egg-info/dependency_links.txt b/FLIR/old/FLIRcodev4.0/flir.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/FLIR/old/FLIRcodev4.0/flir.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/FLIR/old/FLIRcodev4.0/flir.egg-info/entry_points.txt b/FLIR/old/FLIRcodev4.0/flir.egg-info/entry_points.txt deleted file mode 100644 index 62c21bb..0000000 --- a/FLIR/old/FLIRcodev4.0/flir.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_flir = flir.aqctl_flir:main - diff --git a/FLIR/old/FLIRcodev4.0/flir.egg-info/top_level.txt b/FLIR/old/FLIRcodev4.0/flir.egg-info/top_level.txt deleted file mode 100644 index c523cfe..0000000 --- a/FLIR/old/FLIRcodev4.0/flir.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -flir diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S12.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S12.png deleted file mode 100644 index c975b32..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S12.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S42.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S42.png deleted file mode 100644 index c7ebf49..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S42.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S43.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S43.png deleted file mode 100644 index d45ae94..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S43.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S44.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S44.png deleted file mode 100644 index 8b4f542..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S44.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S45.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S45.png deleted file mode 100644 index f662ccc..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S45.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S46.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S46.png deleted file mode 100644 index feee34c..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S46.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S47.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S47.png deleted file mode 100644 index a3cc7dc..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S47.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S48.png b/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S48.png deleted file mode 100644 index ca2e9bd..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/Image_H15_M19_S48.png and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/__init__.py b/FLIR/old/FLIRcodev4.0/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-37.pyc b/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-37.pyc deleted file mode 100644 index d0f4f64..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-37.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-38.pyc b/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-38.pyc deleted file mode 100644 index a434172..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/__pycache__/driver.cpython-38.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/__pycache__/examplev2.cpython-37.pyc b/FLIR/old/FLIRcodev4.0/flir/__pycache__/examplev2.cpython-37.pyc deleted file mode 100644 index 9ee1b6c..0000000 Binary files a/FLIR/old/FLIRcodev4.0/flir/__pycache__/examplev2.cpython-37.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.0/flir/aqctl_flir.py b/FLIR/old/FLIRcodev4.0/flir/aqctl_flir.py deleted file mode 100644 index edc43e6..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/aqctl_flir.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from GitHub.Instruments.FLIR.FLIRcodev40.flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) - - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev4.0/flir/driver(backup_old).py b/FLIR/old/FLIRcodev4.0/flir/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/flir/driver(old).py b/FLIR/old/FLIRcodev4.0/flir/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/flir/driver.py b/FLIR/old/FLIRcodev4.0/flir/driver.py deleted file mode 100644 index df94acd..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/driver.py +++ /dev/null @@ -1,179 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - try: - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - self.cam_1 = self.cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - self.cam_1.Init() - ##### cam_2.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - self.cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - self.cam_1.EndAcquisition() - - ## Set up primary camera trigger - # self.cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - # self.cam_1.V3_3Enable.SetValue(True) - - print("Initialization successful...") - except: - print("Error in __init__()") - - def await_trigger(self): - try: - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - #self.cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - #self.cam_1.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - self.cam_1.BeginAcquisition() - - print("Awaiting trigger...") - - self.postpicture() - except: - print("Error in await_trigger()") - - def postpicture(self): - try: - # Acquire images - self.image_1 = self.cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Ensure image completion - if self.image_1.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Save images - filename = 'Image_H%s_M%d_S%g.png' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - self.image_1.Save(filename) - ##### image_2.Save('cam_2.png') - - # Release images - self.image_1.Release() - ##### image_2.Release() - - # end acquisition - self.cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() - print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - except: - print("Error in postpicture()") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/flir/examplev1.py b/FLIR/old/FLIRcodev4.0/flir/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/flir/examplev2.py b/FLIR/old/FLIRcodev4.0/flir/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/old/FLIRcodev4.0/flir/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/readme.txt b/FLIR/old/FLIRcodev4.0/readme.txt deleted file mode 100644 index 6f15efb..0000000 --- a/FLIR/old/FLIRcodev4.0/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -v1.0 was a failure based on the simplistic code of the manual. Scrapped. -v2.0 was a copy-paste of novatech code with all names and unique functions REMOVED -v3.0 is v2.0 but with the addition of the flir camera functions. Methods are working without the camera. Call "sipyco_rpctool ::1 3200 call picture" to get trigger picture. -v3.1 I dont want to ruin v3.0 stability when hardware testing. v3.1 is hardware testing. Camera initialization and parent class problems. -v3.2 Attempt at initializing camera once and passing object to server. - - -Installation: -1. Install Spinnaker with python3.8 -conda install python3.8 -2. In Flircodevx.x directory, run: - -conda install sipyco -conda install asyncserial -python setup.py build -python setup.py install - -3. Change directories to flir and start server with: - -python aqctl_flir.py - -4. In another anaconda window, in the flir directory, take picture with: - -sipyco_rpctool ::1 3200 call picture \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.0/setup.py b/FLIR/old/FLIRcodev4.0/setup.py deleted file mode 100644 index 91e6954..0000000 --- a/FLIR/old/FLIRcodev4.0/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="flir", - install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_flir = flir.aqctl_flir:main", - ], - }, -) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquireAndDisplay.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Acquisition.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquisitionMultipleCamera.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/BufferHandling.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ChunkData.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/CounterAndTimer.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/DeviceEvents.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/EnumerationEvents.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/EnumerationEvents.py deleted file mode 100644 index 79e8187..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/EnumerationEvents.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - -class InterfaceEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on an interface. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. Also, enumeration event handlers must inherit from - InterfaceEvent whether they are to be registered to the system or an interface. - """ - def __init__(self, iface, iface_num): - """ - Constructor. Note that this sets the interface instance. - - :param iface: Interface instance. - :param iface_num: Interface number. - """ - super(InterfaceEventHandler, self).__init__() - self.interface = iface - self.interface_num = iface_num - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on an interface. It prints out - the device serial number of the camera arriving and the interface - number. The argument is the serial number of the camera that triggered - the arrival event. - - :param serial_number: gcstring representing the device serial number of arriving camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i has arrived on interface %i.' % (serial_number, self.interface_num)) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines removal events on an interface. It prints out the - device serial number of the camera being removed and the interface - number. The argument is the serial number of the camera that triggered - the removal event. - - :param serial_number: gcstring representing the device serial number of removed camera - :type serial_number: gcstring - :return: None - """ - print('Interface event handler:') - print('\tDevice %i was removed from interface %i.' % (serial_number, self.interface_num)) - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - In the C++ example, the SystemEventHandler inherits from both DeviceArrivalEventHandler and - DeviceRemovalEventHandler. This doesn't work for this wrapper, as it will only inherit the abstract - method from the first base class listed, so for this example both System and Interface - event handlers inherit from InterfaceEventHandler. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - can be - registered to interfaces, the system, or both. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It retrieves the - number of cameras currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It does the same - as the system arrival event - it retrieves the number of cameras - currently connected and prints it out. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Create and register interface event handler to each interface - # - # *** NOTES *** - # The process of event handler creation and registration on interfaces is similar - # to the process of event creation and registration on the system. The - # class for interfaces has been constructed to accept an interface and an - # interface number (this is just to separate the interfaces). - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - interface_events = [] - - for i, iface in enumerate(iface_list): - - # Create interface event handler - iface_event_handler = InterfaceEventHandler(iface, i) - interface_events.append(iface_event_handler) - - # Register interface event handler - iface.RegisterEventHandler(interface_events[i]) - - print('Event handler registered to interface %i ...' % i) - - # Release reference to interface event handler - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface_event_handler - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister interface event handler from each interface - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # from all interfaces that they may be registered to. - for i, iface in enumerate(iface_list): - iface.UnregisterEventHandler(interface_events[i]) - - # Release reference to interface and interface event handlers - del iface - del interface_events - print('Event handler unregistered from interfaces...') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Exposure_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/FileAccess_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/HighDynamicRange.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageChannelStatistics.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageEvents.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Inference.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification.raw b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection.raw b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Logging.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/LookupTable.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Classification b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Classification and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Detection b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Network_Detection and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapCallback.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SaveToAvi.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Sequencer.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SpinUpdate.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger-20343286-0.jpg b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger-20343286-0.jpg deleted file mode 100644 index 17fde7f..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger-20343286-0.jpg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger.py deleted file mode 100644 index b1f8936..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger.py +++ /dev/null @@ -1,516 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.HARDWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger_QuickSpin.py deleted file mode 100644 index 36166cb..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/Examples/Trigger_QuickSpin.py +++ /dev/null @@ -1,421 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.HARDWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/README.txt b/FLIR/old/FLIRcodev4.1/Spinnaker/README.txt deleted file mode 100644 index 42057f3..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/README.txt +++ /dev/null @@ -1,342 +0,0 @@ -============================================================================= -Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5, 3.6, and 3.7. To - download Python, visit https://www.python.org/downloads/. Note that the - Python website defaults to 32-bit interpreters, so if you want a 64-bit - version of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python37\, you would add the following entry - to the PATH variable: - - C:\Python37\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. py -3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.7, run a preinstalled example -using the following: - - ex. py -3.7 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.7, install a supported Pillow using the following command: - - ex. python3.7 -m pip install Pillow==5.2.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.chm b/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.pdf b/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt b/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl b/FLIR/old/FLIRcodev4.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl deleted file mode 100644 index bd0497a..0000000 Binary files a/FLIR/old/FLIRcodev4.1/Spinnaker/spinnaker_python-2.0.0.146-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/Trigger_QuickSpin.py b/FLIR/old/FLIRcodev4.1/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/old/FLIRcodev4.1/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/__init__.py b/FLIR/old/FLIRcodev4.1/build/lib/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/aqctl_flir.py b/FLIR/old/FLIRcodev4.1/build/lib/flir/aqctl_flir.py deleted file mode 100644 index be65248..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/aqctl_flir.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) -print("prepreinit") - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - print("preinit") - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - - - -print(__name__) - -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup).py b/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup_old).py b/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(complex).py b/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(complex).py deleted file mode 100644 index b4167c8..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(complex).py +++ /dev/null @@ -1,202 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - print("Exception Error :(") - pass - - -class FLIR: - """Driver for Novatech 409B 4-channel DDS. - - All output channels are in range [0, 1, 2, 3]. - All frequencies are in Hz. - All phases are in turns. - All amplitudes are in volts. - """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - def close(self): - """Close the serial port.""" - if not self.simulation: - self.port.close() - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def reset(self): - """Hardware reset of 409B.""" - await self._ser_send("R", get_response=False) - await asyncio.sleep(1) - await self.setup() - - async def setup(self): - """Initial setup of 409B.""" - - # Setup the Novatech 409B with the following defaults: - # * command echo off ("E d") - # * external clock ("") 10 MHz sinusoid -1 to +7 dBm - print("setup is working") - await self._ser_send("E d", get_response=False) - await self.set_phase_continuous(True) - await self.set_simultaneous_update(False) - - async def save_state_to_eeprom(self): - """Save current state to EEPROM.""" - await self._ser_send("S") - - async def set_phase_continuous(self, is_continuous): - """Toggle phase continuous mode. - - Sends the "M n" command. This turns off the automatic - clearing of the phase register. In this mode, the phase - register is left intact when a command is performed. - Use this mode if you want frequency changes to remain - phase synchronous, with no phase discontinuities. - - :param is_continuous: True or False - """ - if is_continuous: - await self._ser_send("M n") - else: - await self._ser_send("M a") - - async def set_simultaneous_update(self, simultaneous): - """Set simultaneous update mode. - - Sends the "I m" command. In this mode an update - pulse will not be sent to the DDS chip until - an "I p" command is sent. This is useful when it is - important to change all the outputs to new values - simultaneously. - """ - if simultaneous: - await self._ser_send("I m") - else: - await self._ser_send("I a") - - async def do_simultaneous_update(self): - """Apply update in simultaneous update mode.""" - await self._ser_send("I p") - - async def set_freq(self, ch_no, freq): - """Set frequency of one channel.""" - # Novatech expects MHz - await self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6)) - - async def set_phase(self, ch_no, phase): - """Set phase of one channel.""" - # phase word is required by device - # N is an integer from 0 to 16383. Phase is set to - # N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1] - phase_word = round(phase*16383) - cmd = "P{:d} {:d}".format(ch_no, phase_word) - await self._ser_send(cmd) - - async def set_gain(self, ch_no, volts): - """Set amplitude of one channel.""" - - # due to error in Novatech it doesn't generate an error for - # dac_value>1024, so need to trap. - dac_value = int(math.floor(volts/0.51*1024)) - if dac_value < 0 or dac_value > 1023: - s = "Amplitude out of range {v}".format(v=volts) - raise ValueError(s) - - s = "V{:d} {:d}".format(ch_no, dac_value) - await self._ser_send(s) - - async def get_status(self): - if self.simulation: - return ["00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "00989680 2000 01F5 0000 00000000 00000000 000301", - "80 BC0000 0000 0102 21"] - else: - self.port.ser.reset_input_buffer() - result = [] - await self.port.write(("QUE" + "\r\n").encode()) - for i in range(5): - m = (await self._ser_readline()).rstrip().decode() - result.append(m) - logger.debug("got device status: %s", result) - return result - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(old).py b/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver.py b/FLIR/old/FLIRcodev4.1/build/lib/flir/driver.py deleted file mode 100644 index df94acd..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/driver.py +++ /dev/null @@ -1,179 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - try: - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - self.cam_1 = self.cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - self.cam_1.Init() - ##### cam_2.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - self.cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - self.cam_1.EndAcquisition() - - ## Set up primary camera trigger - # self.cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - # self.cam_1.V3_3Enable.SetValue(True) - - print("Initialization successful...") - except: - print("Error in __init__()") - - def await_trigger(self): - try: - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - #self.cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - #self.cam_1.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - self.cam_1.BeginAcquisition() - - print("Awaiting trigger...") - - self.postpicture() - except: - print("Error in await_trigger()") - - def postpicture(self): - try: - # Acquire images - self.image_1 = self.cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Ensure image completion - if self.image_1.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Save images - filename = 'Image_H%s_M%d_S%g.png' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - self.image_1.Save(filename) - ##### image_2.Save('cam_2.png') - - # Release images - self.image_1.Release() - ##### image_2.Release() - - # end acquisition - self.cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() - print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - except: - print("Error in postpicture()") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev1.py b/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev2.py b/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/old/FLIRcodev4.1/build/lib/flir/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.5.egg b/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.5.egg deleted file mode 100644 index 82bb8da..0000000 Binary files a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.5.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.7.egg b/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.7.egg deleted file mode 100644 index e41e83d..0000000 Binary files a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.7.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.8.egg b/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.8.egg deleted file mode 100644 index 0d82f82..0000000 Binary files a/FLIR/old/FLIRcodev4.1/dist/flir-0.0.0-py3.8.egg and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/doc/Makefile b/FLIR/old/FLIRcodev4.1/doc/Makefile deleted file mode 100644 index 298ea9e..0000000 --- a/FLIR/old/FLIRcodev4.1/doc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/doc/conf.py b/FLIR/old/FLIRcodev4.1/doc/conf.py deleted file mode 100644 index 6cdd72e..0000000 --- a/FLIR/old/FLIRcodev4.1/doc/conf.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - - -import os -import sys -from unittest.mock import Mock - -sys.path.insert(0, os.path.abspath('..')) - -mock_modules = ["asyncserial"] - -for module in mock_modules: - sys.modules[module] = Mock() - -# -- Project information ----------------------------------------------------- - -project = 'FLIR' -copyright = '2019, M-Labs' -author = 'M-Labs' - -# The short X.Y version -version = '1.0' -# The full version, including alpha/beta/rc tags -release = '1.0' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinxarg.ext' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = None - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'FLIRdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'FLIR.tex', 'FLIR Documentation', - 'M-Labs', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'flir', 'FLIR Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'FLIR', 'FLIR Documentation', - author, 'FLIR', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] diff --git a/FLIR/old/FLIRcodev4.1/doc/index.rst b/FLIR/old/FLIRcodev4.1/doc/index.rst deleted file mode 100644 index a92b827..0000000 --- a/FLIR/old/FLIRcodev4.1/doc/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Welcome to Novatech409B's documentation! -======================================== - -API ---- - -.. automodule:: flir.driver - :members: - - -ARTIQ controller ----------------- - -.. argparse:: - :ref: flir.aqctl_flir.get_argparser - :prog: aqctl_flir - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/FLIR/old/FLIRcodev4.1/flir.egg-info/PKG-INFO b/FLIR/old/FLIRcodev4.1/flir.egg-info/PKG-INFO deleted file mode 100644 index bfed401..0000000 --- a/FLIR/old/FLIRcodev4.1/flir.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: flir -Version: 0.0.0 -Summary: UNKNOWN -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/FLIR/old/FLIRcodev4.1/flir.egg-info/SOURCES.txt b/FLIR/old/FLIRcodev4.1/flir.egg-info/SOURCES.txt deleted file mode 100644 index 6a7d17b..0000000 --- a/FLIR/old/FLIRcodev4.1/flir.egg-info/SOURCES.txt +++ /dev/null @@ -1,13 +0,0 @@ -setup.py -flir/__init__.py -flir/aqctl_flir.py -flir/driver(backup_old).py -flir/driver(old).py -flir/driver.py -flir/examplev1.py -flir/examplev2.py -flir.egg-info/PKG-INFO -flir.egg-info/SOURCES.txt -flir.egg-info/dependency_links.txt -flir.egg-info/entry_points.txt -flir.egg-info/top_level.txt \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/flir.egg-info/dependency_links.txt b/FLIR/old/FLIRcodev4.1/flir.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/FLIR/old/FLIRcodev4.1/flir.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/FLIR/old/FLIRcodev4.1/flir.egg-info/entry_points.txt b/FLIR/old/FLIRcodev4.1/flir.egg-info/entry_points.txt deleted file mode 100644 index 62c21bb..0000000 --- a/FLIR/old/FLIRcodev4.1/flir.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -aqctl_flir = flir.aqctl_flir:main - diff --git a/FLIR/old/FLIRcodev4.1/flir.egg-info/top_level.txt b/FLIR/old/FLIRcodev4.1/flir.egg-info/top_level.txt deleted file mode 100644 index c523cfe..0000000 --- a/FLIR/old/FLIRcodev4.1/flir.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -flir diff --git a/FLIR/old/FLIRcodev4.1/flir/__init__.py b/FLIR/old/FLIRcodev4.1/flir/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/FLIR/old/FLIRcodev4.1/flir/__pycache__/__init__.cpython-38.pyc b/FLIR/old/FLIRcodev4.1/flir/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 814003d..0000000 Binary files a/FLIR/old/FLIRcodev4.1/flir/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-37.pyc b/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-37.pyc deleted file mode 100644 index d0f4f64..0000000 Binary files a/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-37.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-38.pyc b/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-38.pyc deleted file mode 100644 index d8b042b..0000000 Binary files a/FLIR/old/FLIRcodev4.1/flir/__pycache__/driver.cpython-38.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/flir/__pycache__/examplev2.cpython-37.pyc b/FLIR/old/FLIRcodev4.1/flir/__pycache__/examplev2.cpython-37.pyc deleted file mode 100644 index 9ee1b6c..0000000 Binary files a/FLIR/old/FLIRcodev4.1/flir/__pycache__/examplev2.cpython-37.pyc and /dev/null differ diff --git a/FLIR/old/FLIRcodev4.1/flir/aqctl_flir.py b/FLIR/old/FLIRcodev4.1/flir/aqctl_flir.py deleted file mode 100644 index be65248..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/aqctl_flir.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# Written by Joe Britton, 2015 - -import argparse -import logging -import sys -import os -import asyncio - -from flir.driver import FLIR -from flir.driver import TriggerType -from sipyco.pc_rpc import simple_server_loop -from sipyco import common_args - - -logger = logging.getLogger(__name__) -print("prepreinit") - -def get_argparser(): - parser = argparse.ArgumentParser( - description="ARTIQ controller for the FLIR camera") - common_args.simple_network_args(parser, 3200) - parser.add_argument( - "-d", "--device", default=None, - help="serial port.") - parser.add_argument( - "--softtrig", default=False, action="store_true", - help="Sets trigger to software. Default is hardware") - parser.add_argument( - "--num", default=1, - help="Sets number of images. Default is hardware") - parser.add_argument( - "--simulation", action="store_true", - help="Put the driver in simulation mode, even if --device is used.") - common_args.verbosity_args(parser) - return parser - - -def main(): - print("preinit") - args = get_argparser().parse_args() - common_args.init_logger_from_args(args) - if os.name == "nt": - asyncio.set_event_loop(asyncio.ProactorEventLoop()) - # if args.device is None: - # print("Starting in Simulation mode...") - # dev = FLIR(args.device if not args.simulation else None) - - print("Software trigger is:",args.softtrig) - triggerset=TriggerType(args.softtrig) - dev = FLIR() - #asyncio.get_event_loop().run_until_complete(dev.setup()) - try: - print("Startup on port",args.port,"successful...") - simple_server_loop( - {"flir": dev}, common_args.bind_address_from_args(args), args.port) - finally: - dev.close() - - - -print(__name__) - -if __name__ == "__main__": - main() diff --git a/FLIR/old/FLIRcodev4.1/flir/driver(backup_old).py b/FLIR/old/FLIRcodev4.1/flir/driver(backup_old).py deleted file mode 100644 index f6295b4..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/driver(backup_old).py +++ /dev/null @@ -1,535 +0,0 @@ -# Written by Joe Britton, 2015 - -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - - error_codes = { - "?0": "Unrecognized Command", - "?1": "Bad Frequency", - "?2": "Bad AM Command", - "?3": "Input line too long", - "?4": "Bad Phase", - "?5": "Bad Time", - "?6": "Bad Mode", - "?7": "Bad Amp", - "?8": "Bad Constant", - "?f": "Bad Byte" - } - - def __init__(self, serial_dev): - if serial_dev is None: - self.simulation = True - else: - self.simulation = False - self.port = asyncserial.AsyncSerial( - serial_dev, - baudrate=19200, - bytesize=8, - parity="N", - stopbits=1, - xonxoff=0) - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - if not self.simulation: - self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print("393-postfunction") - try: - print("395") - result = True - err = False - print("398") - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - print("401") - result &= print_device_info(nodemap_tldevice) - print("403") - # Initialize camera - cam.Init() - print("406") - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - print("409") - # Configure trigger - if configure_trigger(cam) is False: - return False - print("413") - # Acquire images - result &= grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - print("416") - # Reset trigger - result &= reset_trigger(cam) - print("419") - # Deinitialize camera - cam.DeInit() - print("422") - except PySpin.SpinnakerException as ex: - print("424-exception") - print('Error: %s' % ex) - result = False - - - return result - - - def picture(cam): - """ - Run this code to take a single triggered picture! - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return False - print(cam) - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - print("472-prefunction") - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print("Closing camera instance...") #input('Done! Press Enter to exit...') - return result - - - # if __name__ == '__picture__': - # if picture(): - # sys.exit(0) - # else: - # sys.exit(1) - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/flir/driver(old).py b/FLIR/old/FLIRcodev4.1/flir/driver(old).py deleted file mode 100644 index f7b83d4..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/driver(old).py +++ /dev/null @@ -1,715 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self,num): - serial_dev = None - cam=0 - cam_list=0 - self.cameras=0 - result = True - self.num=num - system = PySpin.System.GetInstance() - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - cam_list = system.GetCameras() - self.system = system - self.cam_list = cam_list - self.cam=cam_list[0] - - num_cameras = cam_list.GetSize() - print('Number of cameras detected: %d' % num_cameras) - if num_cameras == 0: - cam_list.Clear() - system.ReleaseInstance() - print('Not enough cameras!') - print("Closing camera instance...") - return False - for i, cam in enumerate(cam_list): - print('Defining camera %d...' % i) - - self.nodemap_tldevice = cam.GetTLDeviceNodeMap() - result &= self.print_device_info(self.nodemap_tldevice) - cam.Init() - self.nodemap = cam.GetNodeMap() - - print("Going back to server now...") - - - - - - - # def picture(self): - # """ - # Run this code to take a single triggered picture! - - # :return: True if successful, False otherwise. - # :rtype: bool - # """ - # result = True - # print(self.cam) - # result &= self.run_single_camera(self.cam) - # for i, cam in enumerate(cam_list): - - # print('Running example for camera %d...' % i) - - # print("472-prefunction") - # result &= run_single_camera(cam) - # print('Camera %d example complete... \n' % i) - # return result - - def picture(self):#run_single_camera(self): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - cam=self.cam - cam.BeginAcquisition() - image_result = cam.GetNextImage(1000) - # Configure trigger - if self.configure_trigger(cam) is False: - return False - - # Acquire images - result &= self.grab_next_image_by_trigger(cam) #acquire_images(cam) THIS IS WHAT I CHANGED TO TRY TO GRAB ONLY ONE IMAGE AT A TIME! - - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - filename = 'Trigger-%d.jpg' % i - - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - # Reset trigger - result &= self.reset_trigger(cam) - cam.EndAcquisition() - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - - return result - - async def _ser_readline(self): - c = await self.port.read(1) - print(c) - r = c - while c != b"\n": - c = await self.port.read(1) - r += c - return r - - async def _ser_send(self, cmd, get_response=True): - """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - if self.simulation: - logger.info("simulation _ser_send(\"%s\")", cmd) - else: - logger.debug("_ser_send(\"%s\")", cmd) - self.port.ser.reset_input_buffer() - await self.port.write((cmd + "\r\n").encode()) - if get_response: - result = (await self._ser_readline()).rstrip().decode() - logger.debug("got response from device: %s", result) - if result != "OK": - errstr = self.error_codes.get(result, "Unrecognized reply") - s = "Erroneous reply from device: {ec}, {ecs}".format( - ec=result, ecs=errstr) - raise ValueError(s) - else: - pass - - async def setup(self): - """Initial setup of FLIR.""" - await self._ser_send("E d", get_response=False) - - - def close(self): - """Close the serial hardware port.""" - # Deinitialize camera - self.cam.DeInit() - del self.cam - self.system.ReleaseInstance() - self.cam_list.Clear() - print("Closing camera instance...") #input('Done! Press Enter to exit...') - # if not self.simulation: - # self.port.close() - - async def ping(self): - try: - stat = await self.get_status() - except asyncio.CancelledError: - raise - except: - return False - # check that version number matches is "21" - if stat[4][20:] == "21": - logger.debug("ping successful") - return True - else: - return False - - - def configure_trigger(self,cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - def grab_next_image_by_trigger(self,cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - def acquire_images(self): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - cam=self.cam - NUM_IMAGES=self.num - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= self.grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - def reset(self): - # Deinitialize camera - self.cam.DeInit() - - self.cam.Init() - - - def reset_trigger(self,cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - - def print_device_info(self,nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - - - def handle_close(self,evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - def display(self): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - cam=self.cam - nodemap=self.nodemap - nodemap_tldevice=self.nodemap_tldevice - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', self.handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - - - - - - - - -############################################################ - - - - - - # async def reset(self): - # """Hardware reset of FLIR.""" - # await self._ser_send("R", get_response=False) - # await asyncio.sleep(1) - # await self.setup() - - # async def setup(self): - # """Initial setup of FLIR.""" - - # await self._ser_send("E d", get_response=False) - - # async def get_status(self): - # if self.simulation: - # return ["00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "00989680 2000 01F5 0000 00000000 00000000 000301", - # "80 BC0000 0000 0102 21"] - # else: - # self.port.ser.reset_input_buffer() - # result = [] - # await self.port.write(("QUE" + "\r\n").encode()) - # for i in range(5): - # m = (await self._ser_readline()).rstrip().decode() - # result.append(m) - # logger.debug("got device status: %s", result) - # return result - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/flir/driver.py b/FLIR/old/FLIRcodev4.1/flir/driver.py deleted file mode 100644 index df94acd..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/driver.py +++ /dev/null @@ -1,179 +0,0 @@ -import math -import logging -import asyncio -import asyncserial -import os -import matplotlib.pyplot as plt -import keyboard -import time -import PySpin -import sys -import time - -NUM_IMAGES = 10 # number of images to grab - -global continue_recording -continue_recording = True - -global trigtype -SOFTWARE = 1 -HARDWARE = 2 -trigtype=SOFTWARE -class TriggerType(): - def __init__(self, softtrig): - global trigtype - if softtrig is True: - trigtype=SOFTWARE - else: - trigtype=HARDWARE - -CHOSEN_TRIGGER = trigtype - -logger = logging.getLogger(__name__) - - -class UnexpectedResponse(Exception): - pass - - -class FLIR: - """Driver for FLIR camera """ - def __init__(self): - try: - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - self.system = PySpin.System.GetInstance() - - # Get camera list - self.cam_list = self.system.GetCameras() - - # Get cameras by serial - self.cam_1 = self.cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - self.cam_1.Init() - ##### cam_2.Init() - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - self.cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - - - #This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - self.cam_1.BeginAcquisition() - self.cam_1.EndAcquisition() - - ## Set up primary camera trigger - # self.cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - # self.cam_1.V3_3Enable.SetValue(True) - - print("Initialization successful...") - except: - print("Error in __init__()") - - def await_trigger(self): - try: - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) - #self.cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - #self.cam_1.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - self.cam_1.BeginAcquisition() - - print("Awaiting trigger...") - - self.postpicture() - except: - print("Error in await_trigger()") - - def postpicture(self): - try: - # Acquire images - self.image_1 = self.cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Ensure image completion - if self.image_1.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Save images - filename = 'Image_H%s_M%d_S%g.png' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) - self.image_1.Save(filename) - ##### image_2.Save('cam_2.png') - - # Release images - self.image_1.Release() - ##### image_2.Release() - - # end acquisition - self.cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() - print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) - except: - print("Error in postpicture()") - - def reset(self): - self.cam_1.DeInit() - self.cam_1.EndAcquisition() - del self.cam - self.cam_list.Clear() - PySpin.System.CloseInstance() - - - - ##################################################################### - # async def _ser_readline(self): - # c = await self.port.read(1) - # print(c) - # r = c - # while c != b"\n": - # c = await self.port.read(1) - # r += c - # return r - - # async def _ser_send(self, cmd, get_response=True): - # """Send a string to the serial port.""" - - # Low-level routine for sending serial commands to device. It sends - # strings and listens for a response terminated by a carriage return. - # example: - # ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz - - # if self.simulation: - # logger.info("simulation _ser_send(\"%s\")", cmd) - # else: - # logger.debug("_ser_send(\"%s\")", cmd) - # self.port.ser.reset_input_buffer() - # await self.port.write((cmd + "\r\n").encode()) - # if get_response: - # result = (await self._ser_readline()).rstrip().decode() - # logger.debug("got response from device: %s", result) - # if result != "OK": - # errstr = self.error_codes.get(result, "Unrecognized reply") - # s = "Erroneous reply from device: {ec}, {ecs}".format( - # ec=result, ecs=errstr) - # raise ValueError(s) - # else: - # pass - - # async def setup(self): - # """Initial setup of FLIR.""" - # await self._ser_send("E d", get_response=False) - - \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/flir/examplev1.py b/FLIR/old/FLIRcodev4.1/flir/examplev1.py deleted file mode 100644 index b1a4896..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/examplev1.py +++ /dev/null @@ -1,53 +0,0 @@ -import PySpin - -# Set camera serial numbers -serial_1 = '20343286' -##### serial_2 = '16276941' - -# Get system -system = PySpin.System.GetInstance() - -# Get camera list -cam_list = system.GetCameras() - -# Get cameras by serial -cam_1 = cam_list.GetBySerial(serial_1) -##### cam_2 = cam_list.GetBySerial(serial_2) - -# Initialize cameras -cam_1.Init() -##### cam_2.Init() - -# Set up primary camera trigger -cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) -cam_1.V3_3Enable.SetValue(True) - -# Set up secondary camera trigger -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) -##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) -##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) -##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - -# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered -cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) -##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -# Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. -##### cam_2.BeginAcquisition() -cam_1.BeginAcquisition() - -# Acquire images -image_1 = cam_1.GetNextImage() -##### image_2 = cam_2.GetNextImage() - -# Save images -image_1.Save('cam_1.png') -##### image_2.Save('cam_2.png') - -# Release images -image_1.Release() -##### image_2.Release() - -# end acquisition -cam_1.EndAcquisition() -##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/flir/examplev2.py b/FLIR/old/FLIRcodev4.1/flir/examplev2.py deleted file mode 100644 index cc3d3ad..0000000 --- a/FLIR/old/FLIRcodev4.1/flir/examplev2.py +++ /dev/null @@ -1,64 +0,0 @@ -import math -import logging -import asyncio -import asyncserial - -import PySpin -import sys - - -def __init__(): - # Set camera serial numbers - serial_1 = '20343286' - ##### serial_2 = '16276941' - - # Get system - system = PySpin.System.GetInstance() - - # Get camera list - cam_list = system.GetCameras() - - # Get cameras by serial - cam_1 = cam_list.GetBySerial(serial_1) - ##### cam_2 = cam_list.GetBySerial(serial_2) - - # Initialize cameras - cam_1.Init() - ##### cam_2.Init() - - # Set up primary camera trigger - cam_1.LineSelector.SetValue(PySpin.LineSelector_Line2) - cam_1.V3_3Enable.SetValue(True) - - # Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered - cam_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - ##### cam_2.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame) - -def await_trigger(): - - # Set up secondary camera trigger - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_Off) - ##### cam_2.TriggerSource.SetValue(PySpin.TriggerSource_Line3) - ##### cam_2.TriggerOverlap.SetValue(PySpin.TriggerOverlap_ReadOut) - ##### cam_2.TriggerMode.SetValue(PySpin.TriggerMode_On) - - # Start acquisition; note that secondary cameras have to be started first so acquisition of primary camera triggers secondary cameras. - ##### cam_2.BeginAcquisition() - cam_1.BeginAcquisition() - -def postpicture(): - # Acquire images - image_1 = cam_1.GetNextImage() - ##### image_2 = cam_2.GetNextImage() - - # Save images - image_1.Save('cam_1.png') - ##### image_2.Save('cam_2.png') - - # Release images - image_1.Release() - ##### image_2.Release() - - # end acquisition - cam_1.EndAcquisition() - ##### cam_2.EndAcquisition() \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/readme.txt b/FLIR/old/FLIRcodev4.1/readme.txt deleted file mode 100644 index 6f15efb..0000000 --- a/FLIR/old/FLIRcodev4.1/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -v1.0 was a failure based on the simplistic code of the manual. Scrapped. -v2.0 was a copy-paste of novatech code with all names and unique functions REMOVED -v3.0 is v2.0 but with the addition of the flir camera functions. Methods are working without the camera. Call "sipyco_rpctool ::1 3200 call picture" to get trigger picture. -v3.1 I dont want to ruin v3.0 stability when hardware testing. v3.1 is hardware testing. Camera initialization and parent class problems. -v3.2 Attempt at initializing camera once and passing object to server. - - -Installation: -1. Install Spinnaker with python3.8 -conda install python3.8 -2. In Flircodevx.x directory, run: - -conda install sipyco -conda install asyncserial -python setup.py build -python setup.py install - -3. Change directories to flir and start server with: - -python aqctl_flir.py - -4. In another anaconda window, in the flir directory, take picture with: - -sipyco_rpctool ::1 3200 call picture \ No newline at end of file diff --git a/FLIR/old/FLIRcodev4.1/setup.py b/FLIR/old/FLIRcodev4.1/setup.py deleted file mode 100644 index 91e6954..0000000 --- a/FLIR/old/FLIRcodev4.1/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="flir", - install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! - packages=find_packages(), - entry_points={ - "console_scripts": [ - "aqctl_flir = flir.aqctl_flir:main", - ], - }, -) diff --git a/FLIR/old/Help/PySpinDoc.chm b/FLIR/old/Help/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/Help/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/Help/PySpinDoc.pdf b/FLIR/old/Help/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/Help/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquireAndDisplay.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Acquisition.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Acquisition.py deleted file mode 100644 index 63b221e..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print 'Image saved at %s' % filename - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquisitionMultipleCamera.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquisitionMultipleCamera.py deleted file mode 100644 index 46bd430..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,333 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print'Camera %d acquisition mode set to continuous...' % i - - # Begin acquiring images - cam.BeginAcquisition() - - print'Camera %d started acquiring images...' % i - - print'' - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print'Camera %d serial number set to %s...' % (i, device_serial_number) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print'Image incomplete with image status %d ... \n' % image_result.GetImageStatus() - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print'Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print'Image saved at %s' % filename - - # Release image - image_result.Release() - print'' - - except PySpin.SpinnakerException as ex: - print'Error: %s' % ex - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print'Printing device information for camera %d... \n' % cam_num - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print'%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print'Device control information not available.' - print'' - - except PySpin.SpinnakerException as ex: - print'Error: %s' % ex - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print'*** DEVICE INFORMATION ***\n' - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print'Running example for all cameras...' - - result = run_multiple_cameras(cam_list) - - print'Example complete... \n' - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/BufferHandling.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/BufferHandling.py deleted file mode 100644 index a48b7da..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print '\n*** CONFIGURING TRIGGER ***\n' - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print 'Unable to disable trigger mode (node retrieval). Aborting...\n' - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print 'Unable to disable trigger mode (enum entry retrieval). Aborting...\n' - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print 'Trigger mode disabled...' - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print 'Unable to set trigger mode (node retrieval). Aborting...' - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print 'Unable to set trigger mode (enum entry retrieval). Aborting...' - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print 'Trigger source set to software...' - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print 'Unable to enable trigger mode (enum entry retrieval). Aborting...\n' - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print 'Trigger mode turned back on...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print 'Unable to execute trigger. Aborting...\n' - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print 'Unable to disable trigger mode (node retrieval). Non-fatal error...\n' - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print 'Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n' - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print 'Trigger mode disabled...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print'%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print '\n*** IMAGE ACQUISITION ***\n' - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (node retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print 'Unable to set Buffer Handling mode (node retrieval). Aborting...\n' - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print 'Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n' - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print 'Unable to set Buffer Count Mode (node retrieval). Aborting...\n' - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print 'Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n' - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print 'Stream Buffer Count Mode set to manual...' - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print 'Unable to set Buffer Count (Integer node retrieval). Aborting...\n' - return False - - # Display Buffer Info - print '\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName() - print 'Default Buffer Count: %d' % buffer_count.GetValue() - print 'Maximum Buffer Count: %d' % buffer_count.GetMax() - - buffer_count.SetValue(NUM_BUFFERS) - - print 'Buffer count now set to: %d' % buffer_count.GetValue() - print '\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS)) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print '\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName() - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print '\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName() - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print '\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName() - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print '\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName() - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print '\nCamera triggered. No image grabbed' - else: - print '\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print 'Image incomplete with image status %s ...\n' % result_image.GetImageStatus() - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print 'Frame ID: %d' % result_image.GetFrameID() - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print 'Image saved at %s' % filename - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print 'Error should occur when grabbing image 1 with handling mode set to NewestOnly' - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print '\n\nRunning example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ChunkData.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ChunkData.py deleted file mode 100644 index 1e2a3d5..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ChunkData.py +++ /dev/null @@ -1,673 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print '\n*** CONFIGURING CHUNK DATA ***\n' - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print 'Chunk mode activated...' - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print 'Unable to retrieve chunk selector. Aborting...\n' - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print 'Enabling entries...' - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print '{} not available'.format(chunk_symbolic_form) - result = False - elif chunk_enable.GetValue() is True: - print '{} enabled'.format(chunk_symbolic_form) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print '{} enabled'.format(chunk_symbolic_form) - else: - print '{} not writable'.format(chunk_symbolic_form) - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print 'Printing chunk data from nodemap...' - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print 'Unable to retrieve chunk data control. Aborting...\n' - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print '{} node not available'.format(feature_display_name) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print '{} {}'.format(feature_display_name, feature_value.ToString()) - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print 'Printing chunk data from image...' - try: - result = True - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print '\tExposure time: {}'.format(exposure_time) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print '\tFrame ID: {}'.format(frame_id) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print '\tGain: {}'.format(gain) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print '\tHeight: {}'.format(height) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print '\tOffset X: {}'.format(offset_x) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print '\tOffset Y: {}'.format(offset_y) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print '\tSequencer set active: {}'.format(sequencer_set_active) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print '\tTimestamp: {}'.format(timestamp) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print '\tWidth: {}'.format(width) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '\n*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - else: - print 'Device control information not available.' - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** IMAGE ACQUISITION ***\n' - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (node retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print 'Image saved at %s' % filename - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result &= display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print 'Unable to retrieve chunk selector. Aborting...\n' - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print 'Disabling entries...' - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print '{} not available'.format(chunk_symbolic_form) - result = False - elif not chunk_enable.GetValue(): - print '{} disabled'.format(chunk_symbolic_form) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print '{} disabled'.format(chunk_symbolic_form) - else: - print '{} not writable'.format(chunk_symbolic_form) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print 'Unable to deactivate chunk mode. Aborting...\n' - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/CounterAndTimer.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/CounterAndTimer.py deleted file mode 100644 index 875ddbb..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print '{}: {}'.format(node_feature.GetName(), feature_string) - - else: - print 'Device control information not available.' - - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print 'Configuring Pulse Width Modulation signal' - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print '\nCamera does not support Counter and Timer Functionality. Aborting...\n' - return False - - if not PySpin.IsWritable(node_counter_selector): - print '\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n' - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print '\nUnable to set Counter Selector (entry retrieval). Aborting...\n' - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print '\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n' - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print '\nUnable to set Counter Event Source (entry retrieval). Aborting...\n' - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print '\nUnable to set Counter Duration (integer retrieval). Aborting...\n' - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print '\nUnable to set Counter Delay (integer retrieval). Aborting...\n' - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print '\nThe duty cycle has been set to {}%'.format(duty_cycle) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print '\nThe pulse rate has been set to {} Hz'.format(pulse_rate) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print '\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n' - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print '\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n' - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print '\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n' - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print '\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n' - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '\nConfiguring GPIO strobe output' - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print '\nUnable to determine camera family. Aborting...\n' - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print '\nUnable to set Line Selector (enumeration retrieval). Aborting...\n' - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print '\nUnable to set Line Selector (entry retrieval). Aborting...\n' - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print '\nUnable to set Line Selector (entry retrieval). Aborting...\n' - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print '\nUnable to set Line Mode (enumeration retrieval). Aborting...\n' - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print '\nUnable to set Line Mode (entry retrieval). Aborting...\n' - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print '\nUnable to set Line Source (enumeration retrieval). Aborting...\n' - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print '\nUnable to set Line Source (entry retrieval). Aborting...\n' - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print '\nUnable to set Line Selector (entry retrieval). Aborting...\n' - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print '\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n' - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '\nConfiguring Exposure and Trigger' - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print '\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n' - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print '\nUnable to set Exposure Auto (entry retrieval). Aborting...\n' - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print '\nUnable to set Exposure Time (float retrieval). Aborting...\n' - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print '\nUnable to disable trigger mode (node retrieval). Aborting...\n' - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print '\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n' - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print '\nUnable to set trigger source (enumeration retrieval). Aborting...\n' - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print '\nUnable to set trigger mode (enum entry retrieval). Aborting...\n' - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print '\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n' - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print '\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n' - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print '\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n' - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '\n*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n' - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n' - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as {}...'.format(device_serial_number) - - print '' - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status {} ...'.format(image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed image {}, width = {}, height = {}'.format(i, width, height) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print 'Image saved at {}'.format(filename) - - # Release image - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print 'Unable to disable trigger mode (node retrieval). Non-fatal error...\n' - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print 'Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n' - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: {}'.format(num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera {}...'.format(i) - - result &= run_single_camera(cam) - print 'Camera {} example complete... \n'.format(i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/DeviceEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/DeviceEvents.py deleted file mode 100644 index 69094e1..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print '\tDevice event %s with ID %i number %i...' % (self.GetDeviceEventName(), - self.GetDeviceEventId(), - self.count) - else: - # Print no information on non-specified event - print '\tDevice event occurred; not %s; ignoring...' % self.event_name - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print '\n*** CONFIGURING DEVICE EVENTS ***\n' - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print 'Unable to retrieve event selector entries. Aborting...' - return False - - entries = node_event_selector.GetEntries() - print 'Enabling event selector entries...' - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print '\t%s: enabled...' % node_entry.GetDisplayName() - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device events handler must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device event handlers. - cam.RegisterEventHandler(device_event_handler) - - print 'Device event handler registered generally...' - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print 'Device event handler registered specifically to EventExposureEnd events...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print 'Device event handler unregistered...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex.message - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n' - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status %s...' % image_result.GetImageStatus() - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %i, width = %i, height = %i' % (i, width, height) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print 'Image saved at %s' % filename - - # Release image - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex.message - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration.py deleted file mode 100644 index ff5a70a..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration.py +++ /dev/null @@ -1,271 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print interface_display_name - - else: - print 'Interface display name not readable' - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print '\tNo devices detected.\n' - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print '\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print 'Number of interfaces detected: %i' % num_ifaces - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i' % num_cams - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - print '\n*** QUERYING INTERFACES ***\n' - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/EnumerationEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/EnumerationEvents.py deleted file mode 100644 index 64454af..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/EnumerationEvents.py +++ /dev/null @@ -1,216 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores camera arrival and removal events on the interfaces. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates a user-defined class: SystemEventHandler. -# This child class allows the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on the system. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, - and InterfaceEventHandler - can be registered to interfaces, the system, or both. - However, in Spinnaker Python, an enumeration event handler must inherit from - InterfaceEventHandler if we want to handle both arrival and removal events. - - *** NOTES *** - Registering an interface event handler to the system is basically the same thing - as registering that event handler to all interfaces, with the added benefit of - not having to manage newly arrived or newly removed interfaces. In order to manually - manage newly arrived or removed interfaces, one would need to implement interface - arrival/removal event handlers, which are not yet supported in the Spinnaker Python API. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It prints out - the device serial number of the camera arriving and the number of - cameras currently connected. The argument is the serial number of - the camera that triggered the arrival event. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print 'System event handler:' - print '\tDevice %i has arrived on the system.' % (serial_number) - print '\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices') - - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It prints out the - device serial number of the camera being removed and the number of cameras - currently connected. The argument is the serial number of the camera that - triggered the removal event. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print 'System event handler:' - print '\tDevice %i was removed from the system.' % (serial_number) - print '\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices') - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print 'EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...' - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print '\nWARNING: GEV Enumeration is disabled.' - print 'If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' \ - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n' - return - print 'GEV enumeration is enabled. Continuing..' - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i' % num_cams - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print 'Number of interfaces detected: %i' % num_ifaces - - print '*** CONFIGURING ENUMERATION EVENTS *** \n' - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Wait for user to plug in and/or remove camera devices - raw_input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print 'Event handler unregistered from system...' - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration_QuickSpin.py deleted file mode 100644 index 0424fa5..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Enumeration_QuickSpin.py +++ /dev/null @@ -1,259 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print interface_display_name - - else: - print 'Interface display name not readable' - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print '\tNo devices detected.\n' - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print '\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print 'Number of interfaces detected: %i' % num_ifaces - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i' % num_cams - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - - print '\n*** QUERYING INTERFACES ***\n' - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Exposure_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Exposure_QuickSpin.py deleted file mode 100644 index e48690d..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** CONFIGURING EXPOSURE ***\n' - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print 'Unable to disable automatic exposure. Aborting...' - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print 'Automatic exposure disabled...' - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print 'Unable to set exposure time. Aborting...' - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print 'Shutter time set to %s us...\n' % exposure_time_to_set - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print 'Unable to enable automatic exposure (node retrieval). Non-fatal error...' - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print 'Automatic exposure enabled...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex.message - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print '*** IMAGE ACQUISITION ***' - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print 'Unable to set acquisition mode to continuous. Aborting...' - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print 'Device serial number retrieved as %s...' % device_serial_number - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print 'Unable to get exposure time. Aborting...' - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d...' % image_result.GetImageStatus() - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print 'Image saved at %s' % filename - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/FileAccess_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/FileAccess_QuickSpin.py deleted file mode 100644 index 25569ca..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import sys -import numpy as np -import os -import argparse - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print 'Imgae incomplete with image status %s' % result_image.GetImageStatus() - else: - print 'Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight()) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print ex - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - print '' - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to delete file!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to open file for writing!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to write to file!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception : %s' % ex - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to close file!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print 'Checking file selector support' - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print 'File selector not supported on device!' - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print 'Width: %s' % cam.Width.GetValue() - print 'Height: %s' % cam.Height.GetValue() - print 'offsetX: %s' % cam.OffsetX.GetValue() - print 'OffsetY: %s' % cam.OffsetY.GetValue() - print 'PixelFormat: %s' % cam.PixelFormat.GetValue() - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print 'Unexpected error grabbing reference image: %s' % ex - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print 'Image saved at %s' % filename - - print '*** UPLOADING IMAGE ***' - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print '\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic() - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print '%s not supported!' % node.GetSymbolic() - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print 'Failed to delete file!' - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print 'Failed to open file!' - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print 'Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print 'Empty Image. No data will be written to camera.' - return False - - if verbose: - print '' - print 'Total bytes to write: %s' % total_bytes_to_write - print 'FileAccessLength: %s' % intermediate_buffer_size - print 'Write iterations: %s' % write_iterations - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print 'Writing data to device' - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print 'Writing stream failed!' - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print 'File Access Offset: %s' % cam.FileAccessOffset.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print 'Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print 'Progress: (%s//%s)' % (i, write_iterations) - else: - print 'Progress: %s' % int((i*100 / write_iterations)) + "%" - - print 'Writing complete' - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to open file for reading!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print 'Failed to read file!' - return False - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print 'Checking file selector support' - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print 'File selector not supported on device!' - return False - - print '*** DOWNLOADING IMAGE ***' - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print '\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic() - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print '%s not supported!' % node.GetSymbolic() - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print '%s - No data available to read!' % node.GetSymbolic() - success = False - continue - - print 'Total data to download: %s' % total_bytes_to_read - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print 'Failed to open file!' - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print 'Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print '' - print 'Total bytes to read: %s' % total_bytes_to_read - print 'FileAccessLength: %s' % intermediate_buffer_size - print 'Write iterations: %s' % read_iterations - - print 'Fetching image from camera.' - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print 'Reading stream failed!' - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print 'Bytes read: %s of %s' % (total_size_read, total_bytes_to_read) - print 'Progress: (%s//%s)' % (i, read_iterations) - else: - print 'Progress: %s' % int((i*100 / read_iterations)) + "%" - - print 'Reading complete' - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print 'Failed to set camera pixel format.' - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print 'Width: %s' % width - print 'Height: %s' % height - print 'OffsetX: %s' % offset_x - print 'OffsetY: %s' % offset_y - print 'PixelFormat: %s' % pixel_format - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print 'Image saved at %s' % filename - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'This example only works when 1 camera is connected.' - raw_input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print "Invalid Argument! Use '--help' to learn available arguments." - raw_input('Done! Press Enter to exit...') - return False - - if not result: - print 'File Access failed' - else: - print 'File Access is successful!' - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/HighDynamicRange.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/HighDynamicRange.py deleted file mode 100644 index a67df50..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/HighDynamicRange.py +++ /dev/null @@ -1,301 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***' - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print'HDR mode turned to', hdr_on - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print'Initialized HDR Image1...' - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print'Initialized HDR Image2...' - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print'Initialized HDR Image3...' - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print'Initialized HDR Image4...' - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print'HDR is not supported! Exiting...' - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print'Error configuring HDR image! Exiting...' - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print'Starting grabbing images...' - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print'Grabbed image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print'Error Retrieving Image: %s' % ex - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print'Error: %s' % ex - result = False - - print'' - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageChannelStatistics.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageChannelStatistics.py deleted file mode 100644 index 51e813f..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print 'Unable to set Pixel Format. Aborting...' - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print 'Unable to set Pixel Format to MONO8. Aborting...' - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print 'Pixel Format set to MONO8 ...' - - cam.BeginAcquisition() - - print 'Acquiring images...' - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print 'SN%s image %d:' % (device_serial_number, i) - print '\tNumber pixel values : %d' % image_stats.num_pixel_values - print '\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max) - print '\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print '\tSave to %s' % filename - print - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print 'End Acquisition' - - plt.close() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageEvents.py deleted file mode 100644 index 084e976..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageEvents.py +++ /dev/null @@ -1,453 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image events - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print 'Image event occurred...' - - # Check if image is incomplete - if image.IsIncomplete(): - print 'Image incomplete with image status %i...' % image.GetImageStatus() - - else: - # Print image info - print 'Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight()) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print 'Image saved at %s\n' % filename - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image event by preparing and - registering an image event handler. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image event handlers are registered to cameras. If there are multiple - # cameras, each camera must have the image event handlers registered to it - # separately. Also, multiple image event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image event handlers are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image events and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print '\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image event handlers from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print 'Image events unregistered...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '*** DEVICE INFORMATION ***' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex.message - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image event handlers - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i' % num_cams - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %i...' % i) - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - raw_input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl.py deleted file mode 100644 index f682c4e..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n' - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print 'Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic() - - else: - print 'Pixel format mono 8 not available...' - - else: - print 'Pixel format not available...' - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print 'Offset X set to %i...' % node_offset_x.GetMin() - - else: - print 'Offset X not available...' - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print 'Offset Y set to %i...' % node_offset_y.GetMin() - - else: - print 'Offset Y not available...' - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print 'Width set to %i...' % node_width.GetValue() - - else: - print 'Width not available...' - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print 'Height set to %i...' % node_height.GetValue() - - else: - print 'Height not available...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print 'Image saved at %s' % filename - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl_QuickSpin.py deleted file mode 100644 index d01f4b9..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n' - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print 'Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic() - - else: - print 'Pixel format not available...' - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print 'Offset X set to %d...' % cam.OffsetX.GetValue() - - else: - print 'Offset X not available...' - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print 'Offset Y set to %d...' % cam.OffsetY.GetValue() - - else: - print 'Offset Y not available...' - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print 'Width set to %i...' % cam.Width.GetValue() - - else: - print 'Width not available...' - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print 'Height set to %i...' % cam.Height.GetValue() - - else: - print 'Height not available...' - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '\n*** DEVICE INFORMATION ***\n' - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex.message - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** IMAGE ACQUISITION ***\n' - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print 'Unable to set acquisition mode to continuous. Aborting...' - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d...' % image_result.GetImageStatus() - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print 'Image saved at %s' % filename - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Inference.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Inference.py deleted file mode 100644 index ad28a11..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print 'Unable to query FileSize. Aborting...' - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print 'No files found, skipping file deletion.' - return True - - print 'Deleting file...' - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print 'Unable to configure FileOperationSelector. Aborting...' - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print 'Unable to configure FileOperationSelector Delete. Aborting...' - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print 'Unable to configure FileOperationExecute. Aborting...' - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print 'Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic() - return False - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print 'Opening file for writing...' - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print 'Unable to configure FileOperationSelector. Aborting...' - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print 'Unable to configure FileOperationSelector Open. Aborting...' - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print 'Unable to configure ptr_file_open_mode. Aborting...' - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print 'Unable to configure FileOperationSelector Write. Aborting...' - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print 'Unable to configure FileOperationExecute. Aborting...' - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print 'Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic() - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print 'FileWriteToFlash is set to true' - else: - ptr_file_write_to_flash.SetValue(False) - print 'FileWriteToFlash is set to false' - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print 'Unable to query/configure FileAccessLength. Aborting...' - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print 'Unable to query FileAccessBuffer. Aborting...' - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print 'Unable to query/configure ptrFileAccessOffset. Aborting...' - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print 'Unable to configure FileOperationSelector. Aborting...' - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print 'Unable to configure FileOperationSelector Write. Aborting...' - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print 'Unable to configure FileOperationExecute. Aborting...' - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print 'Unable to query FileOperationStatus Success. Aborting...' - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print 'Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic() - return False - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print 'Closing file...' - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print 'Unable to configure FileOperationSelector. Aborting...' - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print 'Unable to configure FileOperationSelector Close. Aborting...' - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print 'Unable to configure FileOperationExecute. Aborting...' - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print 'Unable to query FileOperationStatus. Aborting...' - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print 'Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic() - return False - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print '\n*** CONFIGURING FILE SELECTOR ***' - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print 'Unable to configure FileSelector. Aborting...' - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print 'Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...' - return False - - # Set file selector to entry - print 'Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n' - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print 'Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...' - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print 'Problem opening file node. Aborting...' - return False - if not camera_open_file(nodemap): - print 'Problem opening file node. Aborting...' - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print 'Unable to query FileAccessLength. Aborting...' - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print 'Unable to query FileAccessBuffer. Aborting...' - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print 'Unable to query FileAccessOffset. Aborting...' - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print 'Unable to query FileOperationResult. Aborting...' - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print 'Failed to load file path : %s' %file_path + '. Aborting...' - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print 'Empty Image. No data will be written to camera. Aborting...' - return False - - print 'Start uploading %s' %file_path + ' to device...' - - print 'Total bytes to write: %s' % total_bytes_to_write - print 'FileAccessLength: %s' % intermediate_buffer_size - print 'Write iterations: %s' % write_iterations - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print 'Writing data to device...' - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print 'Writing to stream failed. Aborting...' - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print '\nWriting complete' - - if not camera_close_file(nodemap): - print 'Failed to close file!' - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print '\n*** CLEANING UP FILE SELECTOR **' - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print 'Unable to configure FileSelector. Aborting...' - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print 'Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...' - return False - - # Set file Selector entry - print 'Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n' - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print 'Failed to delete existing file for selector entry' - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print 'Unable to find ' + entry_name + ' in ChunkSelector...' - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print 'Enabling ' + entry_name + '...' - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print 'not available' - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print 'enabled' - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print 'enabled' - else: - print 'not writable' - result = False - else: - if not ptr_chunk_enable.GetValue(): - print 'disabled' - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print 'disabled' - else: - print 'not writable' - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print '\n*** CONFIGURING CHUNK DATA ***' - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print 'Unable to active chunk mode. Aborting...' - return False - - ptr_chunk_mode_active.SetValue(True) - print 'Chunk mode activated...' - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print 'Unable to retrieve chunk selector (enum retrieval). Aborting...' - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print "Unable to enable Inference Frame Id chunk data. Aborting..." - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print "Unable to enable Inference Bounding Box chunk data. Aborting..." - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print "Unable to enable Inference Result chunk data. Aborting..." - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print "Unable to enable Inference Confidence chunk data. Aborting..." - return result - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print '\n*** DISABLING CHUNK DATA ***' - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print 'Unable to retrieve chunk selector. Aborting...' - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print 'Unable to disable Inference Frame Id chunk data. Aborting...' - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print 'Unable to disable Inference Bounding Box chunk data. Aborting...' - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print 'Unable to disable Inference Result chunk data. Aborting...' - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print 'Unable to disable Inference Confidence chunk data. Aborting...' - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print 'Unable to deactivate chunk mode. Aborting...' - return False - - ptr_chunk_mode_active.SetValue(False) - print 'Chunk mode deactivated...' - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print 'Unable to disable inference. Aborting...' - return False - - ptr_inference_enable.SetValue(False) - print 'Inference disabled...' - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print 'Printing chunk data from image...' - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print '\tInference Frame ID: %s' % inference_frame_ID - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print '\t Inference Result: %s' %inference_result, - print ' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A" - - inference_confidence = chunk_data.GetInferenceConfidence() - print '\t Inference Confidence: %.6f' %inference_confidence - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print '\n*** IMAGE ACQUISITION ***' - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print 'Unable to configure TriggerMode. Aborting...' - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print 'Unable to query TriggerMode Off. Aborting...' - return False - - print 'Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic() - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print '\n*** CONFIGURING TRIGGER ***' - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print 'Unable to configure TriggerSelector. Aborting...' - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print 'Unable to query TriggerSelector FrameStart. Aborting...' - return False - - print 'Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic() - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print 'Unable to configure TriggerSource. Aborting...' - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print 'Unable to query TriggerSource InferenceReady. Aborting...' - return False - - print 'Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic() - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print 'Unable to configure TriggerMode. Aborting...' - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print 'Unable to query TriggerMode On. Aborting...' - return False - - print 'Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic() - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print '\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***' - else: - print '\n*** DISABLING INFERENCE ***' - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print 'Unable to query InferenceNetworkTypeSelector. Aborting...' - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print 'Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...' - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print 'Inference network type set to' + network_type_string + '...' - - print ('Enabling' if is_enabled else 'Disabling') + ' inference...' - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print 'Unable to enable inference. Aborting...' - return False - - ptr_inference_enable.SetValue(is_enabled) - print 'Inference '+'enabled...' if is_enabled else 'disabled...' - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print '\n*** CONFIGURING TEST PATTERN ***' - else: - print '\n*** DISABLING TEST PATTERN ***' - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print 'Unable to query TestPatternGeneratorSelector. Aborting...' - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print 'Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...' - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print 'TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...' - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print 'Unable to query TestPatternGeneratorSelector Sensor. Aborting...' - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print 'TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...' - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print 'Unable to query TestPattern. Aborting...' - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print 'Unable to query TestPattern InjectedImage. Aborting...' - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print 'TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...' - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print 'Unable to query TestPattern Off. Aborting...' - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print 'TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...' - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print 'Unable to query InjectedWidth. Aborting...' - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print 'Unable to query InjectedHeight. Aborting...' - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print '\n*** IMAGE ACQUISITION ***' - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print 'Unable to set acquisition mode to continuous (node retrieval). Aborting...' - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print "'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting..." - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print 'Device serial number retrieved as %s' %device_serial_number - print '\n' - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print 'Image incomplete with image status %d ...' % result_image.GetImageStatus() - else: - print 'Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight()) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print 'Unexpected exception: %s' % ex - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print 'Checking camera inference support...' - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print 'Inference is not supported on this camera. Aborting...' - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print'Unexpected exception: %s' % ex - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %s\n' % num_cameras - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print 'Running example for camera %d...' % i - result = result | run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification.raw b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification_Daisy.jpg b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection.raw b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Logging.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Logging.py deleted file mode 100644 index 0494d17..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print '--------Log Event Received----------' - print 'Category: %s' % logging_event_data.GetCategoryName() - print 'Priority Value: %s' % logging_event_data.GetPriority() - print 'Priority Name: %s' % logging_event_data.GetPriorityName() - print 'Timestamp: %s' % logging_event_data.GetTimestamp() - print 'NDC: %s' % logging_event_data.GetNDC() - print 'Thread: %s' % logging_event_data.GetThreadName() - print 'Message: %s' % logging_event_data.GetLogMessage() - print '------------------------------------\n' - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i' % num_cams - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/LookupTable.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/LookupTable.py deleted file mode 100644 index 01375c9..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/LookupTable.py +++ /dev/null @@ -1,439 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print "Unable to get {} ({} {} retrieval failed.)".format(node, name, node) - print "The {} may not be available on all camera models...".format(node) - print "Please try a Blackfly S camera." - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: return True if successful, False otherwise - :rtype: bool - """ - result = True - print "***CONFIGURING LOOKUP TABLES***\n" - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print "Lookup table selector set to LUT 1...\n" - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print "\tMaximum Range: {}".format(max_range) - - # Calculate increment - increment = max_range / 512 - print "\tIncrement: {}".format(increment) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print "All lookup table values set...\n" - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print "Lookup tables enabled...\n" - - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: return True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print "Unable to disable lookup tables. Non-fatal error...\n" - return False - - lut_enable.SetValue(False) - print "Lookup tables disabled...\n" - - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: return True if successful, False otherwise - :rtype: bool - """ - result = True - print "*** DEVICE INFORMATION ***\n" - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print "{}: {}".format(node_feature.GetName(), feature_string) - - else: - print "Device control information not available." - - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: return True if successful, False otherwise - :rtype: bool - """ - result = True - print "*** IMAGE ACQUISITION ***\n" - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print "Unable to set acquisition mode to continuous (node retrieval). Aborting...\n" - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print "Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n" - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print "Acquisition mode set to continuous...\n" - - # Begin acquiring images - cam.BeginAcquisition() - print "Acquiring images...\n" - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print "Device serial number retrieved as {}...".format(device_serial_number) - - print "" - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print "Image incomplete with image status {}...".format(image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print "Grabbed image {}, width = {}, height = {}".format(i, width, height) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print "Image saved at {}".format(filename) - - # Release image - image_result.Release() - print "" - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: return True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print "Error: {}".format(ex) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: return True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print "Unable to write to current directory. Please check permissions.\n" - raw_input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print "Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print "Number of cameras detected: {}\n".format(num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print "Not enough cameras!\n" - raw_input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print "Running example for camera {}...\n".format(i) - - result &= run_single_camera(cam) - print "Camera {} example complete...\n".format(i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Classification b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Classification and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Detection b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Network_Detection and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapCallback.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapCallback.py deleted file mode 100644 index 11bb576..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print 'Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue() - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print 'Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue() - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print '\n*** CONFIGURING CALLBACKS ***\n' - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print 'Unable to disable automatic gain (node retrieval). Aborting...' - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print 'Unable to disable automatic gain (enum entry retrieval). Aborting...' - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print 'Automatic gain disabled...' - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print 'Unable to retrieve height. Aborting...\n' - return False - - print 'Height ready...' - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print 'Height callback registered...' - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print 'Unable to retrieve gain. Aborting...\n' - return False - - print 'Gain ready...' - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print 'Gain callback registered...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n***CHANGE HEIGHT & GAIN ***\n' - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print 'Unable to retrieve height. Aborting...' - return False - - height_to_set = node_height.GetMax() - - print 'Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print 'Unable to retrieve gain...' - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print 'Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print 'Callbacks deregistered...' - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print 'Unable to enable automatic gain (node retrieval). Aborting...' - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print 'Unable to enable automatic gain (enum entry retrieval). Aborting...' - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print 'Automatic gain disabled...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo.py deleted file mode 100644 index 4c92dce..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print '%s%s' % (ind, text) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print '\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n' - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print '*** PRINTING TL STREAM NODEMAP ***\n' - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print '*** PRINTING GENICAM NODEMAP ***\n' - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 7fdc063..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print 'Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString() - - else: - print 'Device serial number: unavailable' - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print 'Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString() - else: - print 'Device vendor name: unavailable' - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print 'Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString() - else: - print 'Device display name: unavailable' - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print 'Stream ID: %s' % cam.TLStream.StreamID.ToString() - else: - print 'Stream ID: unavailable' - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print 'Stream type: %s' % cam.TLStream.StreamType.ToString() - else: - print 'Stream type: unavailable' - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print 'Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString() - else: - print 'Interface display name: unavailable' - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print 'Interface ID: %s' % interface.TLInterface.InterfaceID.ToString() - else: - print 'Interface ID: unavailable' - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print 'Interface type: %s' % interface.TLInterface.InterfaceType.ToString() - else: - print 'Interface type: unavailable' - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print 'Exposure time: %s' % cam.ExposureTime.ToString() - else: - print 'Exposure time: unavailable' - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print 'Black level: %s' % cam.BlackLevel.ToString() - else: - print 'Black level: unavailable' - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print 'Height: %s' % cam.Height.ToString() - else: - print 'Height: unavailable' - result = False - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print 'Number of cameras detected: %i \n' % num_cams - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('\nDone! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print 'Number of interfaces detected: %i \n' % num_ifaces - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print '\n*** PRINTING INTERFACE INFORMATION ***\n' - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print '\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n' - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print '\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n' - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print '\n*** PRINTING GENICAM INFORMATION ***\n' - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - raw_input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SaveToAvi.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SaveToAvi.py deleted file mode 100644 index 338b834..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print '*** CREATING VIDEO ***' - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print 'Unable to retrieve frame rate. Aborting...' - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print 'Frame rate to be set to %d...' % framerate_to_set - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print 'Error: Unknown AviType. Aborting...' - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print 'Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print 'Appended image %d...' % i - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print 'Video saved at %s.avi' % avi_filename - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '\n*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d...' % image_result.GetImageStatus() - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected:', num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Sequencer.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Sequencer.py deleted file mode 100644 index 1f8e97c..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print 'Unable to get {} ({} {} retrieval failed.)'.format(node, name, node) - print 'The {} may not be available on all camera models...'.format(node) - print 'Please try a Blackfly S camera.' - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** CONFIGURING SEQUENCER ***\n' - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print 'Sequencer mode disabled...' - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print 'Automatic exposure disabled...' - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print 'Automatic gain disabled...' - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print 'Sequencer configuration mode enabled...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print 'Setting state {}...'.format(sequence_number) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = (width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print '\tWidth set to {}...'.format(node_width.GetValue()) - - else: - print '\tUnable to set width; width for sequencer not available on all camera models...' - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = (height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print '\tHeight set to %d...' % node_height.GetValue() - - else: - print '\tUnable to set height; height for sequencer not available on all camera models...' - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print '\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue()) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print '\tGain set to {0:.5f}...'.format(node_gain.GetValue()) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print '\tTrigger source set to start of frame...' - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print 'Unable to select next state. Aborting...\n' - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print '\tNext state set to {}...'.format(node_sequencer_set_next.GetValue()) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print 'Unable to save state. Aborting...\n' - return False - - node_sequencer_set_save.Execute() - - print 'Current state saved...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print 'Sequencer configuration mode disabled...' - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print 'Sequencer mode enabled...' - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print 'Sequencer configuration not valid. Aborting...\n' - return False - - print 'Sequencer configuration valid...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print 'Turning off sequencer mode...' - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print 'Turning automatic exposure back on...' - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print 'Turning automatic gain mode back on...\n' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print '{}: {}'.format(node_feature.GetName(), feature_string) - - else: - print 'Device control information not available.' - - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as {}...'.format(device_serial_number) - - print '' - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print 'Image incomplete with image status {}...'.format(image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed image {}, width = {}, height = {}'.format(i, width, height) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print 'Image saved at {}'.format(filename) - - # Release image - image_result.Release() - print '' - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print 'Unable to retrieve maximum width. Aborting...\n' - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print 'Unable to retrieve maximum height. Aborting...\n' - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print 'Unable to retrieve maximum exposure time. Aborting...\n' - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print 'Unable to retrieve maximum gain. Aborting...\n' - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: {}'.format(ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: {}\n'.format(num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera {}...\n'.format(i) - - result &= run_single_camera(cam) - print 'Camera {} example complete...\n'.format(i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SpinUpdate.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SpinUpdate.py deleted file mode 100644 index deda1ef..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update. - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print 'Action: %s' % action - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator. - :type message: str - :rtype: None - """ - print 'Message: %s' % message - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger.py deleted file mode 100644 index 6c4a60b..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger.py +++ /dev/null @@ -1,519 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print '*** CONFIGURING TRIGGER ***\n' - - print 'Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n' - print 'If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n' - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print 'Software trigger chosen ...' - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print 'Hardware trigger chose ...' - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print 'Unable to disable trigger mode (node retrieval). Aborting...' - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print 'Unable to disable trigger mode (enum entry retrieval). Aborting...' - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print 'Trigger mode disabled...' - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print 'Unable to get trigger selector (node retrieval). Aborting...' - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print 'Unable to set trigger selector (enum entry retrieval). Aborting...' - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print 'Trigger selector set to frame start...' - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print 'Unable to get trigger source (node retrieval). Aborting...' - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print 'Unable to set trigger source (enum entry retrieval). Aborting...' - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print 'Trigger source set to software...' - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print 'Unable to set trigger source (enum entry retrieval). Aborting...' - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print 'Trigger source set to hardware...' - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print 'Unable to enable trigger mode (enum entry retrieval). Aborting...' - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print 'Trigger mode turned back on...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - raw_input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print 'Unable to execute trigger. Aborting...' - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print 'Use the hardware to trigger image acquisition.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print 'Unable to set acquisition mode to continuous (enum retrieval). Aborting...' - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print 'Unable to set acquisition mode to continuous (entry retrieval). Aborting...' - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print 'Image saved at %s\n' % filename - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print 'Unable to disable trigger mode (node retrieval). Aborting...' - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print 'Unable to disable trigger mode (enum entry retrieval). Aborting...' - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print 'Trigger mode disabled...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print 'Unable to write to current directory. Please check permissions.' - raw_input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger_QuickSpin.py deleted file mode 100644 index c409662..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python2/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** CONFIGURING TRIGGER ***\n' - - print 'Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n' - print 'If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n' - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print 'Software trigger chosen...' - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print 'Hardware trigger chosen...' - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print 'Unable to disable trigger mode (node retrieval). Aborting...' - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print 'Trigger mode disabled...' - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print 'Unable to get trigger selector (node retrieval). Aborting...' - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print 'Trigger selector set to frame start...' - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print 'Unable to get trigger source (node retrieval). Aborting...' - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print 'Trigger source set to software...' - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print 'Trigger source set to hardware...' - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print 'Trigger mode turned back on...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - raw_input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print 'Unable to execute trigger. Aborting...' - return False - - cam.TriggerSoftware.Execute() - - # NOTE: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print 'Use the hardware to trigger image acquisition.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print '*** IMAGE ACQUISITION ***\n' - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print 'Unable to set acquisition mode to continuous. Aborting...' - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print 'Acquisition mode set to continuous...' - - # Begin acquiring images - cam.BeginAcquisition() - - print 'Acquiring images...' - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print 'Device serial number retrieved as %s...' % device_serial_number - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print 'Image incomplete with image status %d ...' % image_result.GetImageStatus() - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print 'Grabbed Image %d, width = %d, height = %d' % (i, width, height) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print 'Image saved at %s\n' % filename - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print 'Unable to disable trigger mode (node retrieval). Aborting...' - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print 'Trigger mode disabled...' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print '*** DEVICE INFORMATION ***\n' - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print '%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable') - - else: - print 'Device control information not available.' - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print 'Error: %s' % ex - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print 'Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print 'Number of cameras detected: %d' % num_cameras - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print 'Not enough cameras!' - raw_input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print 'Running example for camera %d...' % i - - result &= run_single_camera(cam) - print 'Camera %d example complete... \n' % i - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - raw_input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquireAndDisplay.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquireAndDisplay.py deleted file mode 100644 index 2aee556..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquireAndDisplay.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# This AcquireAndDisplay.py shows how to get the image data, and then display images in a GUI. -# This example relies on information provided in the ImageChannelStatistics.py example. -# -# This example demonstrates how to display images represented as numpy arrays. -# Currently, this program is limited to single camera use. -# NOTE: keyboard and matplotlib must be installed on Python interpreter prior to running this example. - -import os -import PySpin -import matplotlib.pyplot as plt -import sys -import keyboard -import time - -global continue_recording -continue_recording = True - - -def handle_close(evt): - """ - This function will close the GUI when close event happens. - - :param evt: Event that occurs when the figure closes. - :type evt: Event - """ - - global continue_recording - continue_recording = False - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function continuously acquires images from a device and display them in a GUI. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - global continue_recording - - sNodemap = cam.GetTLStreamNodeMap() - - # Change bufferhandling mode to NewestOnly - node_bufferhandling_mode = PySpin.CEnumerationPtr(sNodemap.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(node_bufferhandling_mode) or not PySpin.IsWritable(node_bufferhandling_mode): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve entry node from enumeration node - node_newestonly = node_bufferhandling_mode.GetEntryByName('NewestOnly') - if not PySpin.IsAvailable(node_newestonly) or not PySpin.IsReadable(node_newestonly): - print('Unable to set stream buffer handling mode.. Aborting...') - return False - - # Retrieve integer value from entry node - node_newestonly_mode = node_newestonly.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_bufferhandling_mode.SetIntValue(node_newestonly_mode) - - print('*** IMAGE ACQUISITION ***\n') - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Close program - print('Press enter to close the program..') - - # Figure(1) is default so you can omit this line. Figure(0) will create a new window every time program hits this line - fig = plt.figure(1) - - # Close the GUI when close event happens - fig.canvas.mpl_connect('close_event', handle_close) - - # Retrieve and display images - while(continue_recording): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Draws an image on the current figure - plt.imshow(image_data, cmap='gray') - - # Interval in plt.pause(interval) determines how fast the images are displayed in a GUI - # Interval is in seconds. - plt.pause(0.001) - - # Clear current reference of a figure. This will improve display speed significantly - plt.clf() - - # If user presses enter, close the program - if keyboard.is_pressed('ENTER'): - print('Program is closing...') - - # Close figure - plt.close('all') - input('Done! Press Enter to exit...') - continue_recording=False - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Acquisition.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Acquisition.py deleted file mode 100644 index 3459923..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Acquisition.py +++ /dev/null @@ -1,372 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Acquisition.py shows how to acquire images. It relies on -# information provided in the Enumeration example. Also, check out the -# ExceptionHandling and NodeMapInfo examples if you haven't already. -# ExceptionHandling shows the handling of standard and Spinnaker exceptions -# while NodeMapInfo explores retrieving information from various node types. -# -# This example touches on the preparation and cleanup of a camera just before -# and just after the acquisition of images. Image retrieval and conversion, -# grabbing image data, and saving images are all covered as well. -# -# Once comfortable with Acquisition, we suggest checking out -# AcquisitionMultipleCamera, NodeMapCallback, or SaveToAvi. -# AcquisitionMultipleCamera demonstrates simultaneously acquiring images from -# a number of cameras, NodeMapCallback serves as a good introduction to -# programming with callbacks and events, and SaveToAvi exhibits video creation. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Acquisition-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Acquisition-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquisitionMultipleCamera.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquisitionMultipleCamera.py deleted file mode 100644 index 6fd7cc8..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/AcquisitionMultipleCamera.py +++ /dev/null @@ -1,334 +0,0 @@ -# ============================================================================ -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. - -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================ -# -# AcquisitionMultipleCamera.py shows how to capture images from -# multiple cameras simultaneously. It relies on information provided in the -# Enumeration, Acquisition, and NodeMapInfo examples. -# -# This example reads similarly to the Acquisition example, -# except that loops are used to allow for simultaneous acquisitions. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - -def acquire_images(cam_list): - """ - This function acquires and saves 10 images from each device. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Prepare each camera to acquire images - # - # *** NOTES *** - # For pseudo-simultaneous streaming, each camera is prepared as if it - # were just one, but in a loop. Notice that cameras are selected with - # an index. We demonstrate pseduo-simultaneous streaming because true - # simultaneous streaming would require multiple process or threads, - # which is too complex for an example. - # - - for i, cam in enumerate(cam_list): - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(cam.GetNodeMap().GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval; camera %d). Aborting... \n' % i) - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry \'continuous\' retrieval %d). \ - Aborting... \n' % i) - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Camera %d acquisition mode set to continuous...' % i) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Camera %d started acquiring images...' % i) - - print() - - # Retrieve, convert, and save images for each camera - # - # *** NOTES *** - # In order to work with simultaneous camera streams, nested loops are - # needed. It is important that the inner loop be the one iterating - # through the cameras; otherwise, all images will be grabbed from a - # single camera before grabbing any images from another. - for n in range(NUM_IMAGES): - for i, cam in enumerate(cam_list): - try: - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(cam.GetTLDeviceNodeMap().GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Camera %d serial number set to %s...' % (i, device_serial_number)) - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ... \n' % image_result.GetImageStatus()) - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Camera %d grabbed image %d, width = %d, height = %d' % (i, n, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'AcquisitionMultipleCamera-%s-%d.jpg' % (device_serial_number, n) - else: - filename = 'AcquisitionMultipleCamera-%d-%d.jpg' % (i, n) - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition for each camera - # - # *** NOTES *** - # Notice that what is usually a one-step process is now two steps - # because of the additional step of selecting the camera. It is worth - # repeating that camera selection needs to be done once per loop. - # - # It is possible to interact with cameras through the camera list with - # GetByIndex(); this is an alternative to retrieving cameras as - # CameraPtr objects that can be quick and easy for small tasks. - for cam in cam_list: - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap, cam_num): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :param cam_num: Camera number. - :type nodemap: INodeMap - :type cam_num: int - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('Printing device information for camera %d... \n' % cam_num) - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - print() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -def run_multiple_cameras(cam_list): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam_list: List of cameras - :type cam_list: CameraList - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve transport layer nodemaps and print device information for - # each camera - # *** NOTES *** - # This example retrieves information from the transport layer nodemap - # twice: once to print device information and once to grab the device - # serial number. Rather than caching the nodem#ap, each nodemap is - # retrieved both times as needed. - print('*** DEVICE INFORMATION ***\n') - - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device information - result &= print_device_info(nodemap_tldevice, i) - - # Initialize each camera - # - # *** NOTES *** - # You may notice that the steps in this function have more loops with - # less steps per loop; this contrasts the AcquireImages() function - # which has less loops but more steps per loop. This is done for - # demonstrative purposes as both work equally well. - # - # *** LATER *** - # Each camera needs to be deinitialized once all images have been - # acquired. - for i, cam in enumerate(cam_list): - - # Initialize camera - cam.Init() - - # Acquire images on all cameras - result &= acquire_images(cam_list) - - # Deinitialize each camera - # - # *** NOTES *** - # Again, each camera must be deinitialized separately by first - # selecting the camera and then deinitializing it. - for cam in cam_list: - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on all cameras - print('Running example for all cameras...') - - result = run_multiple_cameras(cam_list) - - print('Example complete... \n') - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/BufferHandling.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/BufferHandling.py deleted file mode 100644 index 587038f..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/BufferHandling.py +++ /dev/null @@ -1,493 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# BufferHandling.py shows how the different buffer handling modes work. -# It relies on information provided in the Acquisition and Trigger examples. -# -# Buffer handling determines the ordering at which images are retrieved, and -# what occurs when an image is transmitted while the buffer is full. There are -# four different buffer handling modes available; NewestFirst, NewestOnly, -# OldestFirst and OldestFirstOverwrite. -# -# This example explores retrieving images in a set pattern; triggering the camera -# while not retrieving an image (letting the buffer fill up), and retrieving -# images while not triggering. We cycle through the different buffer handling -# modes to see which images are retrieved, confirming their identites via their -# Frame ID values. - -import os -import PySpin -import time -import sys - -# Total number of buffers -NUM_BUFFERS = 3 -# Number of triggers -NUM_TRIGGERS = 6 -# Total number of loops -NUM_LOOPS = 9 - -def configure_trigger(nodemap): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the trigger. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING TRIGGER ***\n') - - # Ensure trigger mode off - # - # *** NOTES *** - # The trigger must be disabled in order to configure the - # trigger source. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...') - - # Set trigger source to software - trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(trigger_source) or not PySpin.IsWritable(trigger_source): - print('Unable to set trigger mode (node retrieval). Aborting...') - return False - - trigger_source_software = PySpin.CEnumEntryPtr(trigger_source.GetEntryByName('Software')) - if not PySpin.IsAvailable(trigger_source_software) or not PySpin.IsReadable(trigger_source_software): - print('Unable to set trigger mode (enum entry retrieval). Aborting...') - return False - - trigger_source.SetIntValue(trigger_source_software.GetValue()) - print('Trigger source set to software...') - - # Turn trigger mode on - trigger_mode_on = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('On')) - if not PySpin.IsAvailable(trigger_mode_on) or not PySpin.IsReadable(trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def grab_next_image_by_trigger(nodemap): - """ - This function retrieves a single image using the trigger. In this example, - only a single image is captured and made available for acquisition - as such, - attempting to acquire two images for a single trigger execution would cause - the example to hang. This is different from other examples, whereby a - constant stream of images are being captured and made available for image - acquisition. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Execute software trigger - software_trigger_command = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(software_trigger_command) or not PySpin.IsWritable(software_trigger_command): - print('Unable to execute trigger. Aborting...\n') - return False - - software_trigger_command.Execute() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Turn trigger mode back off - # - # *** NOTES *** - # Once all images have been captured, turn trigger mode back off to - # restore the camera to a clean state. - trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(trigger_mode) or not PySpin.IsWritable(trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - return False - - trigger_mode_off = PySpin.CEnumEntryPtr(trigger_mode.GetEntryByName('Off')) - if not PySpin.IsAvailable(trigger_mode_off) or not PySpin.IsReadable(trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - return False - - trigger_mode.SetIntValue(trigger_mode_off.GetValue()) - print('Trigger mode disabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** DEVICE INFORMATION ***\n') - - # Retrieve and display Device Information - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function cycles through the four different buffer handling modes. - It saves three images for three of the buffer handling modes - (NewestFirst, OldestFirst, and OldestFirstOverwrite). For NewestOnly, - it saves one image. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - print('\n*** IMAGE ACQUISITION ***\n') - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve Stream Parameters device nodemap - s_node_map = cam.GetTLStreamNodeMap() - - # Retrieve Buffer Handling Mode Information - handling_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferHandlingMode')) - if not PySpin.IsAvailable(handling_mode) or not PySpin.IsWritable(handling_mode): - print('Unable to set Buffer Handling mode (node retrieval). Aborting...\n') - return False - - handling_mode_entry = PySpin.CEnumEntryPtr(handling_mode.GetCurrentEntry()) - if not PySpin.IsAvailable(handling_mode_entry) or not PySpin.IsReadable(handling_mode_entry): - print('Unable to set Buffer Handling mode (Entry retrieval). Aborting...\n') - return False - - # Set stream buffer Count Mode to manual - stream_buffer_count_mode = PySpin.CEnumerationPtr(s_node_map.GetNode('StreamBufferCountMode')) - if not PySpin.IsAvailable(stream_buffer_count_mode) or not PySpin.IsWritable(stream_buffer_count_mode): - print('Unable to set Buffer Count Mode (node retrieval). Aborting...\n') - return False - - stream_buffer_count_mode_manual = PySpin.CEnumEntryPtr(stream_buffer_count_mode.GetEntryByName('Manual')) - if not PySpin.IsAvailable(stream_buffer_count_mode_manual) or not PySpin.IsReadable(stream_buffer_count_mode_manual): - print('Unable to set Buffer Count Mode entry (Entry retrieval). Aborting...\n') - return False - - stream_buffer_count_mode.SetIntValue(stream_buffer_count_mode_manual.GetValue()) - print('Stream Buffer Count Mode set to manual...') - - # Retrieve and modify Stream Buffer Count - buffer_count = PySpin.CIntegerPtr(s_node_map.GetNode('StreamBufferCountManual')) - if not PySpin.IsAvailable(buffer_count) or not PySpin.IsWritable(buffer_count): - print('Unable to set Buffer Count (Integer node retrieval). Aborting...\n') - return False - - # Display Buffer Info - print('\nDefault Buffer Handling Mode: %s' % handling_mode_entry.GetDisplayName()) - print('Default Buffer Count: %d' % buffer_count.GetValue()) - print('Maximum Buffer Count: %d' % buffer_count.GetMax()) - - buffer_count.SetValue(NUM_BUFFERS) - - print('Buffer count now set to: %d' % buffer_count.GetValue()) - print('\nCamera will be triggered %d times in a row before %d images will be retrieved' % (NUM_TRIGGERS,(NUM_LOOPS-NUM_TRIGGERS))) - - for x in range (0, 4): - if x == 0: - handling_mode_entry = handling_mode.GetEntryByName('NewestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 1: - handling_mode_entry = handling_mode.GetEntryByName('NewestOnly') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 2: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirst') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - elif x == 3: - handling_mode_entry = handling_mode.GetEntryByName('OldestFirstOverwrite') - handling_mode.SetIntValue(handling_mode_entry.GetValue()) - print('\n\nBuffer Handling Mode has been set to %s' % handling_mode_entry.GetDisplayName()) - - # Begin capturing images - cam.BeginAcquisition() - - # Sleep for one second; only necessary when using non-BFS/ORX cameras on startup - if x == 0: - time.sleep(1) - - try: - # Software Trigger the camera then save images - for loop_cnt in range (0, NUM_LOOPS): - if loop_cnt < NUM_TRIGGERS: - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap) - print('\nCamera triggered. No image grabbed') - else: - print('\nNo trigger. Grabbing image %d' %(loop_cnt-NUM_TRIGGERS)) - result_image = cam.GetNextImage(500) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %s ...\n' % result_image.GetImageStatus()) - - if loop_cnt >= NUM_TRIGGERS: - # Retrieve Frame ID - print('Frame ID: %d' % result_image.GetFrameID()) - - # Create a unique filename - if device_serial_number: - filename = '%s-%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),device_serial_number, (loop_cnt-NUM_TRIGGERS)) - else: - filename = '%s-%d.jpg' % (handling_mode_entry.GetSymbolic(),(loop_cnt-NUM_TRIGGERS)) - - # Save image - result_image.Save(filename) - print('Image saved at %s' % filename) - - # Release image - result_image.Release() - - # To control the framerate, have the application pause for 250ms. - time.sleep(0.25) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - if handling_mode_entry.GetSymbolic() == 'NewestOnly': - print('Error should occur when grabbing image 1 with handling mode set to NewestOnly') - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_trigger(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print('\n\nRunning example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - - - diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ChunkData.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ChunkData.py deleted file mode 100644 index 4214d69..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ChunkData.py +++ /dev/null @@ -1,674 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ChunkData.py shows how to get chunk data on an image, either from -# the nodemap or from the image itself. It relies on information provided in -# the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure samples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Chunk data provides information on various traits of an image. This includes -# identifiers such as frame ID, properties such as black level, and more. This -# information can be acquired from either the nodemap or the image itself. -# -# It may be preferable to grab chunk data from each individual image, as it -# can be hard to verify whether data is coming from the correct image when -# using the nodemap. This is because chunk data retrieved from the nodemap is -# only valid for the current image; when GetNextImage() is called, chunk data -# will be updated to that of the new current image. -# - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -# Use the following class and global variable to select whether -# chunk data is displayed from the image or the nodemap. -class ChunkDataTypes: - IMAGE = 1 - NODEMAP = 2 - - -CHOSEN_CHUNK_DATA_TYPE = ChunkDataTypes.NODEMAP - - -def configure_chunk_data(nodemap): - """ - This function configures the camera to add chunk data to each image. It does - this by enabling each type of chunk data before enabling chunk data mode. - When chunk data is turned on, the data is made available in both the nodemap - and each image. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - print('\n*** CONFIGURING CHUNK DATA ***\n') - - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if PySpin.IsAvailable(chunk_mode_active) and PySpin.IsWritable(chunk_mode_active): - chunk_mode_active.SetValue(True) - - print('Chunk mode activated...') - - # Enable all types of chunk data - # - # *** NOTES *** - # Enabling chunk data requires working with nodes: "ChunkSelector" - # is an enumeration selector node and "ChunkEnable" is a boolean. It - # requires retrieving the selector node (which is of enumeration node - # type), selecting the entry of the chunk data to be enabled, retrieving - # the corresponding boolean, and setting it to be true. - # - # In this example, all chunk data is enabled, so these steps are - # performed in a loop. Once this is complete, chunk mode still needs to - # be activated. - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Enabling entries...') - - # Iterate through our list and select each entry node to enable - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_str = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Enable the boolean, thus enabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_str)) - result = False - elif chunk_enable.GetValue() is True: - print('{} enabled'.format(chunk_str)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(True) - print('{} enabled'.format(chunk_str)) - else: - print('{} not writable'.format(chunk_str)) - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_nodemap(nodemap): - """ - This function displays all available chunk data by looping through the - chunk data category node on the nodemap. - - :param nodemap: Device nodemap to retrieve images from. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - print('Printing chunk data from nodemap...') - try: - result = True - # Retrieve chunk data information nodes - # - # *** NOTES *** - # As well as being written into the payload of the image, chunk data is - # accessible on the GenICam nodemap. When chunk data is enabled, it is - # made available from both the image payload and the nodemap. - chunk_data_control = PySpin.CCategoryPtr(nodemap.GetNode('ChunkDataControl')) - if not PySpin.IsAvailable(chunk_data_control) or not PySpin.IsReadable(chunk_data_control): - print('Unable to retrieve chunk data control. Aborting...\n') - return False - - features = chunk_data_control.GetFeatures() - - # Iterate through children - for feature in features: - feature_node = PySpin.CNodePtr(feature) - feature_display_name = '\t{}:'.format(feature_node.GetDisplayName()) - - if not PySpin.IsAvailable(feature_node) or not PySpin.IsReadable(feature_node): - print('{} node not available'.format(feature_display_name)) - result &= False - continue - # Print node type value - # - # *** NOTES *** - # All nodes can be cast as value nodes and have their information - # retrieved as a string using the ToString() method. This is much - # easier than dealing with each individual node type. - else: - feature_value = PySpin.CValuePtr(feature) - print('{} {}'.format(feature_display_name, feature_value.ToString())) - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def display_chunk_data_from_image(image): - """ - This function displays a select amount of chunk data from the image. Unlike - accessing chunk data via the nodemap, there is no way to loop through all - available data. - - :param image: Image to acquire chunk data from - :type image: Image object - :return: True if successful, False otherwise. - :rtype: bool - """ - print('Printing chunk data from image...') - try: - result = True - print(type(image)) - # Retrieve chunk data from image - # - # *** NOTES *** - # When retrieving chunk data from an image, the data is stored in a - # ChunkData object and accessed with getter functions. - chunk_data = image.GetChunkData() - - # Retrieve exposure time (recorded in microseconds) - exposure_time = chunk_data.GetExposureTime() - print('\tExposure time: {}'.format(exposure_time)) - - # Retrieve frame ID - frame_id = chunk_data.GetFrameID() - print('\tFrame ID: {}'.format(frame_id)) - - # Retrieve gain; gain recorded in decibels - gain = chunk_data.GetGain() - print('\tGain: {}'.format(gain)) - - # Retrieve height; height recorded in pixels - height = chunk_data.GetHeight() - print('\tHeight: {}'.format(height)) - - # Retrieve offset X; offset X recorded in pixels - offset_x = chunk_data.GetOffsetX() - print('\tOffset X: {}'.format(offset_x)) - - # Retrieve offset Y; offset Y recorded in pixels - offset_y = chunk_data.GetOffsetY() - print('\tOffset Y: {}'.format(offset_y)) - - # Retrieve sequencer set active - sequencer_set_active = chunk_data.GetSequencerSetActive() - print('\tSequencer set active: {}'.format(sequencer_set_active)) - - # Retrieve timestamp - timestamp = chunk_data.GetTimestamp() - print('\tTimestamp: {}'.format(timestamp)) - - # Retrieve width; width recorded in pixels - width = chunk_data.GetWidth() - print('\tWidth: {}'.format(width)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - else: - print('Device control information not available.') - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISTION ***\n') - - try: - result = True - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration mode - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame captures a set number of images, and continuous captures a - # continuous stream of images. As the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can be easily checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - - # Print image information - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ChunkData-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ChunkData-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Display chunk data - - if CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.IMAGE: - result &= display_chunk_data_from_image(image_result) - elif CHOSEN_CHUNK_DATA_TYPE == ChunkDataTypes.NODEMAP: - result = display_chunk_data_from_nodemap(nodemap) - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def disable_chunk_data(nodemap): - """ - This function disables each type of chunk data before disabling chunk data mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise - :rtype: bool - """ - try: - result = True - - # Retrieve the selector node - chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode('ChunkSelector')) - - if not PySpin.IsAvailable(chunk_selector) or not PySpin.IsReadable(chunk_selector): - print('Unable to retrieve chunk selector. Aborting...\n') - return False - - # Retrieve entries - # - # *** NOTES *** - # PySpin handles mass entry retrieval in a different way than the C++ - # API. Instead of taking in a NodeList_t reference, GetEntries() takes - # no parameters and gives us a list of INodes. Since we want these INodes - # to be of type CEnumEntryPtr, we can use a list comprehension to - # transform all of our collected INodes into CEnumEntryPtrs at once. - entries = [PySpin.CEnumEntryPtr(chunk_selector_entry) for chunk_selector_entry in chunk_selector.GetEntries()] - - print('Disabling entries...') - - for chunk_selector_entry in entries: - # Go to next node if problem occurs - if not PySpin.IsAvailable(chunk_selector_entry) or not PySpin.IsReadable(chunk_selector_entry): - continue - - chunk_selector.SetIntValue(chunk_selector_entry.GetValue()) - - chunk_symbolic_form = '\t {}:'.format(chunk_selector_entry.GetSymbolic()) - - # Retrieve corresponding boolean - chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode('ChunkEnable')) - - # Disable the boolean, thus disabling the corresponding chunk data - if not PySpin.IsAvailable(chunk_enable): - print('{} not available'.format(chunk_symbolic_form)) - result = False - elif not chunk_enable.GetValue(): - print('{} disabled'.format(chunk_symbolic_form)) - elif PySpin.IsWritable(chunk_enable): - chunk_enable.SetValue(False) - print('{} disabled'.format(chunk_symbolic_form)) - else: - print('{} not writable'.format(chunk_symbolic_form)) - - # Deactivate Chunk Mode - chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode('ChunkModeActive')) - - if not PySpin.IsAvailable(chunk_mode_active) or not PySpin.IsWritable(chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...\n') - return False - - chunk_mode_active.SetValue(False) - - print('Chunk mode deactivated...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure chunk data - if configure_chunk_data(nodemap) is False: - return False - - # Acquire images and display chunk data - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - if disable_chunk_data(nodemap) is False: - return False - - # De-initialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/CounterAndTimer.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/CounterAndTimer.py deleted file mode 100644 index 537d5d4..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/CounterAndTimer.py +++ /dev/null @@ -1,669 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# CounterAndTimer.py shows how to setup a Pulse Width Modulation (PWM) -# signal using counters and timers. The camera will output the PWM signal via -# strobe, and capture images at a rate defined by the PWM signal as well. -# Users should take care to use a PWM signal within the camera's max -# frame rate (by default, the PWM signal is set to 50 Hz). -# -# Counter and Timer functionality is only available for BFS and Oryx Cameras. -# For details on the hardware setup, see our kb article, "Using Counter and -# Timer Control"; https://www.flir.com/support-center/iis/machine-vision/application-note/using-counter-and-timer-control - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def setup_counter_and_timer(nodemap): - """ - This function configures the camera to setup a Pulse Width Modulation signal using - Counter and Timer functionality. By default, the PWM signal will be set to run at - 50hz, with a duty cycle of 70%. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('Configuring Pulse Width Modulation signal') - - try: - result = True - - # Set Counter Selector to Counter 0 - node_counter_selector = PySpin.CEnumerationPtr(nodemap.GetNode('CounterSelector')) - - # Check to see if camera supports Counter and Timer functionality - if not PySpin.IsAvailable(node_counter_selector): - print('\nCamera does not support Counter and Timer Functionality. Aborting...\n') - return False - - if not PySpin.IsWritable(node_counter_selector): - print('\nUnable to set Counter Selector (enumeration retrieval). Aborting...\n') - return False - - entry_counter_0 = node_counter_selector.GetEntryByName('Counter0') - if not PySpin.IsAvailable(entry_counter_0) or not PySpin.IsReadable(entry_counter_0): - print('\nUnable to set Counter Selector (entry retrieval). Aborting...\n') - return False - - counter_0 = entry_counter_0.GetValue() - - node_counter_selector.SetIntValue(counter_0) - - # Set Counter Event Source to MHzTick - node_counter_event_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterEventSource')) - if not PySpin.IsAvailable(node_counter_event_source) or not PySpin.IsWritable(node_counter_event_source): - print('\nUnable to set Counter Event Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_event_source_mhz_tick = node_counter_event_source.GetEntryByName('MHzTick') - if not PySpin.IsAvailable(entry_counter_event_source_mhz_tick) \ - or not PySpin.IsReadable(entry_counter_event_source_mhz_tick): - print('\nUnable to set Counter Event Source (entry retrieval). Aborting...\n') - return False - - counter_event_source_mhz_tick = entry_counter_event_source_mhz_tick.GetValue() - - node_counter_event_source.SetIntValue(counter_event_source_mhz_tick) - - # Set Counter Duration to 14000 - node_counter_duration = PySpin.CIntegerPtr(nodemap.GetNode('CounterDuration')) - if not PySpin.IsAvailable(node_counter_duration) or not PySpin.IsWritable(node_counter_duration): - print('\nUnable to set Counter Duration (integer retrieval). Aborting...\n') - return False - - node_counter_duration.SetValue(14000) - - # Set Counter Delay to 6000 - node_counter_delay = PySpin.CIntegerPtr(nodemap.GetNode('CounterDelay')) - if not PySpin.IsAvailable(node_counter_delay) or not PySpin.IsWritable(node_counter_delay): - print('\nUnable to set Counter Delay (integer retrieval). Aborting...\n') - return False - - node_counter_delay.SetValue(6000) - - # Determine Duty Cycle of PWM signal - duty_cycle = float(node_counter_duration.GetValue()) / (float(node_counter_duration.GetValue() + - node_counter_delay.GetValue())) * 100 - - print('\nThe duty cycle has been set to {}%'.format(duty_cycle)) - - # Determine pulse rate of PWM signal - pulse_rate = 1000000 / float(node_counter_duration.GetValue() + node_counter_delay.GetValue()) - - print('\nThe pulse rate has been set to {} Hz'.format(pulse_rate)) - - # Set Counter Trigger Source to Frame Trigger Wait - node_counter_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerSource')) - if not PySpin.IsAvailable(node_counter_trigger_source) or not PySpin.IsWritable(node_counter_trigger_source): - print('\nUnable to set Counter Trigger Source (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_ftw = node_counter_trigger_source.GetEntryByName('FrameTriggerWait') - if not PySpin.IsAvailable(entry_counter_trigger_source_ftw)\ - or not PySpin.IsReadable(entry_counter_trigger_source_ftw): - print('\nUnable to set Counter Trigger Source (entry retrieval). Aborting...\n') - return False - - counter_trigger_source_ftw = entry_counter_trigger_source_ftw.GetValue() - - node_counter_trigger_source.SetIntValue(counter_trigger_source_ftw) - - # Set Counter Trigger Activation to Level High - node_counter_trigger_activation = PySpin.CEnumerationPtr(nodemap.GetNode('CounterTriggerActivation')) - if not PySpin.IsAvailable(node_counter_trigger_activation) or \ - not PySpin.IsWritable(node_counter_trigger_activation): - print('\nUnable to set Counter Trigger Activation (enumeration retrieval). Aborting...\n') - return False - - entry_counter_trigger_source_lh = node_counter_trigger_activation.GetEntryByName('LevelHigh') - if not PySpin.IsAvailable(entry_counter_trigger_source_lh) \ - or not PySpin.IsReadable(entry_counter_trigger_source_lh): - print('\nUnable to set Counter Trigger Activation (entry retrieval). Aborting...\n') - return False - - counter_trigger_level_high = entry_counter_trigger_source_lh.GetValue() - - node_counter_trigger_activation.SetIntValue(counter_trigger_level_high) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_digital_io(nodemap): - """ - This function configures the GPIO to output the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring GPIO strobe output') - - try: - result = True - camera_family_bfs = "BFS" - camera_family_oryx = "ORX" - - # Determine camera family - node_device_name = PySpin.CStringPtr(nodemap.GetNode('DeviceModelName')) - if not PySpin.IsAvailable(node_device_name) or not PySpin.IsReadable(node_device_name): - print('\nUnable to determine camera family. Aborting...\n') - return False - - camera_model = node_device_name.GetValue() - - # Set Line Selector - node_line_selector = PySpin.CEnumerationPtr(nodemap.GetNode('LineSelector')) - if not PySpin.IsAvailable(node_line_selector) or not PySpin.IsWritable(node_line_selector): - print('\nUnable to set Line Selector (enumeration retrieval). Aborting...\n') - return False - - if camera_family_bfs in camera_model: - - entry_line_selector_line_1 = node_line_selector.GetEntryByName('Line1') - if not PySpin.IsAvailable(entry_line_selector_line_1) or not PySpin.IsReadable(entry_line_selector_line_1): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_1 = entry_line_selector_line_1.GetValue() - - node_line_selector.SetIntValue(line_selector_line_1) - - elif camera_family_oryx in camera_model: - - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - # Set Line Mode to output - node_line_mode = PySpin.CEnumerationPtr(nodemap.GetNode('LineMode')) - if not PySpin.IsAvailable(node_line_mode) or not PySpin.IsWritable(node_line_mode): - print('\nUnable to set Line Mode (enumeration retrieval). Aborting...\n') - return False - - entry_line_mode_output = node_line_mode.GetEntryByName('Output') - if not PySpin.IsAvailable(entry_line_mode_output) or not PySpin.IsReadable(entry_line_mode_output): - print('\nUnable to set Line Mode (entry retrieval). Aborting...\n') - return False - - line_mode_output = entry_line_mode_output.GetValue() - - node_line_mode.SetIntValue(line_mode_output) - - # Set Line Source for Selected Line to Counter 0 Active - node_line_source = PySpin.CEnumerationPtr(nodemap.GetNode('LineSource')) - if not PySpin.IsAvailable(node_line_source) or not PySpin.IsWritable(node_line_source): - print('\nUnable to set Line Source (enumeration retrieval). Aborting...\n') - return False - - entry_line_source_counter_0_active = node_line_source.GetEntryByName('Counter0Active') - if not PySpin.IsAvailable(entry_line_source_counter_0_active) \ - or not PySpin.IsReadable(entry_line_source_counter_0_active): - print('\nUnable to set Line Source (entry retrieval). Aborting...\n') - return False - - line_source_counter_0_active = entry_line_source_counter_0_active.GetValue() - - node_line_source.SetIntValue(line_source_counter_0_active) - - if camera_family_bfs in camera_model: - # Change Line Selector to Line 2 and Enable 3.3 Voltage Rail - entry_line_selector_line_2 = node_line_selector.GetEntryByName('Line2') - if not PySpin.IsAvailable(entry_line_selector_line_2) or not PySpin.IsReadable(entry_line_selector_line_2): - print('\nUnable to set Line Selector (entry retrieval). Aborting...\n') - return False - - line_selector_line_2 = entry_line_selector_line_2.GetValue() - - node_line_selector.SetIntValue(line_selector_line_2) - - node_voltage_enable = PySpin.CBooleanPtr(nodemap.GetNode('V3_3Enable')) - if not PySpin.IsAvailable(node_voltage_enable) or not PySpin.IsWritable(node_voltage_enable): - print('\nUnable to set Voltage Enable (boolean retrieval). Aborting...\n') - return False - - node_voltage_enable.SetValue(True) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def configure_exposure_and_trigger(nodemap): - """ - This function configures the camera to set a manual exposure value and enables - camera to be triggered by the PWM signal. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\nConfiguring Exposure and Trigger') - - try: - result = True - - # Turn off auto exposure - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print('\nUnable to set Exposure Auto (enumeration retrieval). Aborting...\n') - return False - - entry_exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_exposure_auto_off) or not PySpin.IsReadable(entry_exposure_auto_off): - print('\nUnable to set Exposure Auto (entry retrieval). Aborting...\n') - return False - - exposure_auto_off = entry_exposure_auto_off.GetValue() - - node_exposure_auto.SetIntValue(exposure_auto_off) - - # Set Exposure Time to less than 1/50th of a second (5000 us is used as an example) - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print('\nUnable to set Exposure Time (float retrieval). Aborting...\n') - return False - - node_exposure_time.SetValue(5000) - - # Ensure trigger mode is off - # - # *** NOTES *** - # The trigger must be disabled in order to configure - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('\nUnable to disable trigger mode (node retrieval). Aborting...\n') - return False - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('\nUnable to disable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - # Set Trigger Source to Counter 0 Start - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('\nUnable to set trigger source (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_source_counter_0_start = node_trigger_source.GetEntryByName('Counter0Start') - if not PySpin.IsAvailable(entry_trigger_source_counter_0_start)\ - or not PySpin.IsReadable(entry_trigger_source_counter_0_start): - print('\nUnable to set trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_source.SetIntValue(entry_trigger_source_counter_0_start.GetValue()) - - # Set Trigger Overlap to Readout - node_trigger_overlap = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerOverlap')) - if not PySpin.IsAvailable(node_trigger_overlap) or not PySpin.IsWritable(node_trigger_overlap): - print('\nUnable to set Trigger Overlap (enumeration retrieval). Aborting...\n') - return False - - entry_trigger_overlap_ro = node_trigger_overlap.GetEntryByName('ReadOut') - if not PySpin.IsAvailable(entry_trigger_overlap_ro) or not PySpin.IsReadable(entry_trigger_overlap_ro): - print('\nUnable to set Trigger Overlap (entry retrieval). Aborting...\n') - return False - - trigger_overlap_ro = entry_trigger_overlap_ro.GetValue() - - node_trigger_overlap.SetIntValue(trigger_overlap_ro) - - # Turn trigger mode on - entry_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(entry_trigger_mode_on) or not PySpin.IsReadable(entry_trigger_mode_on): - print('\nUnable to enable trigger mode (enum entry retrieval). Aborting...\n') - return False - - node_trigger_mode.SetIntValue(entry_trigger_mode_on.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enumeration retrieval). Aborting...\n') - return False - - entry_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(entry_acquisition_mode_continuous)\ - or not PySpin.IsReadable(entry_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = entry_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {} ...'.format(image_result.GetImageStatus())) - - else: - - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'CounterAndTimer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'CounterAndTimer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - *** NOTES *** - This function turns off trigger mode, but does not change the trigger source. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn trigger mode back off - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsWritable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Non-fatal error...\n') - - entry_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(entry_trigger_mode_off) or not PySpin.IsReadable(entry_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Non-fatal error...\n') - - node_trigger_mode.SetIntValue(entry_trigger_mode_off.GetValue()) - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see the NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure Counter and Timer setup - result &= setup_counter_and_timer(nodemap) - if not result: - return result - - # Configure DigitalIO (GPIO output) - result &= configure_digital_io(nodemap) - if not result: - return result - - # Configure Exposure and Trigger - result &= configure_exposure_and_trigger(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete... \n'.format(i)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/DeviceEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/DeviceEvents.py deleted file mode 100644 index 53ee365..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/DeviceEvents.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# =============================================================================*/ -# -# DeviceEvents.py shows how to create a handler to access device -# events. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as events. -# -# Device events can be thought of as camera-related events. This example -# creates a user-defined class, DeviceEventHandler, which allows the user to -# define any properties, parameters, and the event handler itself while DeviceEventHandler, -# the parent class, allows the child class to appropriately interface with -# the Spinnaker SDK. - -import os -import PySpin -import sys - - -class EventType: - """ - 'Enum' for choosing whether to register a event specifically for exposure end events - or universally for all events. - """ - GENERIC = 0 - SPECIFIC = 1 - -CHOSEN_EVENT = EventType.GENERIC # change me! -NUM_IMAGES = 10 # number of images to acquire - - -class DeviceEventHandler(PySpin.DeviceEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define device - events must inherit from DeviceEventHandler. Second, the method signature of - OnDeviceEvent() must also be consistent. Everything else - including the - constructor, destructor, properties, and body of OnDeviceEvent() - are - particular to the example. - """ - def __init__(self, eventname): - """ - This constructor registers an event name to be used on device events. - - :param eventname: Name of event to register. - :type eventname: str - :rtype: None - """ - super(DeviceEventHandler, self).__init__() - self.event_name = eventname - self.count = 0 - - def OnDeviceEvent(self, eventname): - """ - Callback function when a device event occurs. - Note eventname is a wrapped gcstring, not a Python string, but basic operations such as printing and comparing - with Python strings are supported. - - :param eventname: gcstring representing the name of the occurred event. - :type eventname: gcstring - :rtype: None - """ - if eventname == self.event_name: - self.count += 1 - - # Print information on specified device event - print('\tDevice event %s with ID %i number %i...' % (eventname, - self.GetDeviceEventId(), - self.count)) - else: - # Print no information on non-specified event - print('\tDevice event occurred; not %s; ignoring...' % self.event_name) - - -def configure_device_events(nodemap, cam): - """ - This function configures the example to execute device events by enabling all - types of device events, and then creating and registering a device event handler that - only concerns itself with an end of exposure event. - - :param INodeMap nodemap: Device nodemap. - :param CameraPtr cam: Pointer to camera. - :returns: tuple (result, device_event_handler) - WHERE - result is True if successful, False otherwise - device_event_handler is the event handler - :rtype: (bool, DeviceEventHandler) - """ - print('\n*** CONFIGURING DEVICE EVENTS ***\n') - - try: - result = True - - # Retrieve device event selector - # - # *** NOTES *** - # Each type of device event must be enabled individually. This is done - # by retrieving "EventSelector" (an enumeration node) and then enabling - # the device event on "EventNotification" (another enumeration node). - # - # This example only deals with exposure end events. However, instead of - # only enabling exposure end events with a simpler device event function, - # all device events are enabled while the device event handler deals with - # ensuring that only exposure end events are considered. A more standard - # use-case might be to enable only the events of interest. - node_event_selector = PySpin.CEnumerationPtr(nodemap.GetNode('EventSelector')) - if not PySpin.IsAvailable(node_event_selector) or not PySpin.IsReadable(node_event_selector): - print('Unable to retrieve event selector entries. Aborting...') - return False - - entries = node_event_selector.GetEntries() - print('Enabling event selector entries...') - - # Enable device events - # - # *** NOTES *** - # In order to enable a device event, the event selector and event - # notification nodes (both of type enumeration) must work in unison. - # The desired event must first be selected on the event selector node - # and then enabled on the event notification node. - for entry in entries: - - # Select entry on selector node - node_entry = PySpin.CEnumEntryPtr(entry) - if not PySpin.IsAvailable(node_entry) or not PySpin.IsReadable(node_entry): - - # Skip if node fails - result = False - continue - - node_event_selector.SetIntValue(node_entry.GetValue()) - - # Retrieve event notification node (an enumeration node) - node_event_notification = PySpin.CEnumerationPtr(nodemap.GetNode('EventNotification')) - if not PySpin.IsAvailable(node_event_notification) or not PySpin.IsWritable(node_event_notification): - - # Skip if node fails - result = False - continue - - # Retrieve entry node to enable device event - node_event_notification_on = PySpin.CEnumEntryPtr(node_event_notification.GetEntryByName('On')) - if not PySpin.IsAvailable(node_event_notification_on) or not PySpin.IsReadable(node_event_notification_on): - - # Skip if node fails - result = False - continue - - node_event_notification.SetIntValue(node_event_notification_on.GetValue()) - - print('\t%s: enabled...' % node_entry.GetDisplayName()) - - # Create device event handler - # - # *** NOTES *** - # The class has been designed to take in the name of an event. If all - # events are registered generically, all event types will trigger a - # device event; on the other hand, if an event handler is registered - # specifically, only that event will trigger an event. - device_event_handler = DeviceEventHandler('EventExposureEnd') - - # Register device event handler - # - # *** NOTES *** - # Device event handlers are registered to cameras. If there are multiple - # cameras, each camera must have any device event handlers registered to it - # separately. Note that multiple device event handlers may be registered to a - # single camera. - # - # *** LATER *** - # Device event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the device event handlers are still in - # scope. - if CHOSEN_EVENT == EventType.GENERIC: - - # Device event handlers registered generally will be triggered by any device events. - cam.RegisterEventHandler(device_event_handler) - - print('Device event handler registered generally...') - - elif CHOSEN_EVENT == EventType.SPECIFIC: - - # Device event handlers registered to a specified event will only - # be triggered by the type of event is it registered to. - cam.RegisterEventHandler(device_event_handler, 'EventExposureEnd') - - print('Device event handler registered specifically to EventExposureEnd events...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, device_event_handler - - -def reset_device_events(cam, device_event_handler): - """ - This function resets the example by unregistering the device event handler. - - :param cam: Camera to unregister event handler from. - :param device_event_handler: Event handler for this example. - :type cam: CameraPtr - :type device_event_handler: DeviceEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister device event handler - # - # *** NOTES *** - # It is important to unregister all device event handlers from all cameras that - # they are registered to. - cam.UnregisterEventHandler(device_event_handler) - - print('Device event handler unregistered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...\n') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) \ - or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...\n') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %s...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %i, width = %i, height = %i' % (i, width, height)) - - # Convert to mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - if device_serial_number: - filename = 'DeviceEvents-%s-%i.jpg' % (device_serial_number, i) - else: - filename = 'DeviceEvents-%i.jpg' % i - - # Save image - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure device event handlers - err, device_event_handler = configure_device_events(nodemap, cam) - if not err: - return err - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset device event handlers - result &= reset_device_events(cam, device_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration.py deleted file mode 100644 index 489b34a..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration.py +++ /dev/null @@ -1,272 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration.py shows how to enumerate interfaces and cameras. -# Knowing this is mandatory for doing anything with the Spinnaker SDK, and is -# therefore the best place to start learning how to use the SDK. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also touches -# on retrieving both nodes from nodemaps and information from nodes. -# -# Once comfortable with enumeration, we suggest checking out the Acquisition and/or -# NodeMapInfo examples. Acquisition demonstrates using a camera to acquire images, -# and NodeMapInfo demonstrates retrieving information from various node types. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL nodemap from interface - # - # *** NOTES *** - # Each interface has a nodemap that can be retrieved in order to - # access information about the interface itself, any devices - # connected, or addressing information if applicable. - nodemap_interface = interface.GetTLNodeMap() - - # Print interface display name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - # - # Note that for Python, the node retrieved then has to be 'cast' - # to the proper type (CStringPtr in this case) before it can be used. - node_interface_display_name = PySpin.CStringPtr(nodemap_interface.GetNode('InterfaceDisplayName')) - - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return result - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Retrieve TL device nodemap; please see NodeMapInfo example for - # additional comments on transport layer nodemaps - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - # Print device vendor name and device model name - # - # *** NOTES *** - # Grabbing node information requires first retrieving the node and - # then retrieving its information. There are two things to keep in - # mind. First, a node is distinguished by type, which is related - # to its value's data type. Second, nodes should be checked for - # availability and readability/writability prior to making an - # attempt to read from or write to the node. - node_device_vendor_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceVendorName')) - - if PySpin.IsAvailable(node_device_vendor_name) and PySpin.IsReadable(node_device_vendor_name): - device_vendor_name = node_device_vendor_name.ToString() - - node_device_model_name = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceModelName')) - - if PySpin.IsAvailable(node_device_model_name) and PySpin.IsReadable(node_device_model_name): - device_model_name = node_device_model_name.ToString() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - # automatically. - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_interfaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_interfaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_interfaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still-registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/EnumerationEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/EnumerationEvents.py deleted file mode 100644 index 3761d54..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/EnumerationEvents.py +++ /dev/null @@ -1,216 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# EnumerationEvents.py explores arrival and removal events on interfaces and the system. -# It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback example, -# as nodemap callbacks follow the same general procedure as events, but with a few less steps. -# -# This example creates two user-defined classes: InterfaceEventHandler and SystemEventHandler. -# These child classes allow the user to define properties, parameters, and the event handler itself -# while the parent classes - DeviceArrivalEventHandler, DeviceRemovalEventHandler, and InterfaceEventHandler - -# allow the child classes to interface with Spinnaker. - -import PySpin - - -class SystemEventHandler(PySpin.InterfaceEventHandler): - """ - This class defines the properties and methods for device arrivals and removals - on the system. Take special note of the signatures of the OnDeviceArrival() - and OnDeviceRemoval() methods. - All three event handler types - DeviceArrivalEventHandler, DeviceRemovalEventHandler, - and InterfaceEventHandler - can be registered to interfaces, the system, or both. - However, in Spinnaker Python, an enumeration event handler must inherit from - InterfaceEventHandler if we want to handle both arrival and removal events. - - *** NOTES *** - Registering an interface event handler to the system is basically the same thing - as registering that event handler to all interfaces, with the added benefit of - not having to manage newly arrived or newly removed interfaces. In order to manually - manage newly arrived or removed interfaces, one would need to implement interface - arrival/removal event handlers, which are not yet supported in the Spinnaker Python API. - """ - def __init__(self, system): - """ - Constructor. This sets the system instance. - - :param system: Instance of the system. - :type system: SystemPtr - :rtype: None - """ - super(SystemEventHandler, self).__init__() - self.system = system - - - def OnDeviceArrival(self, serial_number): - """ - This method defines the arrival event on the system. It prints out - the device serial number of the camera arriving and the number of - cameras currently connected. The argument is the serial number of - the camera that triggered the arrival event. - - :param serial_number: gcstring representing the serial number of the arriving camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tDevice %i has arrived on the system.' % serial_number) - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - - def OnDeviceRemoval(self, serial_number): - """ - This method defines the removal event on the system. It prints out the - device serial number of the camera being removed and the number of cameras - currently connected. The argument is the serial number of the camera that - triggered the removal event. - - :param serial_number: gcstring representing the serial number of the removed camera. - :type serial_number: gcstring - :return: None - """ - cam_list = self.system.GetCameras() - count = cam_list.GetSize() - print('System event handler:') - print('\tDevice %i was removed from the system.' % serial_number) - print('\tThere %s %i %s on the system.' % ('is' if count == 1 else 'are', - count, - 'device' if count == 1 else 'devices')) - - -def check_gev_enabled(system): - """ - This function checks if GEV enumeration is enabled on the system. - - :param system: Current system instance. - :type system: SystemPtr - - """ - - # Retrieve the System TL NodeMap and EnumerateGEVInterfaces node - system_node_map = system.GetTLNodeMap() - node_gev_enumeration = PySpin.CBooleanPtr(system_node_map.GetNode('EnumerateGEVInterfaces')) - - # Ensure the node is valid - if not PySpin.IsAvailable(node_gev_enumeration) or not PySpin.IsReadable(node_gev_enumeration): - print('EnumerateGEVInterfaces node is unavailable or unreadable. Aborting...') - return - - # Check if node is enabled - gev_enabled = node_gev_enumeration.GetValue() - if not gev_enabled: - print('\nWARNING: GEV Enumeration is disabled.') - print('If you intend to use GigE cameras please run the EnableGEVInterfaces shortcut\n' - 'or set EnumerateGEVInterfaces to true and relaunch your application.\n') - return - print('GEV enumeration is enabled. Continuing..') - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :rtype: None - """ - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Check if GEV enumeration is enabled - check_gev_enabled(system) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # MacOS interfaces are only registered if they are active. - # For this example to have the desired outcome all devices must be connected - # at the beginning and end of this example in order to register and deregister - # an event handler on each respective interface. - iface_list = system.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - print('*** CONFIGURING ENUMERATION EVENTS *** \n') - - # Create interface event handler for the system - # - # *** NOTES *** - # The SystemEventHandler has been constructed to accept a system object in - # order to print the number of cameras on the system. - system_event_handler = SystemEventHandler(system) - - # Register interface event handler for the system - # - # *** NOTES *** - # Arrival, removal, and interface event handlers can all be registered to - # interfaces or the system. Do not think that interface event handlers can only be - # registered to an interface. An interface event handler is merely a combination - # of an arrival and a removal event handler. - # - # *** LATER *** - # Arrival, removal, and interface event handlers must all be unregistered manually. - # This must be done prior to releasing the system and while they are still - # in scope. - system.RegisterInterfaceEventHandler(system_event_handler) - - # Wait for user to plug in and/or remove camera devices - input('\nReady! Remove/Plug in cameras to test or press Enter to exit...\n') - - # Unregister system event handler from system object - # - # *** NOTES *** - # It is important to unregister all arrival, removal, and interface event handlers - # registered to the system. - system.UnregisterInterfaceEventHandler(system_event_handler) - - # Delete system event handler, which has a system reference - del system_event_handler - print('Event handler unregistered from system...') - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - -if __name__ == '__main__': - main() diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration_QuickSpin.py deleted file mode 100644 index f016f64..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Enumeration_QuickSpin.py +++ /dev/null @@ -1,260 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Enumeration_QuickSpin.py shows how to enumerate interfaces -# and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. This is a great -# example to start learning about QuickSpin. -# -# This example introduces the preparation, use, and cleanup of the system -# object, interface and camera lists, interfaces, and cameras. It also -# touches on retrieving information from pre-fetched nodes using QuickSpin. -# Retrieving node information is the only portion of the example that -# differs from Enumeration. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def query_interface(interface): - """ - Queries an interface for its cameras and prints out device information. - - :param interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Print interface display name - # - # *** NOTES *** - # QuickSpin allows for the retrieval of interface information directly - # from an interface. Because interface information is made available - # on the transport layer, camera initialization is not required. - node_interface_display_name = interface.TLInterface.InterfaceDisplayName - if PySpin.IsAvailable(node_interface_display_name) and PySpin.IsReadable(node_interface_display_name): - - interface_display_name = node_interface_display_name.GetValue() - - print(interface_display_name) - - else: - print('Interface display name not readable') - - # Update list of cameras on the interface - # - # *** NOTES *** - # Updating the cameras on each interface is especially important if - # there has been any device arrivals or removals since the last time - # that UpdateCameras() was called. - interface.UpdateCameras() - - # Retrieve list of cameras from the interface - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from an interface, such as this one, only - # return cameras attached on that specific interface whereas camera - # lists retrieved from the system will return all cameras on all - # interfaces. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = interface.GetCameras() - - # Retrieve number of cameras - num_cams = cam_list.GetSize() - - # Return if no cameras detected - if num_cams == 0: - print('\tNo devices detected.\n') - return True - - # Print device vendor and model name for each camera on the interface - for i, cam in enumerate(cam_list): - - # Print device vendor name and device model name - # - # *** NOTES *** - # In QuickSpin, accessing nodes does not require first retrieving a - # nodemap. Instead, GenICam nodes are made available - # directly through the camera, and transport layer nodes are made - # available through the camera's TLDevice and TLStream properties. - # - # Most camera interaction happens through the GenICam nodemap, which - # requires the device to be initialized. Simpler reads, like the - # ones below, can often be accomplished at the transport layer, - # which does not require initialization; please see - # NodeMapInfo_QuickSpin for additional information on this topic. - # - # Readability/writability should be checked prior to interacting with - # nodes. Readability and writability are ensured by checking the - # access mode or by using the methods - if cam.TLDevice.DeviceVendorName.GetAccessMode() == PySpin.RO: - device_vendor_name = cam.TLDevice.DeviceVendorName.ToString() - - if cam.TLDevice.DeviceModelName.GetAccessMode() == PySpin.RO: - device_model_name = cam.TLDevice.DeviceModelName.GetValue() - - print('\tDevice %i %s %s \n' % (i, device_vendor_name, device_model_name)) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before losing scope - # - # *** NOTES *** - # Camera lists (and interface lists) must be cleared manually while in - # the same scope that the system is released. However, in cases like this - # where scope is lost, camera lists (and interface lists) will be cleared - cam_list.Clear() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point. - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - # - # *** NOTES *** - # Everything originates with the system object. It is important to notice - # that it has a singleton implementation, so it is impossible to have - # multiple system objects at the same time. Users can only get a smart - # pointer (SystemPtr) to the system instance. - # - # *** LATER *** - # The system object should be cleared prior to program completion. If not - # released explicitly, it will be released automatically when all SystemPtr - # objects that point to the system go out of scope. - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of interfaces from the system - # - # *** NOTES *** - # Interface lists are retrieved from the system object. - # - # *** LATER *** - # Interface lists must be cleared manually. This must be done prior to - # releasing the system and while the interface list is still in scope. - iface_list = system.GetInterfaces() - - # Get number of interfaces - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i' % num_ifaces) - - # Retrieve list of cameras from the system - # - # *** NOTES *** - # Camera lists can be retrieved from an interface or the system object. - # Camera lists retrieved from the system, such as this one, return all - # cameras available on the system. - # - # *** LATER *** - # Camera lists must be cleared manually. This must be done prior to - # releasing the system and while the camera list is still in scope. - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0 or num_ifaces == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - print('\n*** QUERYING INTERFACES ***\n') - - for iface in iface_list: - - # Query interface - result &= query_interface(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Clear camera list before releasing system - # - # *** NOTES *** - # Camera lists must be cleared manually prior to a system release call. - cam_list.Clear() - - # Clear interface list before releasing system - # - # *** NOTES *** - # Interface lists must be cleared manually prior to a system release call. - iface_list.Clear() - - # Release system instance - # - # *** NOTES *** - # The system should be released, but if it is not, it will do so itself. - # It is often at the release of the system (whether manual or automatic) - # that unreleased resources and still registered events will throw an - # exception. - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Exposure_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Exposure_QuickSpin.py deleted file mode 100644 index af71c34..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Exposure_QuickSpin.py +++ /dev/null @@ -1,369 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Exposure_QuickSpin.py shows how to customize image exposure time -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example prepares the camera, sets a new exposure time, and restores -# the camera to its default state. Ensuring custom values fall within an -# acceptable range is also touched on. Retrieving and setting information -# is the only portion of the example that differs from Exposure. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 5 # number of images to save - - -def configure_exposure(cam): - """ - This function configures a custom exposure time. Automatic exposure is turned - off in order to allow for the customization, and then the custom setting is - applied. - - :param cam: Camera to configure exposure for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING EXPOSURE ***\n') - - try: - result = True - - # Turn off automatic exposure mode - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. Enumerations - # representing entry nodes have been added to QuickSpin. This allows - # for the much easier setting of enumeration nodes to new values. - # - # The naming convention of QuickSpin enums is the name of the - # enumeration node followed by an underscore and the symbolic of - # the entry node. Selecting "Off" on the "ExposureAuto" node is - # thus named "ExposureAuto_Off". - # - # *** LATER *** - # Exposure time can be set automatically or manually as needed. This - # example turns automatic exposure off to set it manually and back - # on to return the camera to its default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to disable automatic exposure. Aborting...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) - print('Automatic exposure disabled...') - - # Set exposure time manually; exposure time recorded in microseconds - # - # *** NOTES *** - # Notice that the node is checked for availability and writability - # prior to the setting of the node. In QuickSpin, availability and - # writability are ensured by checking the access mode. - # - # Further, it is ensured that the desired exposure time does not exceed - # the maximum. Exposure time is counted in microseconds - this can be - # found out either by retrieving the unit with the GetUnit() method or - # by checking SpinView. - - if cam.ExposureTime.GetAccessMode() != PySpin.RW: - print('Unable to set exposure time. Aborting...') - return False - - # Ensure desired exposure time does not exceed the maximum - exposure_time_to_set = 2000000.0 - exposure_time_to_set = min(cam.ExposureTime.GetMax(), exposure_time_to_set) - cam.ExposureTime.SetValue(exposure_time_to_set) - print('Shutter time set to %s us...\n' % exposure_time_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_exposure(cam): - """ - This function returns the camera to a normal state by re-enabling automatic exposure. - - :param cam: Camera to reset exposure on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its - # default state. - - if cam.ExposureAuto.GetAccessMode() != PySpin.RW: - print('Unable to enable automatic exposure (node retrieval). Non-fatal error...') - return False - - cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous) - - print('Automatic exposure enabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the value of exposure time to set an appropriate timeout for GetNextImage - timeout = 0 - if cam.ExposureTime.GetAccessMode() == PySpin.RW or cam.ExposureTime.GetAccessMode() == PySpin.RO: - # The exposure time is retrieved in µs so it needs to be converted to ms to keep consistency with the unit being used in GetNextImage - timeout = (int)(cam.ExposureTime.GetValue() / 1000 + 1000) - else: - print ('Unable to get exposure time. Aborting...') - return False - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - # Retrieve next received image and ensure image completion - # By default, GetNextImage will block indefinitely until an image arrives. - # In this example, the timeout value is set to [exposure time + 1000]ms to ensure that an image has enough time to arrive under normal conditions - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'ExposureQS-%s-%d.jpg' % (device_serial_number, i) - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_exposure(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset exposure - result &= reset_exposure(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/FileAccess_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/FileAccess_QuickSpin.py deleted file mode 100644 index f2dae8c..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/FileAccess_QuickSpin.py +++ /dev/null @@ -1,692 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# FileAccess_QuickSpin.py shows shows how to read and write images using camera File Access function. -# -# This example uploads an image to the camera File Access storage and also -# downloads the image from the camera File Access storage and saves it to -# the disk. -# -# It also provides debug message when an additional argument `--verbose` is passed in, -# giving more detailed status of the progress to the users. -# -# Run with arguments in format (no quotes): "--mode --verbose (optional)" -# /d: Download saved image from camera and save it to the working directory. -# /u: Grab an image and store it on camera. -# - -import PySpin -import numpy as np -import os -import argparse -import sys - -parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) -subparsers = parser.add_subparsers() - -class ImageAcquisitionUtil: - @staticmethod - def check_node_readable(node): - return PySpin.IsAvailable(node) and PySpin.IsReadable(node) - - @staticmethod - def grab_reference_image(cam): - """ - This function first grabs 5 images to stablize the camera, - then it grabs a reference image and returns its pointer. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: Pointer to the reference image - :rtype: ImagePtr - """ - reference_image = PySpin.Image.Create() - - # Start capturing images - cam.BeginAcquisition() - - # Grab a couple of images to stabilize the camera - for image_count in range(5): - try: - result_image = cam.GetNextImage(1000) - if result_image.IsIncomplete(): - print('Imgae incomplete with image status %s' % result_image.GetImageStatus()) - else: - print('Grabbed image %s' %str(image_count) + ', width = %s' % str(result_image.GetWidth())\ - + ', height = %s' % str(result_image.GetHeight())) - reference_image.DeepCopy(result_image) - result_image.Release() - except PySpin.SpinnakerException as ex: - print(ex) - continue - - cam.EndAcquisition() - - return reference_image - -class FileAccess: - @staticmethod - def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if ImageAcquisitionUtil.check_node_readable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - print('') - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - @staticmethod - def execute_delete_command(cam): - """ - This function executes delete operation on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Delete) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to delete file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def open_file_to_write(cam): - """ - This function opens the camera file for writing. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for writing!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_write_command(cam): - """ - This function executes write command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Write) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to write to file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception : %s' % ex) - return False - return True - - @staticmethod - def close_file(cam): - """ - This function closes the file. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Close) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to close file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def upload_image(cam, verbose=False): - """ - This function first acquires a reference image from the camera, - then it writes the image file to the camera with file selector UserFile1. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - # Apply small pixel format - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - else: - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - - # Display camera setup information - print('Width: %s' % cam.Width.GetValue()) - print('Height: %s' % cam.Height.GetValue()) - print('offsetX: %s' % cam.OffsetX.GetValue()) - print('OffsetY: %s' % cam.OffsetY.GetValue()) - print('PixelFormat: %s' % cam.PixelFormat.GetValue()) - - # Grab reference image - try: - reference_image = ImageAcquisitionUtil.grab_reference_image(cam) - except PySpin.SpinnakerException as ex: - cam.DeInit() - del cam - print('Unexpected error grabbing reference image: %s' % ex) - return False - - # Form file path - filename = "DeviceStreamWrite-" - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - filename += ".bmp" - - # Save image - reference_image.Save(filename) - print('Image saved at %s' % filename) - - print('*** UPLOADING IMAGE ***') - - # Perform file stream write - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - # Get current enum entry node - node = PySpin.CEnumEntryPtr(entry) - - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - file_size = cam.FileSize.GetValue() - if file_size > 0: - if not FileAccess.execute_delete_command(cam): - print('Failed to delete file!') - success = False - continue - - # Open file on camera for write - if not FileAccess.open_file_to_write(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero if it's not - cam.FileAccessOffset.SetValue(0) - - # Compute number of write operations required - total_bytes_to_write = reference_image.GetBufferSize() - intermediate_buffer_size = cam.FileAccessLength.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera.') - return False - - if verbose: - print('') - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - offset = index * intermediate_buffer_size - if offset == 0: - continue - sections.append(offset) - - # Get image data and split into equal chunks - image_data = reference_image.GetData() - split_data = np.array_split(image_data, sections) - - for i in range(len(split_data)): - # Setup data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - cam.FileAccessBuffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - # Update FileAccessLength, otherwise garbage data outside the range would be written to device - cam.FileAccessLength.SetValue(bytes_left_to_write) - - # Perform write command - if not FileAccess.execute_write_command(cam): - print('Writing stream failed!') - success = False - break - - # Verify size of bytes written - size_written = cam.FileOperationResult.GetValue() - - # Log current file access offset - if verbose: - print('File Access Offset: %s' % cam.FileAccessOffset.GetValue()) - - # Keep track of total bytes written - total_bytes_written += size_written - if verbose: - print('Bytes written: %s of %s' % (total_bytes_written, total_bytes_to_write)) - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - if verbose: - print('Progress: (%s//%s)' % (i, write_iterations)) - else: - print('Progress: %s' % int((i*100 / write_iterations)) + "%") - - print('Writing complete') - - if not FileAccess.close_file(cam): - success = False - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - - @staticmethod - def open_file_to_read(cam): - """ - This function opens the file to read. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Open) - cam.FileOpenMode.SetValue(PySpin.FileOpenMode_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to open file for reading!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def execute_read_command(cam): - """ - This function executes read command on the camera. - - :param cam: Camera used to perform file operation. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - cam.FileOperationSelector.SetValue(PySpin.FileOperationSelector_Read) - cam.FileOperationExecute.Execute() - - if cam.FileOperationStatus.GetValue() != PySpin.FileOperationStatus_Success: - print('Failed to read file!') - return False - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return True - - @staticmethod - def download_image(cam, verbose=False): - """ - This function reads the image file stored in the camera file selector UserFile1, - saving the file to the working directory of this example. - - :param cam: Camera used to download file from. - :param verbose: Prints additional details of file download (False by default) - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - success = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - FileAccess.print_device_info(nodemap_tldevice) - - cam.Init() - - # Check file selector support - print('Checking file selector support') - if cam.FileSelector.GetAccessMode() == PySpin.NA or cam.FileSelector.GetAccessMode() == PySpin.NI: - print('File selector not supported on device!') - return False - - print('*** DOWNLOADING IMAGE ***') - - selector_list = cam.FileSelector.GetEntries() - - for entry in selector_list: - node = PySpin.CEnumEntryPtr(entry) - if verbose: - print('\nChecking FileSelector EnumEntry - %s' % node.GetSymbolic()) - - # Check file selector entry support - if not node or not ImageAcquisitionUtil.check_node_readable(node): - # Go to next entry node - print('%s not supported!' % node.GetSymbolic()) - continue - - # Use UserFile1 as the selector in this example. - # Available file selector entries varies across different cameras - if node.GetSymbolic() == "UserFile1": - # Set file selector - cam.FileSelector.SetIntValue(int(node.GetNumericValue())) - - # Get file size - total_bytes_to_read = cam.FileSize.GetValue() - if total_bytes_to_read == 0: - print('%s - No data available to read!' % node.GetSymbolic()) - success = False - continue - - print('Total data to download: %s' % total_bytes_to_read) - - # Open file on camera for reading - if not FileAccess.open_file_to_read(cam): - print('Failed to open file!') - success = False - continue - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - if cam.FileAccessLength.GetValue() < cam.FileAccessBuffer.GetLength(): - try: - cam.FileAccessLength.SetValue(cam.FileAccessBuffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unable to set FileAccessLength to FileAccessBuffer length: %s' % ex) - - # Set file access offset to zero - cam.FileAccessOffset.SetValue(0) - - # Computer number of read operations required - intermediate_buffer_size = cam.FileAccessLength.GetValue() - read_iterations = (total_bytes_to_read // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_read % intermediate_buffer_size) == 0) else 1) - - if verbose: - print('') - print('Total bytes to read: %s' % total_bytes_to_read) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % read_iterations) - - print('Fetching image from camera.') - - total_size_read = 0 - size_read = cam.FileOperationResult.GetValue() - image_data = np.array(size_read, dtype=np.uint8) - - for i in range(read_iterations): - if not FileAccess.execute_read_command(cam): - print('Reading stream failed!') - success = False - break - - # Verify size of bytes read - size_read = cam.FileOperationResult.GetValue() - - # Read from buffer Node - buffer_read = cam.FileAccessBuffer.Get(size_read) - if i == 0: - image_data = buffer_read - else: - image_data = np.append(image_data, buffer_read) - - # Keep track of total bytes read - total_size_read += size_read - if verbose: - print('Bytes read: %s of %s' % (total_size_read, total_bytes_to_read)) - print('Progress: (%s//%s)' % (i, read_iterations)) - else: - print('Progress: %s' % int((i*100 / read_iterations)) + "%") - - print('Reading complete') - - if not FileAccess.close_file(cam): - success = False - - # Form file path - filename = "DeviceStreamRead-" - - if cam.DeviceSerialNumber.GetAccessMode() == PySpin.RW or cam.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - filename += "%s-" % cam.DeviceSerialNumber.ToString() - - filename += ".bmp" - - # Image should be captured with Mono8 or Bayer8, it sets camera to correct pixel format - # in order to grab image ROI - if ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_Mono8)): - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - elif ImageAcquisitionUtil.check_node_readable(cam.PixelFormat.GetEntry(PySpin.PixelFormat_BayerGB8)): - # Use Bayer8 if Mono8 is not available - cam.PixelFormat.SetValue(PySpin.PixelFormat_BayerGB8) - else: - print('Failed to set camera pixel format.') - return False - - width = cam.Width.GetValue() - height = cam.Height.GetValue() - offset_x = cam.OffsetX.GetValue() - offset_y = cam.OffsetY.GetValue() - pixel_format = cam.PixelFormat.GetValue() - - # Form image and save data - print('Width: %s' % width) - print('Height: %s' % height) - print('OffsetX: %s' % offset_x) - print('OffsetY: %s' % offset_y) - print('PixelFormat: %s' % pixel_format) - - # Create image - image = PySpin.Image.Create(width, height, offset_x, offset_y, pixel_format, image_data) - - # Save image - image.Save(filename) - print('Image saved at %s' % filename) - - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - return success - -def main(): - """ - Example entry point; please see Enumeration.py example for more in-depth - comments on preparing and cleaning up the system with PySpin. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - parser = argparse.ArgumentParser() - parser = subparsers.add_parser('stop', formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument('--mode', required=True, type=str, - help='/u : Grab an image and store it on camera.\n/d : Download saved image from camera and save it to the working directory.\n') - parser.add_argument('--verbose', default=False, action='store_true', - help='Enable verbose output.') - - args = parser.parse_args() - - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - # This example only works with 1 camera is connected. - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - elif num_cameras > 1: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('This example only works when 1 camera is connected.') - input('Done! Press Enter to exit...') - return False - else: - if args.mode == '/u' or args.mode == '/U': - result = FileAccess.upload_image(cam_list[0], args.verbose) - elif args.mode == '/d' or args.mode == '/D': - result = FileAccess.download_image(cam_list[0], args.verbose) - else: - print("Invalid Argument! Use '--help' to learn available arguments.") - input('Done! Press Enter to exit...') - return False - - if not result: - print('File Access failed') - else: - print('File Access is successful!') - - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/HighDynamicRange.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/HighDynamicRange.py deleted file mode 100644 index da60789..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/HighDynamicRange.py +++ /dev/null @@ -1,302 +0,0 @@ -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# HighDynamicRange.py -# This example shows how to set High Dynamic Range (HDR) if it is available on the camera. - -import PySpin -import os -import sys - -NUM_IMAGES = 4 # number of images to grab - -K_HDR_SHUTTER1 = 1000 # us -K_HDR_SHUTTER2 = 5000 -K_HDR_SHUTTER3 = 15000 -K_HDR_SHUTTER4 = 30000 - -K_HDR_GAIN1 = 0 # dB -K_HDR_GAIN2 = 5 -K_HDR_GAIN3 = 10 -K_HDR_GAIN4 = 15 - - -def print_device_info(nodemap): - """ - Helper for outputting camera information - - :param nodemap: Transport layer device nodemap. - :type INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***') - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceControl')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - -def check_node_accessibility(node): - """ - Helper for checking GenICam node accessibility - - :param node: GenICam node being checked - :type node: CNodePtr - :return: True if accessible, False otherwise - :rtype: bool - """ - - return PySpin.IsAvailable(node) and (PySpin.IsReadable(node) or PySpin.IsWritable(node)) - -def toggle_hdr_mode(nodemap, hdr_on): - """ - Helper for toggling HDR mode on camera - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :param hdr_on: True if want to turn hdr mode on, False otherwise. - :type hdr_on: bool - :return: True if successful, False otherwise. - :rtype: bool - """ - - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - - if check_node_accessibility(node_hdr_enabled): - node_hdr_enabled.SetValue(hdr_on) - else: - return False - - print('HDR mode turned to', hdr_on) - - return True - -def initialize_hdr_images(nodemap): - """ - Helper for initializing HDR images - - :param nodemap: Transport layer device nodemap. - :type: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - hdr_image_selector = PySpin.CEnumerationPtr(nodemap.GetNode("PGR_HDRImageSelector")) - hdr_exposure_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_ExposureTimeAbs")) - hdr_gain_abs = PySpin.CFloatPtr(nodemap.GetNode("PGR_HDR_GainAbs")) - - if not check_node_accessibility(hdr_image_selector): - return False - if not check_node_accessibility(hdr_exposure_abs): - return False - if not check_node_accessibility(hdr_gain_abs): - return False - - # Configure Image1 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image1").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER1) - hdr_gain_abs.SetValue(K_HDR_GAIN1) - print('Initialized HDR Image1...') - - # Configure Image2 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image2").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER2) - hdr_gain_abs.SetValue(K_HDR_GAIN2) - print('Initialized HDR Image2...') - - # Configure Image3 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image3").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER3) - hdr_gain_abs.SetValue(K_HDR_GAIN3) - print('Initialized HDR Image3...') - - # Configure Image4 - hdr_image_selector.SetIntValue(hdr_image_selector.GetEntryByName("Image4").GetValue()) - hdr_exposure_abs.SetValue(K_HDR_SHUTTER4) - hdr_gain_abs.SetValue(K_HDR_GAIN4) - print('Initialized HDR Image4...') - - return True - -def run_single_camera(cam): - """ - Helper for running example on single camera - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Initialize camera - cam.Init() - - # Get GenICam NodeMap info from camera - nodemap = cam.GetNodeMap() - - # Get camera information through NodeMap - print_device_info(nodemap) - - # Verify whether HDR is supported on this device - node_hdr_enabled = PySpin.CBooleanPtr(nodemap.GetNode("PGR_HDRModeEnabled")) - if not PySpin.IsAvailable(node_hdr_enabled): - print('HDR is not supported! Exiting...') - return True - - # HDR needs to be enabled prior to configure individual HDR images - toggle_hdr_mode(nodemap, True) - - if not initialize_hdr_images(nodemap): - print('Error configuring HDR image! Exiting...') - return False - - # Retrieve Device ID - device_id = cam.GetTLDeviceNodeMap().GetNode("DeviceID") - - # Begin capturing images - print('Starting grabbing images...') - cam.BeginAcquisition() - - for i in range(NUM_IMAGES): - try: - # Retrieve the next received image - raw_image = cam.GetNextImage(1000) - width = raw_image.GetWidth() - height = raw_image.GetHeight() - print('Grabbed image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - converted_image = raw_image.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - filename = 'HighDynamicRange-%s-%d.jpg' % (device_id, i) - - # Save image - converted_image.Save(filename) - - # Image need to be released after use - raw_image.Release() - - except PySpin.SpinnakerException as ex: - print('Error Retrieving Image: %s' % ex) - result = False - continue - - # End capturing of images - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - print() - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for cam in cam_list: - result &= run_single_camera(cam) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageChannelStatistics.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageChannelStatistics.py deleted file mode 100644 index 7589b73..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageChannelStatistics.py +++ /dev/null @@ -1,302 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageChannelStatisitcs.py shows how to get the image data and channel statistics, and then saves / displays them. -# This example relies on information provided in the Acquisition examples. -# -# This example demonstrates how to visualize the image histogram using Python, and display an image represented as -# a numpy array. -# -# NOTE: matplotlib must be installed on Python interpreter prior to running this example - -import os -import sys -import PySpin -import matplotlib.pyplot as plt - -NUM_IMAGES = 10 # number of images to grab - - -def acquire_and_display_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and displays the channel statistics of N images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format): - print('Unable to set Pixel Format. Aborting...') - return False - - else: - # Retrieve entry node from enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if not PySpin.IsAvailable(node_pixel_format_mono8) or not PySpin.IsReadable(node_pixel_format_mono8): - print('Unable to set Pixel Format to MONO8. Aborting...') - return False - - # Retrieve integer value from entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel Format set to MONO8 ...') - - cam.BeginAcquisition() - - print('Acquiring images...') - - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - plt.ion() - for i in range(NUM_IMAGES): - try: - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - else: - fig = plt.figure(1) - - try: - image_stats = image_result.CalculateChannelStatistics(PySpin.GREY) - # Getting the image data as a numpy array - image_data = image_result.GetNDArray() - - # Display Statistics - print('SN%s image %d:' % (device_serial_number, i)) - print('\tNumber pixel values : %d' % image_stats.num_pixel_values) - print('\tRange: Min = %d, Max = %d' % (image_stats.range_min, - image_stats.range_max)) - print('\tPixel Value: Min = %d, Max = %d, Mean = %.2f' % (image_stats.pixel_value_min, - image_stats.pixel_value_max, - image_stats.pixel_value_mean)) - - # Using matplotlib, two subplots are created where the top subplot is the histogram and the - # bottom subplot is the image. - # - # Refer to https://matplotlib.org/2.0.2/api/pyplot_api.html#module-matplotlib.pyplot - - # Clear the figure to reuse for next plot - plt.clf() - - # Plot the histogram in the first subplot in a 2 row by 1 column grid - plt.subplot(211) - plt.cla() - plt.plot(image_stats.histogram, label='Grey') - plt.title('SN%s Histogram (%d)' % (device_serial_number, i)) - plt.legend() - - # Plot the image in the second subplot in a 2 row by 1 column grid - plt.subplot(212) - plt.cla() - plt.imshow(image_data, cmap='gray') - - # Show the image - plt.show() - plt.pause(0.01) - - # Create a unique filename - if device_serial_number: - filename = 'ImageChannelStatistics-%s-%d.png' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageChannelStatistics-%d.png' % i - - fig.savefig(filename) - print('\tSave to %s' % filename) - print() - - except PySpin.SpinnakerException: - raise - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException: - raise - - cam.EndAcquisition() - print('End Acquisition') - - plt.close() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - #Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire images - result &= acquire_and_display_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) - diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageEvents.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageEvents.py deleted file mode 100644 index ac85f18..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageEvents.py +++ /dev/null @@ -1,452 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageEvents.py shows how to acquire images using the image event handler. -# It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, ImageEventHandler, that inherits -# from the Spinnaker class, ImageEventHandler. ImageEventHandler allows the user to -# define any properties, parameters, and the event handler itself while ImageEvent -# allows the child class to appropriately interface with Spinnaker. - -import os -import sys -import PySpin -from time import sleep - -SLEEP_DURATION = 200 # amount of time for main thread to sleep for (in milliseconds) until _NUM_IMAGES have been saved - - -class ImageEventHandler(PySpin.ImageEventHandler): - """ - This class defines the properties, parameters, and the event handler itself. Take a - moment to notice what parts of the class are mandatory, and what have been - added for demonstration purposes. First, any class used to define image event handlers - must inherit from ImageEventHandler. Second, the method signature of OnImageEvent() - must also be consistent. Everything else - including the constructor, - destructor, properties, body of OnImageEvent(), and other functions - - is particular to the example. - """ - _NUM_IMAGES = 10 - - def __init__(self, cam): - """ - Constructor. Retrieves serial number of given camera and sets image counter to 0. - - :param cam: Camera instance, used to get serial number for unique image filenames. - :type cam: CameraPtr - :rtype: None - """ - super(ImageEventHandler, self).__init__() - - nodemap = cam.GetTLDeviceNodeMap() - - # Retrieve device serial number - node_device_serial_number = PySpin.CStringPtr(nodemap.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - self._device_serial_number = node_device_serial_number.GetValue() - - # Initialize image counter to 0 - self._image_count = 0 - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - def OnImageEvent(self, image): - """ - This method defines an image event. In it, the image that triggered the - event is converted and saved before incrementing the count. Please see - Acquisition example for more in-depth comments on the acquisition - of images. - - :param image: Image from event. - :type image: ImagePtr - :rtype: None - """ - # Save max of _NUM_IMAGES Images - if self._image_count < self._NUM_IMAGES: - print('Image event occurred...') - - # Check if image is incomplete - if image.IsIncomplete(): - print('Image incomplete with image status %i...' % image.GetImageStatus()) - - else: - # Print image info - print('Grabbed image %i, width = %i, height = %i' % (self._image_count, - image.GetWidth(), - image.GetHeight())) - - # Convert to mono8 - image_converted = image.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create unique filename and save image - if self._device_serial_number: - filename = 'ImageEvents-%s-%i.jpg' % (self._device_serial_number, self._image_count) - - else: # if serial number is empty - filename = 'ImageEvents-%i.jpg' % self._image_count - - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Increment image counter - self._image_count += 1 - - def get_image_count(self): - """ - Getter for image count. - - :return: Number of images saved. - :rtype: int - """ - return self._image_count - - def get_max_images(self): - """ - Getter for maximum images. - - :return: Total number of images to save. - :rtype: int - """ - return self._NUM_IMAGES - - -def configure_image_events(cam): - """ - This function configures the example to execute image events by preparing and - registering an image event. - - :param cam: Camera instance to configure image event. - :return: tuple(result, image_event_handler) - WHERE - result is True if successful, False otherwise - image_event_handler is the event handler - :rtype: (bool, ImageEventHandler) - """ - try: - result = True - - # Create image event handler - # - # *** NOTES *** - # The class has been constructed to accept a camera pointer in order - # to allow the saving of images with the device serial number. - image_event_handler = ImageEventHandler(cam) - - # Register image event handler - # - # *** NOTES *** - # Image events are registered to cameras. If there are multiple - # cameras, each camera must have the image events registered to it - # separately. Also, multiple image events may be registered to a - # single camera. - # - # *** LATER *** - # Image event handlers must be unregistered manually. This must be done prior - # to releasing the system and while the image events are still in - # scope. - cam.RegisterEventHandler(image_event_handler) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, image_event_handler - - -def wait_for_images(image_event_handler): - """ - This function waits for the appropriate amount of images. Notice that - whereas most examples actively retrieve images, the acquisition of images is - handled passively in this example. - - :param image_event_handler: Image event handler. - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Wait for images - # - # *** NOTES *** - # In order to passively capture images using image event handlers and - # automatic polling, the main thread sleeps in increments of SLEEP_DURATION ms - # until _MAX_IMAGES images have been acquired and saved. - while image_event_handler.get_image_count() < image_event_handler.get_max_images(): - print('\t//\n\t// Sleeping for %i ms. Grabbing images...' % SLEEP_DURATION) - sleep(SLEEP_DURATION / 1000.0) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_image_events(cam, image_event_handler): - """ - This functions resets the example by unregistering the image event handler. - - :param cam: Camera instance. - :param image_event_handler: Image event handler for cam. - :type cam: CameraPtr - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Unregister image event handler - # - # *** NOTES *** - # It is important to unregister all image events from all cameras they are registered to. - # Unlike SystemEventHandler and InterfaceEventHandler in the EnumerationEvents example, - # there is no need to explicitly delete the ImageEventHandler here as it does not store - # an instance of the camera (it gets deleted in the constructor already). - cam.UnregisterEventHandler(image_event_handler) - - print('Image events unregistered...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap from camera. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** DEVICE INFORMATION ***') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - result = False - - return result - - -def acquire_images(cam, nodemap, image_event_handler): - """ - This function passively waits for images by calling wait_for_images(). Notice that - this function is much shorter than the acquire_images() function of other examples. - This is because most of the code has been moved to the image event's OnImageEvent() - method. - - :param cam: Camera instance to grab images from. - :param nodemap: Device nodemap. - :param image_event_handler: Image event handler. - :type cam: CameraPtr - :type nodemap: INodeMap - :type image_event_handler: ImageEventHandler - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve images using image event handler - wait_for_images(image_event_handler) - - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure image events - err, image_event_handler = configure_image_events(cam) - if not err: - return err - - # Acquire images using the image event handler - result &= acquire_images(cam, nodemap, image_event_handler) - - # Reset image event handlers - result &= reset_image_events(cam, image_event_handler) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for additional - comments on the steps in this function. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl.py deleted file mode 100644 index e8b19f2..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl.py shows how to apply custom image settings to -# the camera. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# This example demonstrates setting minimums to offsets, X and Y, and maximums -# to width and height. It also shows the setting of a new pixel format, which -# is an enumeration type node. -# -# Following this, we suggest familiarizing yourself with the Exposure example -# if you haven't already. Exposure is another example on camera customization -# that is shorter and simpler than many of the others. Once comfortable with -# Exposure and ImageFormatControl, we suggest checking out any of the longer, -# more complicated examples related to camera configuration: ChunkData, -# LookupTable, Sequencer, or Trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(nodemap): - """ - Configures a number of settings on the camera including offsets X and Y, width, - height, and pixel format. These settings must be applied before BeginAcquisition() - is called; otherwise, they will be read only. Also, it is important to note that - settings are applied immediately. This means if you plan to reduce the width and - move the x offset accordingly, you need to apply such changes in the appropriate order. - - :param nodemap: GenICam nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS *** \n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # Enumeration nodes are slightly more complicated to set than other - # nodes. This is because setting an enumeration node requires working - # with two nodes instead of the usual one. - # - # As such, there are a number of steps to setting an enumeration node: - # retrieve the enumeration node from the nodemap, retrieve the desired - # entry node from the enumeration node, retrieve the integer value from - # the entry node, and set the new value of the enumeration node with - # the integer value from the entry node. - # - # Retrieve the enumeration node from the nodemap - node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat')) - if PySpin.IsAvailable(node_pixel_format) and PySpin.IsWritable(node_pixel_format): - - # Retrieve the desired entry node from the enumeration node - node_pixel_format_mono8 = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono8')) - if PySpin.IsAvailable(node_pixel_format_mono8) and PySpin.IsReadable(node_pixel_format_mono8): - - # Retrieve the integer value from the entry node - pixel_format_mono8 = node_pixel_format_mono8.GetValue() - - # Set integer as new value for enumeration node - node_pixel_format.SetIntValue(pixel_format_mono8) - - print('Pixel format set to %s...' % node_pixel_format.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format mono 8 not available...') - - else: - print('Pixel format not available...') - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - node_offset_x = PySpin.CIntegerPtr(nodemap.GetNode('OffsetX')) - if PySpin.IsAvailable(node_offset_x) and PySpin.IsWritable(node_offset_x): - - node_offset_x.SetValue(node_offset_x.GetMin()) - print('Offset X set to %i...' % node_offset_x.GetMin()) - - else: - print('Offset X not available...') - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple of. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - node_offset_y = PySpin.CIntegerPtr(nodemap.GetNode('OffsetY')) - if PySpin.IsAvailable(node_offset_y) and PySpin.IsWritable(node_offset_y): - - node_offset_y.SetValue(node_offset_y.GetMin()) - print('Offset Y set to %i...' % node_offset_y.GetMin()) - - else: - print('Offset Y not available...') - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. However, as these values are being set to the maximum, - # there is no reason to check against the increment. - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - - width_to_set = node_width.GetMax() - node_width.SetValue(width_to_set) - print('Width set to %i...' % node_width.GetValue()) - - else: - print('Width not available...') - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - - height_to_set = node_height.GetMax() - node_height.SetValue(height_to_set) - print('Height set to %i...' % node_height.GetValue()) - - else: - print('Height not available...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # - # *** NOTES *** - # Because the example acquires and saves 10 images, setting acquisition - # mode to continuous lets the example finish. If set to single frame - # or multiframe (at a lower number of images), the example would just - # hang. This would happen because the example has been written to - # acquire 10 images while the camera would have been programmed to - # retrieve less than that. - # - # Setting the value of an enumeration node is slightly more complicated - # than other node types. Two nodes must be retrieved: first, the - # enumeration node is retrieved from the nodemap; and second, the entry - # node is retrieved from the enumeration node. The integer value of the - # entry node is then set as the new value of the enumeration node. - # - # Notice that both the enumeration and the entry nodes are checked for - # availability and readability/writability. Enumeration nodes are - # generally readable and writable whereas their entry nodes are only - # ever readable. - # - # Retrieve enumeration node from nodemap - - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - # - # *** NOTES *** - # What happens when the camera begins acquiring images depends on the - # acquisition mode. Single frame captures only a single image, multi - # frame catures a set number of images, and continuous captures a - # continuous stream of images. Because the example calls for the - # retrieval of 10 images, continuous mode has been set. - # - # *** LATER *** - # Image acquisition must be ended when no more images are needed. - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image - # - # *** NOTES *** - # Capturing an image houses images on the camera buffer. Trying - # to capture an image that does not exist will hang the camera. - # - # *** LATER *** - # Once an image from the buffer is saved and/or no longer - # needed, the image must be released in order to keep the - # buffer from filling up. - image_result = cam.GetNextImage(1000) - - # Ensure image completion - # - # *** NOTES *** - # Images can easily be checked for completion. This should be - # done whenever a complete image is expected or required. - # Further, check image status for a little more insight into - # why an image is incomplete. - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControl-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'ImageFormatControl-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure custom image settings - if not configure_custom_image_settings(nodemap): - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl_QuickSpin.py deleted file mode 100644 index 8fba164..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/ImageFormatControl_QuickSpin.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# ImageFormatControl_QuickSpin.py shows how to apply custom image -# settings to the camera using the QuickSpin API. QuickSpin is a subset of -# the Spinnaker library that allows for simpler node access and control. -# -# This example demonstrates customizing offsets X and Y, width and height, -# and the pixel format. Ensuring custom values fall within an acceptable -# range is also touched on. Retrieving and setting node values using -# QuickSpin is the only portion of the example that differs from -# ImageFormatControl. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def configure_custom_image_settings(cam): - """ - Configures a number of settings on the camera including offsets X and Y, - width, height, and pixel format. These settings must be applied before - BeginAcquisition() is called; otherwise, those nodes would be read only. - Also, it is important to note that settings are applied immediately. - This means if you plan to reduce the width and move the x offset accordingly, - you need to apply such changes in the appropriate order. - - :param cam: Camera to configure settings on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n') - - try: - result = True - - # Apply mono 8 pixel format - # - # *** NOTES *** - # In QuickSpin, enumeration nodes are as easy to set as other node - # types. This is because enum values representing each entry node - # are added to the API. - if cam.PixelFormat.GetAccessMode() == PySpin.RW: - cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono8) - print('Pixel format set to %s...' % cam.PixelFormat.GetCurrentEntry().GetSymbolic()) - - else: - print('Pixel format not available...') - result = False - - # Apply minimum to offset X - # - # *** NOTES *** - # Numeric nodes have both a minimum and maximum. A minimum is retrieved - # with the method GetMin(). Sometimes it can be important to check - # minimums to ensure that your desired value is within range. - if cam.OffsetX.GetAccessMode() == PySpin.RW: - cam.OffsetX.SetValue(cam.OffsetX.GetMin()) - print('Offset X set to %d...' % cam.OffsetX.GetValue()) - - else: - print('Offset X not available...') - result = False - - # Apply minimum to offset Y - # - # *** NOTES *** - # It is often desirable to check the increment as well. The increment - # is a number of which a desired value must be a multiple. Certain - # nodes, such as those corresponding to offsets X and Y, have an - # increment of 1, which basically means that any value within range - # is appropriate. The increment is retrieved with the method GetInc(). - if cam.OffsetY.GetAccessMode() == PySpin.RW: - cam.OffsetY.SetValue(cam.OffsetY.GetMin()) - print('Offset Y set to %d...' % cam.OffsetY.GetValue()) - - else: - print('Offset Y not available...') - result = False - - # Set maximum width - # - # *** NOTES *** - # Other nodes, such as those corresponding to image width and height, - # might have an increment other than 1. In these cases, it can be - # important to check that the desired value is a multiple of the - # increment. - # - # This is often the case for width and height nodes. However, because - # these nodes are being set to their maximums, there is no real reason - # to check against the increment. - if cam.Width.GetAccessMode() == PySpin.RW and cam.Width.GetInc() != 0 and cam.Width.GetMax != 0: - cam.Width.SetValue(cam.Width.GetMax()) - print('Width set to %i...' % cam.Width.GetValue()) - - else: - print('Width not available...') - result = False - - # Set maximum height - # - # *** NOTES *** - # A maximum is retrieved with the method GetMax(). A node's minimum and - # maximum should always be a multiple of its increment. - if cam.Height.GetAccessMode() == PySpin.RW and cam.Height.GetInc() != 0 and cam.Height.GetMax != 0: - cam.Height.SetValue(cam.Height.GetMax()) - print('Height set to %i...' % cam.Height.GetValue()) - - else: - print('Height not available...') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(cam): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param cam: Camera to get device information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - nodemap = cam.GetTLDeviceNodeMap() - - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex.message) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on the acquisition of images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** IMAGE ACQUISITION ***\n') - - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber is not None and cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - - try: - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to Mono8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8) - - # Create a unique filename - if device_serial_number: - filename = 'ImageFormatControlQS-%s-%d.jpg' % (device_serial_number, i) - else: - filename = 'ImageFormatControlQS-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo_QuickSpin example for more - in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - # Initialize camera - cam.Init() - - # Print device info - result = print_device_info(cam) - - # Configure exposure - if not configure_custom_image_settings(cam): - return False - - # Acquire images - result &= acquire_images(cam) - - # Deinitialize camera - cam.DeInit() - - return result - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - -def main(): - """ - Example entry point; please see Enumeration_QuickSpin example for more - in-depth comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Release example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Inference.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Inference.py deleted file mode 100644 index 524d8ca..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Inference.py +++ /dev/null @@ -1,1218 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Inference.py shows how to perform the following: -# - Upload custom inference neural networks to the camera (DDR or Flash) -# - Inject sample test image -# - Enable/Configure chunk data -# - Enable/Configure trigger inference ready sync -# - Acquire images -# - Display inference data from acquired image chunk data -# - Disable previously configured camera configurations -# -# Inference is only available for Firefly deep learning cameras. -# See the related content section on the Firefly DL product page for relevant -# documentation. -# https://www.flir.com/products/firefly-dl/ -# It can also be helpful to familiarize yourself with the Acquisition, -# ChunkData and FileAccess_QuickSpin examples. - -import PySpin -import numpy as np -import os -import sys -from enum import Enum - -# Use the following enum and global constant to select whether inference network -# type is Detection or Classification. - -class InferenceNetworkType(Enum): - # This network determines the most likely class given a set of predetermined, - # trained options. Object detection can also provide a location within the - # image (in the form of a "bounding box" surrounding the class), and can - # detect multiple objects. - DETECTION = 1 - # This network determines the best option from a list of predetermined options; - # the camera gives a percentage that determines the likelihood of the currently - # perceived image being one of the classes it has been trained to recognize. - CLASSIFICATION = 2 - -CHOSEN_INFERENCE_NETWORK_TYPE = InferenceNetworkType.DETECTION - -# Use the following enum and global constant to select whether uploaded inference -# network and injected image should be written to camera flash or DDR -class FileUploadPersistence(Enum): - FLASH = 1 # Slower upload but data persists after power cycling the camera - DDR = 2 # Faster upload but data clears after power cycling the camera - -CHOSEN_FILE_UPLOAD_PERSISTENCE = FileUploadPersistence.DDR - -# The example provides two existing custom networks that can be uploaded -# on to the camera to demonstrate classification and detection capabilities. -# "Network_Classification" file is created with Tensorflow using a mobilenet -# neural network for classifying flowers. -# "Network_Detection" file is created with Caffe using mobilenet SSD network -# for people object detection. -# Note: Make sure these files exist on the system and are accessible by the example -NETWORK_FILE_PATH = ("Network_Classification" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Network_Detection") - -# The example provides two raw images that can be injected into the camera -# to demonstrate camera inference classification and detection capabilities. Jpeg -# representation of the raw images can be found packaged with the example with -# the names "Injected_Image_Classification_Daisy.jpg" and "Injected_Image_Detection_Aeroplane.jpg". -# Note: Make sure these files exist on the system and are accessible by the example -INJECTED_IMAGE_FILE_PATH = ("Injected_Image_Classification.raw" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.CLASSIFICATION) \ - else "Injected_Image_Detection.raw") - -# The injected images have different ROI sizes so the camera needs to be -# configured to the appropriate width and height to match the injected image -INJECTED_IMAGE_WIDTH = 640 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 720 -INJECTED_IMAGE_HEIGHT = 400 if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.CLASSIFICATION else 540 - -# Use the following enum to represent the inference bounding box type -class InferenceBoundingBoxType(Enum): - INFERENCE_BOX_TYPE_RECTANGLE = 0 - INFERENCE_BOX_TYPE_CIRCLE = 1 - INFERENCE_BOX_TYPE_ROTATED_RECTANGLE = 2 - -# The sample classification inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_CLASSIFICATION = ["daisy", "dandelion", "roses", "sunflowers", "tulips"] - -# The sample detection inference network file was trained with the following -# data set labels -# Note: This list should match the list of labels used during the training -# stage of the network file -LABEL_DETECTION = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", - "car", "cat", "chair", "cow", "diningtable", "dog", "horse", - "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "monitor"] - -# This function prints the device information of the camera from the transport -# layer; please see NodeMapInfo example for more in-depth comments on printing -# device information from the nodemap. -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - -# This function executes a file delete operation on the camera. -def camera_delete_file(nodemap): - ptr_file_size = PySpin.CIntegerPtr(nodemap.GetNode("FileSize")) - if not PySpin.IsReadable(ptr_file_size): - print('Unable to query FileSize. Aborting...') - return False - - if ptr_file_size.GetValue() == 0: - # No file uploaded yet. Skip delete - print('No files found, skipping file deletion.') - return True - - print('Deleting file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_delete = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Delete")) - if not PySpin.IsReadable(ptr_file_operation_delete): - print('Unable to configure FileOperationSelector Delete. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_delete.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to delete file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes file open/write on the camera, sets the uploaded file persistence -# and attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write. -def camera_open_file(nodemap): - print('Opening file for writing...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_open = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Open")) - if not PySpin.IsReadable(ptr_file_operation_open): - print('Unable to configure FileOperationSelector Open. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_open.GetNumericValue())) - - ptr_file_open_mode = PySpin.CEnumerationPtr(nodemap.GetNode("FileOpenMode")) - if not PySpin.IsWritable(ptr_file_open_mode): - print('Unable to configure ptr_file_open_mode. Aborting...') - return False - - ptr_file_open_mode_write = PySpin.CEnumEntryPtr(ptr_file_open_mode.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_open_mode_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_open_mode.SetIntValue(int(ptr_file_open_mode_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to open file for writing! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - # Set file upload persistence settings - ptr_file_write_to_flash = PySpin.CBooleanPtr(nodemap.GetNode("FileWriteToFlash")) - if PySpin.IsWritable(ptr_file_write_to_flash): - if CHOSEN_FILE_UPLOAD_PERSISTENCE == FileUploadPersistence.FLASH: - ptr_file_write_to_flash.SetValue(True) - print('FileWriteToFlash is set to true') - else: - ptr_file_write_to_flash.SetValue(False) - print('FileWriteToFlash is set to false') - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessLength")) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query/configure FileAccessLength. Aborting...') - return False - - # Attempt to set FileAccessLength to FileAccessBufferNode length to speed up the write - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode("FileAccessBuffer")) - if not PySpin.IsReadable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - if ptr_file_access_length.GetValue() < ptr_file_access_buffer.GetLength(): - try: - ptr_file_access_length.SetValue(ptr_file_access_buffer.GetLength()) - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - - # Set File Access Offset to zero - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode("FileAccessOffset")) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query/configure ptrFileAccessOffset. Aborting...') - return False - ptr_file_access_offset.SetValue(0) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file write operation on the camera. -def camera_write_to_file(nodemap): - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_write = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Write")) - if not PySpin.IsReadable(ptr_file_operation_write): - print('Unable to configure FileOperationSelector Write. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_write.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus Success. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to write to file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function executes a file close operation on the camera. -def camera_close_file(nodemap): - print('Closing file...') - try: - ptr_file_operation_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationSelector")) - if not PySpin.IsWritable(ptr_file_operation_selector): - print('Unable to configure FileOperationSelector. Aborting...') - return False - - ptr_file_operation_close = PySpin.CEnumEntryPtr(ptr_file_operation_selector.GetEntryByName("Close")) - if not PySpin.IsReadable(ptr_file_operation_close): - print('Unable to configure FileOperationSelector Close. Aborting...') - return False - - ptr_file_operation_selector.SetIntValue(int(ptr_file_operation_close.GetNumericValue())) - - ptr_file_operation_execute = PySpin.CCommandPtr(nodemap.GetNode("FileOperationExecute")) - if not PySpin.IsWritable(ptr_file_operation_execute): - print('Unable to configure FileOperationExecute. Aborting...') - return False - - ptr_file_operation_execute.Execute() - - ptr_file_operation_status = PySpin.CEnumerationPtr(nodemap.GetNode("FileOperationStatus")) - if not PySpin.IsReadable(ptr_file_operation_status): - print('Unable to query FileOperationStatus. Aborting...') - return False - - ptr_file_operation_status_success = PySpin.CEnumEntryPtr(ptr_file_operation_status.GetEntryByName("Success")) - if not PySpin.IsReadable(ptr_file_operation_status_success): - print('Unable to query FileOperationStatus. Aborting...') - return False - - if ptr_file_operation_status.GetCurrentEntry().GetNumericValue() != ptr_file_operation_status_success.GetNumericValue(): - print('Failed to close the file! File Operation Status : %s' %ptr_file_operation_status.GetCurrentEntry().GetSymbolic()) - return False - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function uploads a file on the system to the camera given the selected -# file selector entry. -def upload_file_to_camera(nodemap, file_selector_entry_name, file_path): - print('\n*** CONFIGURING FILE SELECTOR ***') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode('FileSelector')) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry %s ' %file_selector_entry_name + '. Aborting...') - return False - - # Set file selector to entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - # Delete file on camera before writing in case camera runs out of space - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry %s' %ptr_inference_selector_entry.GetSymbolic() + '. Aborting...') - return False - - # Open file on camera for write - if camera_open_file(nodemap) != True: - if not camera_close_file(nodemap): - print('Problem opening file node. Aborting...') - return False - if not camera_open_file(nodemap): - print('Problem opening file node. Aborting...') - return False - - # check node - ptr_file_access_length = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessLength')) - if not PySpin.IsReadable(ptr_file_access_length) or not PySpin.IsWritable(ptr_file_access_length): - print('Unable to query FileAccessLength. Aborting...') - return False - - ptr_file_access_buffer = PySpin.CRegisterPtr(nodemap.GetNode('FileAccessBuffer')) - if not PySpin.IsReadable(ptr_file_access_buffer) or not PySpin.IsWritable(ptr_file_access_buffer): - print('Unable to query FileAccessBuffer. Aborting...') - return False - - ptr_file_access_offset = PySpin.CIntegerPtr(nodemap.GetNode('FileAccessOffset')) - if not PySpin.IsReadable(ptr_file_access_offset) or not PySpin.IsWritable(ptr_file_access_offset): - print('Unable to query FileAccessOffset. Aborting...') - return False - - ptr_file_access_result = PySpin.CIntegerPtr(nodemap.GetNode('FileOperationResult')) - if not PySpin.IsReadable(ptr_file_access_result): - print('Unable to query FileOperationResult. Aborting...') - return False - - # Load network file from path depending on network type - with open(file_path, 'rb') as fd: - fd.seek(0, os.SEEK_END) - num_bytes = fd.tell() - fd.seek(0,0) - file_bytes = np.fromfile(fd, dtype=np.ubyte, count=num_bytes) - - if len(file_bytes) == 0: - print('Failed to load file path : %s' %file_path + '. Aborting...') - return False - - total_bytes_to_write = len(file_bytes) - intermediate_buffer_size = ptr_file_access_length.GetValue() - write_iterations = (total_bytes_to_write // intermediate_buffer_size) + \ - (0 if ((total_bytes_to_write % intermediate_buffer_size) == 0) else 1) - - if total_bytes_to_write == 0: - print('Empty Image. No data will be written to camera. Aborting...') - return False - - print('Start uploading %s' %file_path + ' to device...') - - print('Total bytes to write: %s' % total_bytes_to_write) - print('FileAccessLength: %s' % intermediate_buffer_size) - print('Write iterations: %s' % write_iterations) - - bytes_left_to_write = total_bytes_to_write - total_bytes_written = 0 - - print('Writing data to device...') - - # Splitting the file into equal chunks (except the last chunk) - sections = [] - for index in range(write_iterations): - num = index * intermediate_buffer_size - if num == 0: - continue - sections.append(num) - split_data = np.array_split(file_bytes, sections) - - # Writing split data to camera - for i in range(write_iterations): - # Set up data to write - tmp_buffer = split_data[i] - - # Write to AccessBufferNode - ptr_file_access_buffer.Set(tmp_buffer) - - if intermediate_buffer_size > bytes_left_to_write: - ptr_file_access_length.SetValue(bytes_left_to_write) - - # Perform Write command - if not camera_write_to_file(nodemap): - print('Writing to stream failed. Aborting...') - return False - - # Verify size of bytes written - size_written = ptr_file_access_result.GetValue() - - # Keep track of total bytes written - total_bytes_written += size_written - - # Keep track of bytes left to write - bytes_left_to_write = total_bytes_to_write - total_bytes_written - - sys.stdout.write('\r') - sys.stdout.write('Progress: %s' % int((i*100 / write_iterations)) + '%' ) - sys.stdout.flush() - - print('\nWriting complete') - - if not camera_close_file(nodemap): - print('Failed to close file!') - - return True - -# This function deletes the file uploaded to the camera given the selected -# file selector entry. -def delete_file_on_camera(nodemap, file_selector_entry_name): - print('\n*** CLEANING UP FILE SELECTOR **') - - ptr_file_selector = PySpin.CEnumerationPtr(nodemap.GetNode("FileSelector")) - if not PySpin.IsWritable(ptr_file_selector): - print('Unable to configure FileSelector. Aborting...') - return False - - ptr_inference_selector_entry = PySpin.CEnumEntryPtr(ptr_file_selector.GetEntryByName(file_selector_entry_name)) - if not PySpin.IsReadable(ptr_inference_selector_entry): - print('Unable to query FileSelector entry ' + file_selector_entry_name + '. Aborting...') - return False - - # Set file Selector entry - print('Setting FileSelector to %s ' %ptr_inference_selector_entry.GetSymbolic() + '...\n') - ptr_file_selector.SetIntValue(int(ptr_inference_selector_entry.GetNumericValue())) - - if camera_delete_file(nodemap) != True: - print('Failed to delete existing file for selector entry') - return False - - return True - -# This function enables or disables the given chunk data type based on -# the specified entry name. -def set_chunk_enable(nodemap, entry_name, enable): - result = True - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - ptr_entry = PySpin.CEnumEntryPtr(ptr_chunk_selector.GetEntryByName(entry_name)) - if not PySpin.IsReadable(ptr_entry): - print('Unable to find ' + entry_name + ' in ChunkSelector...') - return False - - ptr_chunk_selector.SetIntValue(ptr_entry.GetValue()) - - # Enable the boolean, thus enabling the corresponding chunk data - print('Enabling ' + entry_name + '...') - ptr_chunk_enable = PySpin.CBooleanPtr(nodemap.GetNode("ChunkEnable")) - if not PySpin.IsAvailable(ptr_chunk_enable): - print('not available') - return False - - if enable: - if ptr_chunk_enable.GetValue(): - print('enabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(True) - print('enabled') - else: - print('not writable') - result = False - else: - if not ptr_chunk_enable.GetValue(): - print('disabled') - elif PySpin.IsWritable(ptr_chunk_enable): - ptr_chunk_enable.SetValue(False) - print('disabled') - else: - print('not writable') - result = False - - return result - -# This function configures the camera to add inference chunk data to each image. -# When chunk data is turned on, the data is made available in both the nodemap -# and each image. -def configure_chunk_data(nodemap): - result = True - print('\n*** CONFIGURING CHUNK DATA ***') - - try: - # Activate chunk mode - # - # *** NOTES *** - # Once enabled, chunk data will be available at the end of the payload - # of every image captured until it is disabled. Chunk data can also be - # retrieved from the nodemap. - - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to active chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(True) - print('Chunk mode activated...') - - # Enable inference related chunks in chunk data - - # Retrieve the chunk data selector node - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector (enum retrieval). Aborting...') - return False - - # Enable chunk data inference Frame Id - result = set_chunk_enable(nodemap, "InferenceFrameId", True) - if result == False: - print("Unable to enable Inference Frame Id chunk data. Aborting...") - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Enable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", True) - if result == False: - print("Unable to enable Inference Bounding Box chunk data. Aborting...") - return result - else: - # Enable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", True) - if result == False: - print("Unable to enable Inference Result chunk data. Aborting...") - return result - - # Enable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", True) - if result == False: - print("Unable to enable Inference Confidence chunk data. Aborting...") - return result - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables each type of chunk data before disabling chunk data mode. -def disable_chunk_data(nodemap): - print('\n*** DISABLING CHUNK DATA ***') - - result = True - try: - ptr_chunk_selector = PySpin.CEnumerationPtr(nodemap.GetNode("ChunkSelector")) - - if not PySpin.IsReadable(ptr_chunk_selector): - print('Unable to retrieve chunk selector. Aborting...') - return False - - result = set_chunk_enable(nodemap, "InferenceFrameId", False) - if result == False: - print('Unable to disable Inference Frame Id chunk data. Aborting...') - return result - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - # Detection network type - - # Disable chunk data inference bounding box - result = set_chunk_enable(nodemap, "InferenceBoundingBoxResult", False) - if result == False: - print('Unable to disable Inference Bounding Box chunk data. Aborting...') - return result - else: - # Classification network type - - # Disable chunk data inference result - result = set_chunk_enable(nodemap, "InferenceResult", False) - if result == False: - print('Unable to disable Inference Result chunk data. Aborting...') - return result - - # Disable chunk data inference confidence - result = set_chunk_enable(nodemap, "InferenceConfidence", False) - if result == False: - print('Unable to disable Inference Confidence chunk data. Aborting...') - return result - - # Deactivate ChunkMode - ptr_chunk_mode_active = PySpin.CBooleanPtr(nodemap.GetNode("ChunkModeActive")) - if not PySpin.IsWritable(ptr_chunk_mode_active): - print('Unable to deactivate chunk mode. Aborting...') - return False - - ptr_chunk_mode_active.SetValue(False) - print('Chunk mode deactivated...') - - # Disable Inference - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to disable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(False) - print('Inference disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function displays the inference-related chunk data from the image. -def display_chunk_data(image): - result = True - print('Printing chunk data from image...') - - try: - chunk_data = image.GetChunkData() - - inference_frame_ID = chunk_data.GetInferenceFrameId() - print('\tInference Frame ID: %s' % inference_frame_ID) - - if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION: - box_result = chunk_data.GetInferenceBoundingBoxResult() - box_count = box_result.GetBoxCount() - - print('\tInference Bounding Box Result:') - if box_count == 0: - print('\t No bounding box') - - for i in range(box_count): - box = box_result.GetBoxAt(i) - if box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} W={7} H={8})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rectangle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.rect.bottomRightXCoord - box.rect.topLeftXCoord, - box.rect.bottomRightYCoord - box.rect.topLeftYCoord)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_CIRCLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X={5} Y={6} R={7})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Circle", - box.rect.topLeftXCoord, - box.rect.topLeftYCoord, - box.circle.radius)) - elif box.boxType == InferenceBoundingBoxType.INFERENCE_BOX_TYPE_ROTATED_RECTANGLE.value: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4} (X1={5} Y1={6} X2={7} Y2={8} angle={9})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Rotated Rectangle", - box.rotatedRect.topLeftXCoord, - box.rotatedRect.topLeftYCoord, - box.rotatedRect.bottomRightXCoord, - box.rotatedRect.bottomRightYCoord, - box.rotatedRect.rotationAngle)) - else: - print('\t\tBox {0}: Class {1} ({2}): - {3:.4f}% - {4})' - .format(i+1, - box.classId, - LABEL_DETECTION[box.classId] if box.classId < len(LABEL_DETECTION) else "N/A", - box.confidence * 100, - "Unknown bounding box type (not supported)")) - else: - inference_result = chunk_data.GetInferenceResult() - print('\t Inference Result: %s' %inference_result, end = '') - print(' (%s)' % LABEL_CLASSIFICATION[inference_result] if inference_result < len(LABEL_CLASSIFICATION) else "N/A") - - inference_confidence = chunk_data.GetInferenceConfidence() - print('\t Inference Confidence: %.6f' %inference_confidence) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function disables trigger mode on the camera. -def disable_trigger(nodemap): - print('\n*** IMAGE ACQUISITION ***') - - try: - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_off = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_trigger_off): - print('Unable to query TriggerMode Off. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_off.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_off.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera to run in "inference sync" trigger mode. -def configure_trigger(nodemap): - print('\n*** CONFIGURING TRIGGER ***') - - try: - # Configure TriggerSelector - ptr_trigger_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSelector")) - if not PySpin.IsWritable(ptr_trigger_selector): - print('Unable to configure TriggerSelector. Aborting...') - return False - - ptr_frame_start = PySpin.CEnumEntryPtr(ptr_trigger_selector.GetEntryByName("FrameStart")) - if not PySpin.IsReadable(ptr_frame_start): - print('Unable to query TriggerSelector FrameStart. Aborting...') - return False - - print('Configure TriggerSelector to ' + ptr_frame_start.GetSymbolic()) - ptr_trigger_selector.SetIntValue(int(ptr_frame_start.GetNumericValue())) - - # Configure TriggerSource - ptr_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerSource")) - if not PySpin.IsWritable(ptr_trigger_source): - print('Unable to configure TriggerSource. Aborting...') - return False - - ptr_inference_ready = PySpin.CEnumEntryPtr(ptr_trigger_source.GetEntryByName("InferenceReady")) - if not PySpin.IsReadable(ptr_inference_ready): - print('Unable to query TriggerSource InferenceReady. Aborting...') - return False - - print('Configure TriggerSource to ' + ptr_inference_ready.GetSymbolic()) - ptr_trigger_source.SetIntValue(int(ptr_inference_ready.GetNumericValue())) - - # Configure TriggerMode - ptr_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode("TriggerMode")) - if not PySpin.IsWritable(ptr_trigger_mode): - print('Unable to configure TriggerMode. Aborting...') - return False - - ptr_trigger_on = PySpin.CEnumEntryPtr(ptr_trigger_mode.GetEntryByName("On")) - if not PySpin.IsReadable(ptr_trigger_on): - print('Unable to query TriggerMode On. Aborting...') - return False - - print('Configure TriggerMode to ' + ptr_trigger_on.GetSymbolic()) - ptr_trigger_mode.SetIntValue(int(ptr_trigger_on.GetNumericValue())) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function enables/disables inference on the camera and configures the inference network type -def configure_inference(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING INFERENCE (' + ("DETECTION" if ((CHOSEN_INFERENCE_NETWORK_TYPE) \ - == InferenceNetworkType.DETECTION) \ - else 'CLASSIFICATION') + ') ***') - else: - print('\n*** DISABLING INFERENCE ***') - - try: - if is_enabled: - ptr_inference_network_type_selector = PySpin.CEnumerationPtr(nodemap.GetNode("InferenceNetworkTypeSelector")) - if not PySpin.IsWritable(ptr_inference_network_type_selector): - print('Unable to query InferenceNetworkTypeSelector. Aborting...') - return False - - network_type_string = ("Detection" if CHOSEN_INFERENCE_NETWORK_TYPE == InferenceNetworkType.DETECTION - else "Classification") - - # Retrieve entry node from enumeration node - ptr_inference_network_type = PySpin.CEnumEntryPtr(ptr_inference_network_type_selector.GetEntryByName(network_type_string)) - if not PySpin.IsReadable(ptr_inference_network_type): - print('Unable to set inference network type to %s' %network_type_string + ' (entry retrieval). Aborting...') - return False - - inference_network_value = ptr_inference_network_type.GetNumericValue() - ptr_inference_network_type_selector.SetIntValue(int(inference_network_value)) - - print('Inference network type set to' + network_type_string + '...') - - print(('Enabling' if is_enabled else 'Disabling') + ' inference...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode("InferenceEnable")) - if not PySpin.IsWritable(ptr_inference_enable): - print('Unable to enable inference. Aborting...') - return False - - ptr_inference_enable.SetValue(is_enabled) - print('Inference '+'enabled...' if is_enabled else 'disabled...') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function configures camera test pattern to make use of the injected test image for inference -def configure_test_pattern(nodemap, is_enabled): - if is_enabled: - print('\n*** CONFIGURING TEST PATTERN ***') - else: - print('\n*** DISABLING TEST PATTERN ***') - - try: - # Set TestPatternGeneratorSelector to PipelineStart - ptr_test_pattern_generator_selector = PySpin.CEnumerationPtr(nodemap.GetNode("TestPatternGeneratorSelector")) - if not PySpin.IsWritable(ptr_test_pattern_generator_selector): - print('Unable to query TestPatternGeneratorSelector. Aborting...') - return False - - if is_enabled: - ptr_test_pattern_generator_pipeline_start = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("PipelineStart")) - if not PySpin.IsReadable(ptr_test_pattern_generator_pipeline_start): - print('Unable to query TestPatternGeneratorSelector PipelineStart. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_pipeline_start.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_pipeline_start.GetSymbolic() + '...') - - else: - ptr_test_pattern_generator_sensor = PySpin.CEnumEntryPtr(ptr_test_pattern_generator_selector.GetEntryByName("Sensor")) - if not PySpin.IsReadable(ptr_test_pattern_generator_sensor): - print('Unable to query TestPatternGeneratorSelector Sensor. Aborting...') - return False - - ptr_test_pattern_generator_selector.SetIntValue(int(ptr_test_pattern_generator_sensor.GetNumericValue())) - print('TestPatternGeneratorSelector set to ' + ptr_test_pattern_generator_sensor.GetSymbolic() + '...') - - # Set TestPattern to InjectedImage - ptr_test_pattern = PySpin.CEnumerationPtr(nodemap.GetNode("TestPattern")) - if not PySpin.IsWritable(ptr_test_pattern): - print('Unable to query TestPattern. Aborting...') - return False - - if is_enabled: - ptr_injected_image = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("InjectedImage")) - if not PySpin.IsReadable(ptr_injected_image): - print('Unable to query TestPattern InjectedImage. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_injected_image.GetNumericValue())) - print('TestPattern set to ' + ptr_injected_image.GetSymbolic() + '...') - else: - ptr_test_pattern_off = PySpin.CEnumEntryPtr(ptr_test_pattern.GetEntryByName("Off")) - if not PySpin.IsReadable(ptr_test_pattern_off): - print('Unable to query TestPattern Off. Aborting...') - return False - - ptr_test_pattern.SetIntValue(int(ptr_test_pattern_off.GetNumericValue())) - print('TestPattern set to ' + ptr_test_pattern_off.GetSymbolic() + '...') - - if is_enabled: - # The inject images have different ROI sizes so camera needs to be configured to the appropriate - # injected width and height - ptr_injected_width = PySpin.CIntegerPtr(nodemap.GetNode("InjectedWidth")) - if not PySpin.IsWritable(ptr_injected_width): - print('Unable to query InjectedWidth. Aborting...') - return False - - ptr_injected_width.SetValue(INJECTED_IMAGE_WIDTH if is_enabled else ptr_injected_width.GetMax()) - - ptr_injected_height = PySpin.CIntegerPtr(nodemap.GetNode("InjectedHeight")) - if not PySpin.IsWritable(ptr_injected_height): - print('Unable to query InjectedHeight. Aborting...') - return False - - ptr_injected_height.SetValue(INJECTED_IMAGE_HEIGHT if is_enabled else ptr_injected_height.GetMax()) - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return True - -# This function acquires and saves 10 images from a device; please see -# Acquisition example for more in-depth comments on acquiring images. -def acquire_images(cam, nodemap, nodemap_tldevice): - result = True - print('\n*** IMAGE ACQUISITION ***') - - try: - # Set acquisition mode to continuous - ptr_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsWritable(ptr_acquisition_mode): - print('Unable to set acquisition mode to continuous (node retrieval). Aborting...') - return False - - ptr_acquisition_mode_continuous = PySpin.CEnumEntryPtr(ptr_acquisition_mode.GetEntryByName("Continuous")) - if not PySpin.IsReadable(ptr_acquisition_mode_continuous): - print("'Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...") - return False - - acquisition_mode_continuous = ptr_acquisition_mode_continuous.GetValue() - - ptr_acquisition_mode.SetIntValue(int(acquisition_mode_continuous)) - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - ptr_string_serial = PySpin.CStringPtr(nodemap.GetNode("DeviceSerialNumber")) - if PySpin.IsReadable(ptr_string_serial): - device_serial_number = ptr_string_serial.GetValue() - print('Device serial number retrieved as %s' %device_serial_number) - print('\n') - - # Retrieve, convert, and save images - num_images = 10 - - for i in range(num_images): - try: - result_image = cam.GetNextImage(1000) - - if result_image.IsIncomplete(): - print('Image incomplete with image status %d ...' % result_image.GetImageStatus()) - else: - print('Grabbed Image %d, width = %d, height = %d' \ - % (i, result_image.GetWidth(), result_image.GetHeight())) - - result = display_chunk_data(result_image) - - # Release image - result_image.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - cam.EndAcquisition() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - return False - - return result - -# This function acts as the body of the example; please see NodeMapInfo example -# for more in-depth comments on setting up cameras. -def run_single_camera(cam): - result = False - err = 0 - - try: - nodemap_tldevice = cam.GetTLDeviceNodeMap() - result = print_device_info(nodemap_tldevice) - - cam.Init() - - nodemap = cam.GetNodeMap() - - # Check to make sure camera supports inference - print('Checking camera inference support...') - ptr_inference_enable = PySpin.CBooleanPtr(nodemap.GetNode('InferenceEnable')) - if not PySpin.IsWritable(ptr_inference_enable): - print('Inference is not supported on this camera. Aborting...') - return False - - # Upload custom inference network onto the camera - # The inference network file is in a movidius specific neural network format. - # Uploading the network to the camera allows for "inference on the edge" where - # camera can apply deep learning on a live stream. Refer to "Getting Started - # with Firefly-DL" for information on how to create your own custom inference - # network files using pre-existing neural network. - err = upload_file_to_camera(nodemap, "InferenceNetwork", NETWORK_FILE_PATH) - if err != True: - return err - - # Upload injected test image - # Instead of applying deep learning on a live stream, the camera can be - # tested with an injected test image. - err = upload_file_to_camera(nodemap, "InjectedImage", INJECTED_IMAGE_FILE_PATH) - if err != True: - return err - - # Configure inference - err = configure_inference(nodemap, True) - if err != True: - return err - - # Configure test pattern to make use of the injected image - err = configure_test_pattern(nodemap, True) - if err != True: - return err - - # Configure trigger - # When enabling inference results via chunk data, the results that accompany a frame - # will likely not be the frame that inference was run on. In order to guarantee that - # the chunk inference results always correspond to the frame that they are sent with, - # the camera needs to be put into the "inference sync" trigger mode. - # Note: Enabling this setting will limit frame rate so that every frame contains new - # inference dataset. To not limit the frame rate, you can enable InferenceFrameID - # chunk data to help determine which frame is associated with a particular - # inference data. - err = configure_trigger(nodemap) - if err != True: - return err - - # Configure chunk data - err = configure_chunk_data(nodemap) - if err != True: - return err - - # Acquire images and display chunk data - result = result | acquire_images(cam, nodemap, nodemap_tldevice) - - # Disable chunk data - err = disable_chunk_data(nodemap) - if err != True: - return err - - # Disable trigger - err = disable_trigger(nodemap) - if err != True: - return err - - # Disable test pattern - err = configure_test_pattern(nodemap, False) - if err != True: - return err - - # Disable inference - err = configure_inference(nodemap, False) - if err != True: - return err - - # Clear injected test image - err = delete_file_on_camera(nodemap, "InjectedImage") - if err != True: - return err - - # Clear uploaded inference network - err = delete_file_on_camera(nodemap, "InferenceNetwork") - if err != True: - return err - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print('Unexpected exception: %s' % ex) - result = False - - return result - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = False - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %s\n' % num_cameras) - - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - for i, cam in enumerate(cam_list): - print('Running example for camera %d...' % i) - result = result | run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification.raw b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification.raw deleted file mode 100644 index e79db8f..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification.raw and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification_Daisy.jpg b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification_Daisy.jpg deleted file mode 100644 index 128f332..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Classification_Daisy.jpg and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection.raw b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection.raw deleted file mode 100644 index e1c3100..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection.raw and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection_Aeroplane.jpg b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection_Aeroplane.jpg deleted file mode 100644 index 8e3cefc..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Injected_Image_Detection_Aeroplane.jpg and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Logging.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Logging.py deleted file mode 100644 index 4501a54..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Logging.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Logging.py shows how to create a handler to access logging events. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the NodeMapCallback -# example, as nodemap callbacks follow the same general procedure as -# events, but with a few less steps. -# -# This example creates a user-defined class, LoggingEventHandler, that inherits -# from the Spinnaker class, LoggingEventHandler. The child class allows the user to -# define any properties, parameters, and the event handler itself while LoggingEventHandler -# allows the child class to appropriately interface with the Spinnaker SDK. - -import PySpin - - -# Define callback priority threshold; please see documentation for additional -# information on logging level philosophy. -LOGGING_LEVEL = PySpin.LOG_LEVEL_DEBUG # change to any LOG_LEVEL_* constant - - -class LoggingEventHandler(PySpin.LoggingEventHandler): - """ - Although logging events are just as flexible and extensible as other events, - they are generally only used for logging purposes, which is why a number of - helpful functions that provide logging information have been added. Generally, - if the purpose is not logging, one of the other event types is probably more - appropriate. - """ - - def __init__(self): - super(LoggingEventHandler, self).__init__() - - def OnLogEvent(self, logging_event_data): - """ - This function displays readily available logging information. - - :param logging_event_data: Logging data. - :type logging_event_data: LoggingEventData - :rtype: None - """ - print('--------Log Event Received----------') - print('Category: %s' % logging_event_data.GetCategoryName()) - print('Priority Value: %s' % logging_event_data.GetPriority()) - print('Priority Name: %s' % logging_event_data.GetPriorityName()) - print('Timestamp: %s' % logging_event_data.GetTimestamp()) - print('NDC: %s' % logging_event_data.GetNDC()) - print('Thread: %s' % logging_event_data.GetThreadName()) - print('Message: %s' % logging_event_data.GetLogMessage()) - print('------------------------------------\n') - - -def main(): - """ - Example entry point; notice the volume of data that the logging event handler - prints out on debug despite the fact that very little really happens in this - example. Because of this, it may be better to have the logger set to lower - level in order to provide a more concise, focused log. - - :rtype: None - """ - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Create and register the logging event handler - # - # *** NOTES *** - # Logging event handlers are registered to the system. Take note that a logging - # event handler is very verbose when the logging level is set to debug. - # - # *** LATER *** - # Logging event handlers must be unregistered manually. This must be done prior to - # releasing the system and while the logging event handlers are still in scope. - logging_event_handler = LoggingEventHandler() - system.RegisterLoggingEventHandler(logging_event_handler) - - # Set callback priority level - # - # *** NOTES *** - # Please see documentation for up-to-date information on the logging - # philosophies of the Spinnaker SDK. - system.SetLoggingEventPriorityLevel(LOGGING_LEVEL) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i' % num_cams) - - # Clear camera list before releasing system - cam_list.Clear() - - # Unregister logging event handler - # - # *** NOTES *** - # It is important to unregister all logging event handlers from the system. - system.UnregisterLoggingEventHandler(logging_event_handler) - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - - -if __name__ == '__main__': - main() diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/LookupTable.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/LookupTable.py deleted file mode 100644 index 851b6d0..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/LookupTable.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= - -# LookupTable.py -# -# LookupTable.py shows how to configure lookup tables on the camera. -# It relies on information provided in the Enumeration, Acquisition, and -# NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# Lookup tables allow for the customization and control of individual pixels. -# This can be a very powerful and deeply useful tool; however, because use -# cases are context dependent, this example only explores lookup table -# configuration. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node" or "Entry" - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print("Unable to get {} ({} {} retrieval failed.)".format(node, name, node)) - print("The {} may not be available on all camera models...".format(node)) - print("Please try a Blackfly S camera.") - - -def configure_lookup_tables(nodemap): - """ - This function configures lookup tables linearly. This involves selecting the - type of lookup table, finding the appropriate increment calculated from the - maximum value, and enabling lookup tables on the camera. - - :param nodemap: Device nodemap - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("***CONFIGURING LOOKUP TABLES***\n") - - # Select lookup table type - # - # ***NOTES *** - # Setting the lookup table selector. It is important to note that this - # does not enable lookup tables. - - try: - lut_selector = PySpin.CEnumerationPtr(nodemap.GetNode("LUTSelector")) - if not PySpin.IsAvailable(lut_selector) or not PySpin.IsWritable(lut_selector): - print_retrieve_node_failure("node", "LUTSelector") - return False - - lut_selector_lut1 = lut_selector.GetEntryByName("LUT1") - if not PySpin.IsAvailable(lut_selector_lut1) or not PySpin.IsReadable(lut_selector_lut1): - print_retrieve_node_failure("entry", "LUTSelector LUT1") - return False - - lut_selector.SetIntValue(lut_selector_lut1.GetValue()) - print("Lookup table selector set to LUT 1...\n") - - # Determine pixel increment and set indexes and values as desired - # - # *** NOTES *** - # To get the pixel increment, the maximum range of the value node must - # first be retrieved. The value node represents an index, so its value - # should be one less than a power of 2 (e.g. 511, 1023, etc.). Add 1 to - # this index to get the maximum range. Divide the maximum range by 512 - # to calculate the pixel increment. - # - # Finally, all values (in the value node) and their corresponding - # indexes (in the index node) need to be set. The goal of this example - # is to set the lookup table linearly. As such, the slope of the values - # should be set according to the increment, but the slope of the - # indexes is inconsequential. - - # Retrieve value node - lut_value = PySpin.CIntegerPtr(nodemap.GetNode("LUTValue")) - if not PySpin.IsAvailable(lut_value) or not PySpin.IsWritable(lut_value): - print_retrieve_node_failure("node", "LUTValue") - return False - - # Retrieve maximum range - max_range = lut_value.GetMax() + 1 - print("\tMaximum Range: {}".format(max_range)) - - # Calculate increment - increment = max_range / 512 - print("\tIncrement: {}".format(increment)) - - # Retrieve index node - lut_index = PySpin.CIntegerPtr(nodemap.GetNode("LUTIndex")) - if not PySpin.IsAvailable(lut_index) or not PySpin.IsWritable(lut_index): - print_retrieve_node_failure("node", "LUTIndex") - return False - - # Set values and indexes - i = 0 - while i < max_range: - lut_index.SetValue(int(i)) - lut_value.SetValue(int(i)) - i += increment - - print("All lookup table values set...\n") - - # Enable lookup tables - # - # *** NOTES *** - # Once lookup tables have been configured, don"t forget to enable them - # with the appropriate node. - # - # *** LATER *** - # Once the images with lookup tables have been collected, turn the - # feature off with the same node. - - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print_retrieve_node_failure("node", "LUTEnable") - return False - - lut_enable.SetValue(True) - print("Lookup tables enabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def reset_lookup_tables(nodemap): - """ - This function resets the camera by disabling lookup tables. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - # Disable lookup tables - # - # *** NOTES *** - # Turn lookup tables off when they are not needed to reduce overhead - - try: - lut_enable = PySpin.CBooleanPtr(nodemap.GetNode("LUTEnable")) - if not PySpin.IsAvailable(lut_enable) or not PySpin.IsWritable(lut_enable): - print("Unable to disable lookup tables. Non-fatal error...\n") - return False - - lut_enable.SetValue(False) - print("Lookup tables disabled...\n") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - # This function prints the device information of the camera from the transport - # layer; please see NodeMapInfo example for more in-depth comments on printing - # device information from the nodemap. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** DEVICE INFORMATION ***\n") - - try: - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode("DeviceInformation")) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - if PySpin.IsReadable(node_feature): - feature_string = node_feature.ToString() - else: - feature_string = "Node not readable" - - print("{}: {}".format(node_feature.GetName(), feature_string)) - - else: - print("Device control information not available.") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def acquire_images(cam, nodemap, nodemap_tl_device): - """ - This function acquires and saves 10 images from a device; please see - Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from - :param nodemap: Device nodemap - :param nodemap_tl_device: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tl_device: INodeMap - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - print("*** IMAGE ACQUISITION ***\n") - - # Set acquisition mode to continuous - try: - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionMode")) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n") - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName("Continuous") - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print("Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting...\n") - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - print("Acquisition mode set to continuous...\n") - - # Begin acquiring images - cam.BeginAcquisition() - print("Acquiring images...\n") - - # Retrieve device serial number for filename - device_serial_number = "" - node_device_serial_number = PySpin.CStringPtr(nodemap_tl_device.GetNode("DeviceSerialNumber")) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print("Device serial number retrieved as {}...".format(device_serial_number)) - - print("") - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(1000) - - if image_result.IsIncomplete(): - print("Image incomplete with image status {}...".format(image_result.GetImageStatus())) - - else: - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print("Grabbed image {}, width = {}, height = {}".format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = "LookupTable-{}-{}.jpg".format(device_serial_number, i) - else: # if serial number is empty - filename = "LookupTable-{}.jpg".format(i) - - # Save image - image_converted.Save(filename) - print("Image saved at {}".format(filename)) - - # Release image - image_result.Release() - print("") - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: returns True if successful, False otherwise - :rtype: bool - """ - result = True - - try: - # Retrieve TL device nodemap and print device information - nodemap_tl_device = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tl_device) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure lookup tables - result &= configure_lookup_tables(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tl_device) - - # Reset lookup tables - result &= reset_lookup_tables(nodemap) - - # Deinitialize camera - cam.DeInit() - except PySpin.SpinnakerException as ex: - print("Error: {}".format(ex)) - result = False - - return result - - -def main(): - """ - Since this application saves images in the current folder - we must ensure that we have permission to write to this folder. - If we do not have permission, fail right away. - - :return: returns True if successful, False otherwise - :rtype: bool - """ - try: - test_file = open("test.txt", "w+") - except IOError: - print("Unable to write to current directory. Please check permissions.\n") - input("Press Enter to exit...") - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print("Library version: {}.{}.{}.{}\n".format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print("Number of cameras detected: {}\n".format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - # Release system instance - system.ReleaseInstance() - print("Not enough cameras!\n") - input("Done! Press Enter to exit...") - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - print("Running example for camera {}...\n".format(i)) - - result &= run_single_camera(cam) - print("Camera {} example complete...\n".format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input("Done! Press Enter to exit...") - return result - - -if __name__ == "__main__": - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Classification b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Classification deleted file mode 100644 index a7a5513..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Classification and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Detection b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Detection deleted file mode 100644 index 838b384..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Network_Detection and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapCallback.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapCallback.py deleted file mode 100644 index 0db4cc7..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapCallback.py +++ /dev/null @@ -1,424 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapCallback.py shows how to use nodemap callbacks. It relies -# on information provided in the Enumeration, Acquisition, and NodeMapInfo -# examples. As callbacks are very similar to events, it may be a good idea to -# explore this example prior to tackling the events examples. -# -# This example focuses on creating, registering, using, and unregistering -# callbacks. A callback requires a callback class with a callback function signature, -# which allows it to be registered to and access a node. Events follow this same pattern. -# -# Once comfortable with NodeMapCallback, we suggest checking out any of the -# events examples: DeviceEvents, EnumerationEvents, ImageEvents, or Logging. - -import PySpin -import sys - - -class HeightNodeCallback(PySpin.NodeCallback): - """ - This is the first of two callback classes. This callback will be registered to the height node. - Node callbacks must inherit from NodeCallback, and must implement CallbackFunction with the same function signature. - - NOTE: Instances of callback classes must not go out of scope until they are deregistered, otherwise segfaults - will occur. - """ - def __init__(self): - super(HeightNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the height node changes and triggers a callback. - - :param node: Height node. - :type node: INode - :rtype: None - """ - node_height = PySpin.CIntegerPtr(node) - print('Height callback message:\n\tLook! Height changed to %f...\n' % node_height.GetValue()) - - -class GainNodeCallback(PySpin.NodeCallback): - """ - This is the second callback class, registered to the gain node. - """ - def __init__(self): - super(GainNodeCallback, self).__init__() - - def CallbackFunction(self, node): - """ - This function gets called when the gain node changes and triggers a callback. - - :param node: Gain node. - :type node: INode - :rtype: None - """ - node_gain = PySpin.CFloatPtr(node) - print('Gain callback message:\n\tLook! Gain changed to %f...\n' % node_gain.GetValue()) - - -def configure_callbacks(nodemap): - """ - This function sets up the example by disabling automatic gain, creating the callbacks, and registering them to - their specific nodes. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :returns: tuple (result, callback_height, callback_gain) - WHERE - result is True if successful, False otherwise - callback_height is the HeightNodeCallback instance registered to the height node - callback_gain is the GainNodeCallback instance registered to the gain node - :rtype: (bool, HeightNodeCallback, GainNodeCallback) - """ - print('\n*** CONFIGURING CALLBACKS ***\n') - try: - result = True - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs to - # be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned off at the end of the example in order - # to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to disable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_off = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Off')) - if not PySpin.IsAvailable(node_gain_auto_off) or not PySpin.IsReadable(node_gain_auto_off): - print('Unable to disable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_off.GetValue()) - print('Automatic gain disabled...') - - # Register callback to height node - # - # *** NOTES *** - # Callbacks need to be registered to nodes, which should be writable - # if the callback is to ever be triggered. Also ensure that the callback - # instance does not go out of scope, as it will get garbage-collected - # and a segfault will result once the callback actually occurs. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height): - print('Unable to retrieve height. Aborting...\n') - return False - - print('Height ready...') - - callback_height = HeightNodeCallback() - PySpin.RegisterNodeCallback(node_height.GetNode(), callback_height) - - print('Height callback registered...') - - # Register callback to gain node - # - # *** NOTES *** - # Depending on the specific goal of the function, it can be important - # to notice the node type that a callback is registered to. Notice in - # the callback functions above that the callback registered to height - # casts its node as an integer whereas the callback registered to gain - # casts as a float. - # - # *** LATER *** - # Each callback needs to be unregistered individually before releasing - # the system or an exception will be thrown. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print('Unable to retrieve gain. Aborting...\n') - return False - - print('Gain ready...') - - callback_gain = GainNodeCallback() - PySpin.RegisterNodeCallback(node_gain.GetNode(), callback_gain) - print('Gain callback registered...\n') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, callback_height, callback_gain - - -def change_height_and_gain(nodemap): - """ - This function demonstrates the triggering of the nodemap callbacks. First it - changes height, which executes the callback registered to the height node, and - then it changes gain, which executes the callback registered to the gain node. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n***CHANGE HEIGHT & GAIN ***\n') - - try: - result = True - - # Change height to trigger height callback - # - # *** NOTES *** - # Notice that changing the height only triggers the callback function - # registered to the height node. - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsWritable(node_height) \ - or node_height.GetInc() == 0 or node_height.GetMax() == 0: - - print('Unable to retrieve height. Aborting...') - return False - - height_to_set = node_height.GetMax() - - print('Regular function message:\n\tHeight about to be changed to %i...\n' % height_to_set) - - node_height.SetValue(height_to_set) - - # Change gain to trigger gain callback - # - # *** NOTES *** - # The same is true of changing the gain node; changing a node will - # only ever trigger the callback function (or functions) currently - # registered to it. - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain) or node_gain.GetMax() == 0: - print('Unable to retrieve gain...') - return False - - gain_to_set = node_gain.GetMax() / 2.0 - - print('Regular function message:\n\tGain about to be changed to %f...\n' % gain_to_set) - node_gain.SetValue(gain_to_set) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def reset_callbacks(nodemap, callback_height, callback_gain): - """ - This function cleans up the example by deregistering the callbacks and - turning automatic gain back on. - - :param nodemap: Device nodemap. - :param callback_height: Height node callback instance to deregister. - :param callback_gain: Gain node callback instance to deregister. - :type nodemap: INodeMap - :type callback_height: HeightNodeCallback - :type callback_gain: GainNodeCallback - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Deregister callbacks - # - # *** NOTES *** - # It is important to deregister each callback function from each node - # that it is registered to. - PySpin.DeregisterNodeCallback(callback_height) - PySpin.DeregisterNodeCallback(callback_gain) - - print('Callbacks deregistered...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned back on in order to restore the camera to - # its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print('Unable to enable automatic gain (node retrieval). Aborting...') - return False - - node_gain_auto_continuous = PySpin.CEnumEntryPtr(node_gain_auto.GetEntryByName('Continuous')) - if not PySpin.IsAvailable(node_gain_auto_continuous) or not PySpin.IsReadable(node_gain_auto_continuous): - print('Unable to enable automatic gain (enum entry retrieval). Aborting...') - return False - - node_gain_auto.SetIntValue(node_gain_auto_continuous.GetValue()) - print('Automatic gain disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to setup and run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure callbacks - err, callback_height, callback_gain = configure_callbacks(nodemap) - if not err: - return err - - # Change height and gain to trigger callbacks - result &= change_height_and_gain(nodemap) - - # Reset callbacks - result &= reset_callbacks(nodemap, callback_height, callback_gain) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo.py deleted file mode 100644 index c8224cc..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo.py shows how to retrieve node map information. It relies -# on information provided in the Enumeration example. Also, check out the -# Acquisition and ExceptionHandling examples if you haven't already. -# Acquisition demonstrates image acquisition while ExceptionHandling shows the -# handling of standard and Spinnaker exceptions. -# -# This example explores retrieving information from all major node types on the -# camera. This includes string, integer, float, boolean, command, enumeration, -# category, and value types. Looping through multiple child nodes is also -# covered. A few node types are not covered - base, port, and register - as -# they are not fundamental. The final node type - enumeration entry - is -# explored only in terms of its parent node type - enumeration. -# -# Once comfortable with NodeMapInfo, we suggest checking out ImageFormatControl -# and Exposure. ImageFormatControl explores customizing image settings on a -# camera while Exposure introduces the standard structure of configuring a -# device, acquiring some images, and then returning the device to a default -# state. - -import PySpin -import sys - -# Defines max number of characters that will be printed out for any node information -MAX_CHARS = 35 - - -class ReadType: - """ - Use the following constants to determine whether nodes are read - as Value nodes or their individual types. - """ - VALUE = 0, - INDIVIDUAL = 1 - -CHOSEN_READ = ReadType.INDIVIDUAL - - -def print_with_indent(level, text): - """ - Helper function for printing a string prefix with a specifc number of indents. - :param level: Number of indents to generate - :type level: int - :param text: String to print after indent - :type text: str - """ - ind = '' - for i in range(level): - ind += ' ' - print('%s%s' % (ind, text)) - - -def print_value_node(node, level): - """ - Retrieves and prints the display name and value of all node types as value nodes. - A value node is a general node type that allows for the reading and writing of any node type as a string. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create value node - node_value = PySpin.CValuePtr(node) - - # Retrieve display name - # - # *** NOTES *** - # A node's 'display name' is generally more appropriate for output and - # user interaction whereas its 'name' is what the camera understands. - # Generally, its name is the same as its display name but without - # spaces - for instance, the name of the node that houses a camera's - # serial number is 'DeviceSerialNumber' while its display name is - # 'Device Serial Number'. - display_name = node_value.GetDisplayName() - - # Retrieve value of any node type as string - # - # *** NOTES *** - # Because value nodes return any node type as a string, it can be much - # easier to deal with nodes as value nodes rather than their actual - # individual types. - value = node_value.ToString() - - # Cap length at MAX_CHARS - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_string_node(node, level): - """ - Retrieves and prints the display name and value of a string node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create string node - node_string = PySpin.CStringPtr(node) - - # Retrieve string node value - # - # *** NOTES *** - # Functions in Spinnaker C++ that use gcstring types - # are substituted with Python strings in PySpin. - # The only exception is shown in the DeviceEvents example, where - # the callback function still uses a wrapped gcstring type. - display_name = node_string.GetDisplayName() - - # Ensure that the value length is not excessive for printing - value = node_string.GetValue() - value = value[:MAX_CHARS] + '...' if len(value) > MAX_CHARS else value - - # Print value; 'level' determines the indentation level of output - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_integer_node(node, level): - """ - Retrieves and prints the display name and value of an integer node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create integer node - node_integer = PySpin.CIntegerPtr(node) - - # Get display name - display_name = node_integer.GetDisplayName() - - # Retrieve integer node value - # - # *** NOTES *** - # All node types except base nodes have a ToString() - # method which returns a value as a string. - value = node_integer.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_float_node(node, level): - """ - Retrieves and prints the display name and value of a float node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create float node - node_float = PySpin.CFloatPtr(node) - - # Get display name - display_name = node_float.GetDisplayName() - - # Retrieve float value - value = node_float.GetValue() - - # Print value - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_boolean_node(node, level): - """ - Retrieves and prints the display name and value of a Boolean node. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create Boolean node - node_boolean = PySpin.CBooleanPtr(node) - - # Get display name - display_name = node_boolean.GetDisplayName() - - # Retrieve Boolean value - value = node_boolean.GetValue() - - # Print Boolean value - # NOTE: In Python a Boolean will be printed as "True" or "False". - print_with_indent(level, '%s: %s' % (display_name, value)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_command_node(node, level): - """ - This function retrieves and prints the display name and tooltip of a command - node, limiting the number of printed characters to a macro-defined maximum. - The tooltip is printed below because command nodes do not have an intelligible - value. - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create command node - node_command = PySpin.CCommandPtr(node) - - # Get display name - display_name = node_command.GetDisplayName() - - # Retrieve tooltip - # - # *** NOTES *** - # All node types have a tooltip available. Tooltips provide useful - # information about nodes. Command nodes do not have a method to - # retrieve values as their is no intelligible value to retrieve. - tooltip = node_command.GetToolTip() - - # Ensure that the value length is not excessive for printing - tooltip = tooltip[:MAX_CHARS] + '...' if len(tooltip) > MAX_CHARS else tooltip - - # Print display name and tooltip - print_with_indent(level, '%s: %s' % (display_name, tooltip)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_enumeration_node_and_current_entry(node, level): - """ - This function retrieves and prints the display names of an enumeration node - and its current entry (which is actually housed in another node unto itself). - - :param node: Node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create enumeration node - node_enumeration = PySpin.CEnumerationPtr(node) - - # Retrieve current entry as enumeration node - # - # *** NOTES *** - # Enumeration nodes have three methods to differentiate between: first, - # GetIntValue() returns the integer value of the current entry node; - # second, GetCurrentEntry() returns the entry node itself; and third, - # ToString() returns the symbolic of the current entry. - node_enum_entry = PySpin.CEnumEntryPtr(node_enumeration.GetCurrentEntry()) - - # Get display name - display_name = node_enumeration.GetDisplayName() - - # Retrieve current symbolic - # - # *** NOTES *** - # Rather than retrieving the current entry node and then retrieving its - # symbolic, this could have been taken care of in one step by using the - # enumeration node's ToString() method. - entry_symbolic = node_enum_entry.GetSymbolic() - - # Print current entry symbolic - print_with_indent(level, '%s: %s' % (display_name, entry_symbolic)) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_category_node_and_all_features(node, level): - """ - This function retrieves and prints out the display name of a category node - before printing all child nodes. Child nodes that are also category nodes are - printed recursively. - - :param node: Category node to get information from. - :type node: INode - :param level: Depth to indent output. - :type level: int - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Create category node - node_category = PySpin.CCategoryPtr(node) - - # Get and print display name - display_name = node_category.GetDisplayName() - print_with_indent(level, display_name) - - # Retrieve and iterate through all children - # - # *** NOTES *** - # The two nodes that typically have children are category nodes and - # enumeration nodes. Throughout the examples, the children of category nodes - # are referred to as features while the children of enumeration nodes are - # referred to as entries. Keep in mind that enumeration nodes can be cast as - # category nodes, but category nodes cannot be cast as enumerations. - for node_feature in node_category.GetFeatures(): - - # Ensure node is available and readable - if not PySpin.IsAvailable(node_feature) or not PySpin.IsReadable(node_feature): - continue - - # Category nodes must be dealt with separately in order to retrieve subnodes recursively. - if node_feature.GetPrincipalInterfaceType() == PySpin.intfICategory: - result &= print_category_node_and_all_features(node_feature, level + 1) - - # Cast all non-category nodes as value nodes - # - # *** NOTES *** - # If dealing with a variety of node types and their values, it may be - # simpler to cast them as value nodes rather than as their individual types. - # However, with this increased ease-of-use, functionality is sacrificed. - elif CHOSEN_READ == ReadType.VALUE: - result &= print_value_node(node_feature, level + 1) - - # Cast all non-category nodes as actual types - elif CHOSEN_READ == ReadType.INDIVIDUAL: - if node_feature.GetPrincipalInterfaceType() == PySpin.intfIString: - result &= print_string_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIInteger: - result &= print_integer_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIFloat: - result &= print_float_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIBoolean: - result &= print_boolean_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfICommand: - result &= print_command_node(node_feature, level + 1) - elif node_feature.GetPrincipalInterfaceType() == PySpin.intfIEnumeration: - result &= print_enumeration_node_and_current_entry(node_feature, level + 1) - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example. First nodes from the TL - device and TL stream nodemaps are retrieved and printed. Following this, - the camera is initialized and then nodes from the GenICam nodemap are - retrieved and printed. - - :param cam: Camera to get nodemaps from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - level = 0 - - # Retrieve TL device nodemap - # - # *** NOTES *** - # The TL device nodemap is available on the transport layer. As such, - # camera initialization is unnecessary. It provides mostly immutable - # information fundamental to the camera such as the serial number, - # vendor, and model. - print('\n*** PRINTING TRANSPORT LAYER DEVICE NODEMAP *** \n') - - nodemap_gentl = cam.GetTLDeviceNodeMap() - - result &= print_category_node_and_all_features(nodemap_gentl.GetNode('Root'), level) - - # Retrieve TL stream nodemap - # - # *** NOTES *** - # The TL stream nodemap is also available on the transport layer. Camera - # initialization is again unnecessary. As you can probably guess, it - # provides information on the camera's streaming performance at any - # given moment. Having this information available on the transport layer - # allows the information to be retrieved without affecting camera performance. - print('*** PRINTING TL STREAM NODEMAP ***\n') - - nodemap_tlstream = cam.GetTLStreamNodeMap() - - result &= print_category_node_and_all_features(nodemap_tlstream.GetNode('Root'), level) - - # Initialize camera - # - # *** NOTES *** - # The camera becomes connected upon initialization. This provides - # access to configurable options and additional information, accessible - # through the GenICam nodemap. - # - # *** LATER *** - # Cameras should be deinitialized when no longer needed. - print('*** PRINTING GENICAM NODEMAP ***\n') - - cam.Init() - - # Retrieve GenICam nodemap - # - # *** NOTES *** - # The GenICam nodemap is the primary gateway to customizing - # and configuring the camera to suit your needs. Configuration options - # such as image height and width, trigger mode enabling and disabling, - # and the sequencer are found on this nodemap. - nodemap_applayer = cam.GetNodeMap() - - result &= print_category_node_and_all_features(nodemap_applayer.GetNode('Root'), level) - - # Deinitialize camera - # - # *** NOTES *** - # Camera deinitialization helps ensure that devices clean up properly - # and do not need to be power-cycled to maintain integrity. - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return True - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo_QuickSpin.py deleted file mode 100644 index 3381bb6..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/NodeMapInfo_QuickSpin.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# NodeMapInfo_QuickSpin.py shows how to interact with nodes -# using the QuickSpin API. QuickSpin is a subset of the Spinnaker library -# that allows for simpler node access and control. -# -# This example demonstrates the retrieval of information from both the -# transport layer and the camera. Because the focus of this example is node -# access, which is where QuickSpin and regular Spinnaker differ, this -# example differs from NodeMapInfo quite a bit. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - - -def print_transport_layer_device_info(cam): - """ - Prints device information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing device information on the transport layer is - accomplished via a camera's TLDevice property. The TLDevice property - houses nodes related to general device information such as the three - demonstrated below, device access status, XML and GUI paths and - locations, and GEV information to name a few. The TLDevice property - allows access to nodes that would generally be retrieved through the - TL device nodemap in full Spinnaker. - - Notice that each node is checked for availability and readability - prior to value retrieval. Checking for availability and readability - (or writability when applicable) whenever a node is accessed is - important in terms of error handling. If a node retrieval error - occurs but remains unhandled, an exception is thrown. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print device serial number - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - print('Device serial number: %s' % cam.TLDevice.DeviceSerialNumber.ToString()) - - else: - print('Device serial number: unavailable') - result = False - - # Print device vendor name - # - # *** NOTE *** - # To check node readability/writability, you can either - # compare its access mode with RO, RW, etc. or you can use - # the IsReadable/IsWritable functions on the node. - if PySpin.IsReadable(cam.TLDevice.DeviceVendorName): - print('Device vendor name: %s' % cam.TLDevice.DeviceVendorName.ToString()) - else: - print('Device vendor name: unavailable') - result = False - - # Print device display name - if PySpin.IsReadable(cam.TLDevice.DeviceDisplayName): - print('Device display name: %s' % cam.TLDevice.DeviceDisplayName.ToString()) - else: - print('Device display name: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_stream_info(cam): - """ - Prints stream information from transport layer. - - *** NOTES *** - In QuickSpin, accessing stream information on the transport layer is - accomplished via a camera's TLStream property. The TLStream property - houses nodes related to streaming such as the two demonstrated below, - buffer information, and GEV packet information to name a few. The - TLStream property allows access to nodes that would generally be - retrieved through the TL stream nodemap in full Spinnaker. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print stream ID - if cam.TLStream.StreamID.GetAccessMode() == PySpin.RO: - print('Stream ID: %s' % cam.TLStream.StreamID.ToString()) - else: - print('Stream ID: unavailable') - result = False - - # Print stream type - if PySpin.IsReadable(cam.TLStream.StreamType): - print('Stream type: %s' % cam.TLStream.StreamType.ToString()) - else: - print('Stream type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_transport_layer_interface_info(interface): - """ - Prints stream information from the transport layer. - - *** NOTES *** - In QuickSpin, accessing interface information is accomplished via an - interface's TLInterface property. The TLInterface property houses - nodes that hold information about the interface such as the three - demonstrated below, other general interface information, and - GEV addressing information. The TLInterface property allows access to - nodes that would generally be retrieved through the interface nodemap - in full Spinnaker. - - Interface nodes should also always be checked for availability and - readability (or writability when applicable). If a node retrieval - error occurs but remains unhandled, an exception is thrown. - - :param interface: Interface to get information from. - :type interface: InterfacePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print interface display name - if interface.TLInterface.InterfaceDisplayName.GetAccessMode() == PySpin.RO: - print('Interface display name: %s' % interface.TLInterface.InterfaceDisplayName.ToString()) - else: - print('Interface display name: unavailable') - result = False - - # Print interface ID - if interface.TLInterface.InterfaceID.GetAccessMode() == PySpin.RO: - print('Interface ID: %s' % interface.TLInterface.InterfaceID.ToString()) - else: - print('Interface ID: unavailable') - result = False - - # Print interface type - if PySpin.IsReadable(interface.TLInterface.InterfaceType.GetAccessMode()): - print('Interface type: %s' % interface.TLInterface.InterfaceType.ToString()) - else: - print('Interface type: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_genicam_device_info(cam): - """ - Prints device information from the camera. - - *** NOTES *** - Most camera interaction happens through GenICam nodes. The - advantages of these nodes is that there is a lot more of them, they - allow for a much deeper level of interaction with a camera, and no - intermediate property (i.e. TLDevice or TLStream) is required. The - disadvantage is that they require initialization. - - :param cam: Camera to get information from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - - # Print exposure time - if cam.ExposureTime.GetAccessMode() == PySpin.RO or cam.ExposureTime.GetAccessMode() == PySpin.RW: - print('Exposure time: %s' % cam.ExposureTime.ToString()) - else: - print('Exposure time: unavailable') - result = False - - # Print black level - if PySpin.IsReadable(cam.BlackLevel): - print('Black level: %s' % cam.BlackLevel.ToString()) - else: - print('Black level: unavailable') - result = False - - # Print height - if PySpin.IsReadable(cam.Height): - print('Height: %s' % cam.Height.ToString()) - else: - print('Height: unavailable') - result = False - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def main(): - """ - Example entry point; this function prints transport layer information from - each interface and transport and GenICam information from each camera. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - sys = PySpin.System.GetInstance() - - # Get current library version - version = sys.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = sys.GetCameras() - - num_cams = cam_list.GetSize() - - print('Number of cameras detected: %i \n' % num_cams) - - # Finish if there are no cameras - if num_cams == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Retrieve list of interfaces from the system - iface_list = sys.GetInterfaces() - - num_ifaces = iface_list.GetSize() - - print('Number of interfaces detected: %i \n' % num_ifaces) - - # Print information on each interface - # - # *** NOTES *** - # All USB 3 Vision and GigE Vision interfaces should enumerate for - # Spinnaker. - print('\n*** PRINTING INTERFACE INFORMATION ***\n') - - for iface in iface_list: - result &= print_transport_layer_interface_info(iface) - - # Release reference to interface - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del iface - - # Print general device information on each camera from transport layer - # - # *** NOTES *** - # Transport layer nodes do not require initialization in order to interact - # with them. - print('\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_device_info(cam) - - # Print streaming information on each camera from transport layer - # - # *** NOTES *** - # Again, initialization is not required to print information from the - # transport layer; this is equally true of streaming information. - print('\n*** PRINTING TRANSPORT LAYER STREAMING INFORMATION ***\n') - - for cam in cam_list: - result &= print_transport_layer_stream_info(cam) - - # Print device information on each camera from GenICam nodemap - # - # *** NOTES *** - # GenICam nodes require initialization in order to interact with - # them; as such, this loop initializes the camera, prints some information - # from the GenICam nodemap, and then deinitializes it. If the camera were - # not initialized, node availability would fail. - print('\n*** PRINTING GENICAM INFORMATION ***\n') - - for cam in cam_list: - # Initialize camera - cam.Init() - - # Print info - result &= print_genicam_device_info(cam) - - # Deinitialize camera - cam.DeInit() - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Clear interface list before releasing system - iface_list.Clear() - - # Release system instance - sys.ReleaseInstance() - - input('\nDone! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SaveToAvi.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SaveToAvi.py deleted file mode 100644 index 1f79203..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SaveToAvi.py +++ /dev/null @@ -1,378 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SaveToAvi.py shows how to create an AVI video from a vector of -# images. It relies on information provided in the Enumeration, Acquisition, -# and NodeMapInfo examples. -# -# This example introduces the SpinVideo class, which is used to quickly and -# easily create various types of AVI videos. It demonstrates the creation of -# three types: uncompressed, MJPG, and H264. - -import PySpin -import sys - - -class AviType: - """'Enum' to select AVI video type to be created and saved""" - UNCOMPRESSED = 0 - MJPG = 1 - H264 = 2 - -chosenAviType = AviType.UNCOMPRESSED # change me! -NUM_IMAGES = 10 # number of images to use in AVI file - - -def save_list_to_avi(nodemap, nodemap_tldevice, images): - """ - This function prepares, saves, and cleans up an AVI video from a vector of images. - - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param images: List of images to save to an AVI video. - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type images: list of ImagePtr - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** CREATING VIDEO ***') - - try: - result = True - - # Retrieve device serial number for filename - device_serial_number = '' - node_serial = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - - if PySpin.IsAvailable(node_serial) and PySpin.IsReadable(node_serial): - device_serial_number = node_serial.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Get the current frame rate; acquisition frame rate recorded in hertz - # - # *** NOTES *** - # The video frame rate can be set to anything; however, in order to - # have videos play in real-time, the acquisition frame rate can be - # retrieved from the camera. - - node_acquisition_framerate = PySpin.CFloatPtr(nodemap.GetNode('AcquisitionFrameRate')) - - if not PySpin.IsAvailable(node_acquisition_framerate) and not PySpin.IsReadable(node_acquisition_framerate): - print('Unable to retrieve frame rate. Aborting...') - return False - - framerate_to_set = node_acquisition_framerate.GetValue() - - print('Frame rate to be set to %d...' % framerate_to_set) - - # Select option and open AVI filetype with unique filename - # - # *** NOTES *** - # Depending on the filetype, a number of settings need to be set in - # an object called an option. An uncompressed option only needs to - # have the video frame rate set whereas videos with MJPG or H264 - # compressions should have more values set. - # - # Once the desired option object is configured, open the AVI file - # with the option in order to create the image file. - # - # Note that the filename does not need to be appended to the - # name of the file. This is because the AVI recorder object takes care - # of the file extension automatically. - # - # *** LATER *** - # Once all images have been added, it is important to close the file - - # this is similar to many other standard file streams. - - avi_recorder = PySpin.SpinVideo() - - if chosenAviType == AviType.UNCOMPRESSED: - avi_filename = 'SaveToAvi-Uncompressed-%s' % device_serial_number - - option = PySpin.AVIOption() - option.frameRate = framerate_to_set - - elif chosenAviType == AviType.MJPG: - avi_filename = 'SaveToAvi-MJPG-%s' % device_serial_number - - option = PySpin.MJPGOption() - option.frameRate = framerate_to_set - option.quality = 75 - - elif chosenAviType == AviType.H264: - avi_filename = 'SaveToAvi-H264-%s' % device_serial_number - - option = PySpin.H264Option() - option.frameRate = framerate_to_set - option.bitrate = 1000000 - option.height = images[0].GetHeight() - option.width = images[0].GetWidth() - - else: - print('Error: Unknown AviType. Aborting...') - return False - - avi_recorder.Open(avi_filename, option) - - # Construct and save AVI video - # - # *** NOTES *** - # Although the video file has been opened, images must be individually - # appended in order to construct the video. - print('Appending %d images to AVI file: %s.avi...' % (len(images), avi_filename)) - - for i in range(len(images)): - avi_recorder.Append(images[i]) - print('Appended image %d...' % i) - - # Close AVI file - # - # *** NOTES *** - # Once all images have been appended, it is important to close the - # AVI file. Notice that once an AVI file has been closed, no more - # images can be added. - - avi_recorder.Close() - print('Video saved at %s.avi' % avi_filename) - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('\n*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap): - """ - This function acquires 10 images from a device, stores them in a list, and returns the list. - please see the Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve, convert, and save images - images = list() - - for i in range(NUM_IMAGES): - try: - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d...' % image_result.GetImageStatus()) - - else: - # Print image information; height and width recorded in pixels - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 and append to list - images.append(image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result, images - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run example on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Acquire list of images - err, images = acquire_images(cam, nodemap) - if err < 0: - return err - - result &= save_list_to_avi(nodemap, nodemap_tldevice, images) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected:', num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Sequencer.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Sequencer.py deleted file mode 100644 index 23035c7..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Sequencer.py +++ /dev/null @@ -1,873 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Sequencer.py shows how to use the sequencer to grab images with -# various settings. It relies on information provided in the Enumeration, -# Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples as these examples provide a strong introduction to -# camera customization. -# -# The sequencer is another very powerful tool, which can be used to create -# and store multiple states of customized image settings. A very useful -# application of the sequencer is creating high dynamic range images. -# -# This example is probably the most complex and definitely the longest. As -# such, the configuration has been split between three functions. The first -# prepares the camera to set the sequences, the second sets the settings for -# a single state (it is run five times), and the third configures the -# camera to use the sequencer when it acquires images. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -def print_retrieve_node_failure(node, name): - """" - This function handles the error prints when a node or entry is unavailable or - not readable on the connected camera. - - :param node: Node type. "Node' or 'Entry' - :param name: Node name. - :type node: String - :type name: String - :rtype: None - """ - print('Unable to get {} ({} {} retrieval failed.)'.format(node, name, node)) - print('The {} may not be available on all camera models...'.format(node)) - print('Please try a Blackfly S camera.') - - -def configure_sequencer_part_one(nodemap): - """" - This function prepares the sequencer to accept custom configurations by - ensuring sequencer mode is off (this is a requirement to the enabling of - sequencer configuration mode), disabling automatic gain and exposure, and - turning sequencer configuration mode on. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING SEQUENCER ***\n') - try: - result = True - - # Ensure sequencer is off for configuration - # - # *** NOTES *** - # In order to configure a new sequence, sequencer configuration mode - # needs to be turned on. To do this, sequencer mode must be disabled. - # However, simply disabling sequencer mode might throw an exception if - # the current sequence is an invalid configuration. - # - # Thus, in order to ensure that sequencer mode is disabled, we first - # check whether the current sequence is valid. If it - # isn't, then we know that sequencer mode is off and we can move on; - # if it is, then we can manually disable sequencer mode. - # - # Also note that sequencer configuration mode needs to be off in order - # to manually disable sequencer mode. It should be off by default, so - # the example skips checking this. - # - # Validate sequencer configuration - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - # If valid, disable sequencer mode; otherwise, do nothing - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() == \ - sequencer_configuration_valid_yes.GetValue(): - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Sequencer mode disabled...') - - # Turn off automatic exposure - # - # *** NOTES *** - # Automatic exposure prevents the manual configuration of exposure - # times and needs to be turned off for this example. - # - # *** LATER *** - # Automatic exposure is turned back on at the end of the example in - # order to restore the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if not PySpin.IsAvailable(node_exposure_auto) or not PySpin.IsWritable(node_exposure_auto): - print_retrieve_node_failure('node', 'ExposureAuto') - return False - - exposure_auto_off = node_exposure_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(exposure_auto_off) or not PySpin.IsReadable(exposure_auto_off): - print_retrieve_node_failure('entry', 'ExposureAuto Off') - return False - - node_exposure_auto.SetIntValue(exposure_auto_off.GetValue()) - - print('Automatic exposure disabled...') - - # Turn off automatic gain - # - # *** NOTES *** - # Automatic gain prevents the manual configuration of gain and needs - # to be turned off for this example. - # - # *** LATER *** - # Automatic gain is turned back on at the end of the example in - # order to restore the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if not PySpin.IsAvailable(node_gain_auto) or not PySpin.IsWritable(node_gain_auto): - print_retrieve_node_failure('node', 'GainAuto') - return False - - gain_auto_off = node_gain_auto.GetEntryByName('Off') - if not PySpin.IsAvailable(gain_auto_off) or not PySpin.IsReadable(gain_auto_off): - print_retrieve_node_failure('entry', 'GainAuto Off') - return False - - node_gain_auto.SetIntValue(gain_auto_off.GetValue()) - - print('Automatic gain disabled...') - - # Turn configuration mode on - # - # *** NOTES *** - # Once sequencer mode is off, enabling sequencer configuration mode - # allows for the setting of each state. - # - # *** LATER *** - # Before sequencer mode is turned back on, sequencer configuration - # mode must be turned back off. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_on = node_sequencer_configuration_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_configuration_mode_on)\ - or not PySpin.IsReadable(sequencer_configuration_mode_on): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode On') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_on.GetValue()) - - print('Sequencer configuration mode enabled...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def set_single_state(nodemap, sequence_number, width_to_set, height_to_set, exposure_time_to_set, gain_to_set): - """ - This function sets a single state. It sets the sequence number, applies - custom settings, selects the trigger type and next state number, and saves - the state. The custom values that are applied are all calculated in the - function that calls this one, run_single_camera(). - - :param nodemap: Device nodemap. - :param sequence_number: Sequence number. - :param width_to_set: Width to set for sequencer. - :param height_to_set: Height to set fpr sequencer. - :param exposure_time_to_set: Exposure time to set for sequencer. - :param gain_to_set: Gain to set for sequencer. - :type nodemap: INodeMap - :type sequence_number: int - :type width_to_set: int - :type height_to_set: int - :type exposure_time_to_set: float - :type gain_to_set: float - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Select the current sequence number - # - # *** NOTES *** - # Select the index of the state to be set. - # - # *** LATER *** - # The next state - i.e. the state to be linked to - - # also needs to be set before saving the current state. - node_sequencer_set_selector = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetSelector')) - if not PySpin.IsAvailable(node_sequencer_set_selector) or not PySpin.IsWritable(node_sequencer_set_selector): - print_retrieve_node_failure('node', 'SequencerSetSelector') - return False - - node_sequencer_set_selector.SetValue(sequence_number) - - print('Setting state {}...'.format(sequence_number)) - - # Set desired settings for the current state - # - # *** NOTES *** - # Width, height, exposure time, and gain are set in this example. If - # the sequencer isn't working properly, it may be important to ensure - # that each feature is enabled on the sequencer. Features are enabled - # by default, so this is not explored in this example. - # - # Changing the height and width for the sequencer is not available - # for all camera models. - # - # Set width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if PySpin.IsAvailable(node_width) and PySpin.IsWritable(node_width): - width_inc = node_width.GetInc() - - if width_to_set % width_inc != 0: - width_to_set = int(width_to_set / width_inc) * width_inc - - node_width.SetValue(width_to_set) - - print('\tWidth set to {}...'.format(node_width.GetValue())) - - else: - print('\tUnable to set width; width for sequencer not available on all camera models...') - - # Set height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if PySpin.IsAvailable(node_height) and PySpin.IsWritable(node_height): - height_inc = node_height.GetInc() - - if height_to_set % height_inc != 0: - height_to_set = int(height_to_set / height_inc) * height_inc - - node_height.SetValue(height_to_set) - - print('\tHeight set to %d...' % node_height.GetValue()) - - else: - print('\tUnable to set height; height for sequencer not available on all camera models...') - - # Set exposure time; exposure time recorded in microseconds - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsWritable(node_exposure_time): - print_retrieve_node_failure('node', 'ExposureTime') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_to_set > exposure_time_max: - exposure_time_to_set = exposure_time_max - - node_exposure_time.SetValue(exposure_time_to_set) - - print('\tExposure set to {0:.0f}...'.format(node_exposure_time.GetValue())) - - # Set gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_gain) or not PySpin.IsWritable(node_gain): - print_retrieve_node_failure('node', 'Gain') - return False - - gain_max = node_gain.GetMax() - - if gain_to_set > gain_max: - gain_to_set = gain_max - - node_gain.SetValue(gain_to_set) - - print('\tGain set to {0:.5f}...'.format(node_gain.GetValue())) - - # Set the trigger type for the current state - # - # *** NOTES *** - # It is a requirement of every state to have its trigger source set. - # The trigger source refers to the moment when the sequencer changes - # from one state to the next. - node_sequencer_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerTriggerSource')) - if not PySpin.IsAvailable(node_sequencer_trigger_source) or not PySpin.IsWritable(node_sequencer_trigger_source): - print_retrieve_node_failure('node', 'SequencerTriggerSource') - return False - - sequencer_trigger_source_frame_start = node_sequencer_trigger_source.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(sequencer_trigger_source_frame_start) or \ - not PySpin.IsReadable(sequencer_trigger_source_frame_start): - print_retrieve_node_failure('entry', 'SequencerTriggerSource FrameStart') - return False - - node_sequencer_trigger_source.SetIntValue(sequencer_trigger_source_frame_start.GetValue()) - - print('\tTrigger source set to start of frame...') - - # Set the next state in the sequence - # - # *** NOTES *** - # When setting the next state in the sequence, ensure it does not - # exceed the maximum and that the states loop appropriately. - final_sequence_index = 4 - - node_sequencer_set_next = PySpin.CIntegerPtr(nodemap.GetNode('SequencerSetNext')) - if not PySpin.IsAvailable(node_sequencer_set_next) or not PySpin.IsWritable(node_sequencer_set_next): - print('Unable to select next state. Aborting...\n') - return False - - if sequence_number == final_sequence_index: - node_sequencer_set_next.SetValue(0) - else: - node_sequencer_set_next.SetValue(sequence_number + 1) - - print('\tNext state set to {}...'.format(node_sequencer_set_next.GetValue())) - - # Save current state - # - # *** NOTES *** - # Once all appropriate settings have been configured, make sure to - # save the state to the sequence. Notice that these settings will be - # lost when the camera is power-cycled. - node_sequencer_set_save = PySpin.CCommandPtr(nodemap.GetNode('SequencerSetSave')) - if not PySpin.IsAvailable(node_sequencer_set_save) or not PySpin.IsWritable(node_sequencer_set_save): - print('Unable to save state. Aborting...\n') - return False - - node_sequencer_set_save.Execute() - - print('Current state saved...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def configure_sequencer_part_two(nodemap): - """" - Now that the states have all been set, this function readies the camera - to use the sequencer during image acquisition. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn configuration mode off - # - # *** NOTES *** - # Once all desired states have been set, turn sequencer - # configuration mode off in order to turn sequencer mode on. - node_sequencer_configuration_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationMode')) - if not PySpin.IsAvailable(node_sequencer_configuration_mode) \ - or not PySpin.IsWritable(node_sequencer_configuration_mode): - print_retrieve_node_failure('node', 'SequencerConfigurationMode') - return False - - sequencer_configuration_mode_off = node_sequencer_configuration_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_configuration_mode_off)\ - or not PySpin.IsReadable(sequencer_configuration_mode_off): - print_retrieve_node_failure('entry', 'SequencerConfigurationMode Off') - return False - - node_sequencer_configuration_mode.SetIntValue(sequencer_configuration_mode_off.GetValue()) - - print('Sequencer configuration mode disabled...') - - # Turn sequencer mode on - # - # *** NOTES *** - # After sequencer mode has been turned on, the camera will begin using the - # saved states in the order that they were set. - # - # *** LATER *** - # Once all images have been captured, disable the sequencer in order - # to restore the camera to its initial state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_on = node_sequencer_mode.GetEntryByName('On') - if not PySpin.IsAvailable(sequencer_mode_on) or not PySpin.IsReadable(sequencer_mode_on): - print_retrieve_node_failure('entry', 'SequencerMode On') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_on.GetValue()) - - print('Sequencer mode enabled...') - - # Validate sequencer settings - # - # *** NOTES *** - # Once all states have been set, it is a good idea to - # validate them. Although this node cannot ensure that the states - # have been set up correctly, it does ensure that the states have - # been set up in such a way that the camera can function. - node_sequencer_configuration_valid = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerConfigurationValid')) - if not PySpin.IsAvailable(node_sequencer_configuration_valid) \ - or not PySpin.IsReadable(node_sequencer_configuration_valid): - print_retrieve_node_failure('node', 'SequencerConfigurationValid') - return False - - sequencer_configuration_valid_yes = node_sequencer_configuration_valid.GetEntryByName('Yes') - if not PySpin.IsAvailable(sequencer_configuration_valid_yes) \ - or not PySpin.IsReadable(sequencer_configuration_valid_yes): - print_retrieve_node_failure('entry', 'SequencerConfigurationValid Yes') - return False - - if node_sequencer_configuration_valid.GetCurrentEntry().GetValue() != \ - sequencer_configuration_valid_yes.GetValue(): - print('Sequencer configuration not valid. Aborting...\n') - return False - - print('Sequencer configuration valid...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def reset_sequencer(nodemap): - """" - This function restores the camera to its default state by turning sequencer mode - off and re-enabling automatic exposure and gain. - - :param nodemap: Device nodemap. - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Turn sequencer mode back off - # - # *** NOTES *** - # The sequencer is turned off in order to return the camera to its default state. - node_sequencer_mode = PySpin.CEnumerationPtr(nodemap.GetNode('SequencerMode')) - if not PySpin.IsAvailable(node_sequencer_mode) or not PySpin.IsWritable(node_sequencer_mode): - print_retrieve_node_failure('node', 'SequencerMode') - return False - - sequencer_mode_off = node_sequencer_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(sequencer_mode_off) or not PySpin.IsReadable(sequencer_mode_off): - print_retrieve_node_failure('entry', 'SequencerMode Off') - return False - - node_sequencer_mode.SetIntValue(sequencer_mode_off.GetValue()) - - print('Turning off sequencer mode...') - - # Turn automatic exposure back on - # - # *** NOTES *** - # Automatic exposure is turned on in order to return the camera to its default state. - node_exposure_auto = PySpin.CEnumerationPtr(nodemap.GetNode('ExposureAuto')) - if PySpin.IsAvailable(node_exposure_auto) and PySpin.IsWritable(node_exposure_auto): - exposure_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(exposure_auto_continuous) and PySpin.IsReadable(exposure_auto_continuous): - node_exposure_auto.SetIntValue(exposure_auto_continuous.GetValue()) - print('Turning automatic exposure back on...') - - # Turn automatic gain back on - # - # *** NOTES *** - # Automatic gain is turned on in order to return the camera to its default state. - node_gain_auto = PySpin.CEnumerationPtr(nodemap.GetNode('GainAuto')) - if PySpin.IsAvailable(node_gain_auto) and PySpin.IsWritable(node_gain_auto): - gain_auto_continuous = node_exposure_auto.GetEntryByName('Continuous') - if PySpin.IsAvailable(gain_auto_continuous) and PySpin.IsReadable(gain_auto_continuous): - node_gain_auto.SetIntValue(gain_auto_continuous.GetValue()) - print('Turning automatic gain mode back on...\n') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - feature_string = node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable' - print('{}: {}'.format(node_feature.GetName(), feature_string)) - - else: - print('Device control information not available.') - - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice, timeout): - """ - This function acquires and saves 10 images from a device. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :param timeout: Timeout for image acquisition. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :type timeout: int - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or \ - not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or \ - not PySpin.IsReadable(node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as {}...'.format(device_serial_number)) - - print('') - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve next received image and ensure image completion - image_result = cam.GetNextImage(timeout) - - if image_result.IsIncomplete(): - print('Image incomplete with image status {}...'.format(image_result.GetImageStatus())) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed image {}, width = {}, height = {}'.format(i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Sequencer-{}-{}.jpg'.format(device_serial_number, i) - else: # if serial number is empty - filename = 'Sequencer-{}.jpg'.format(i) - - # Save image - image_converted.Save(filename) - print('Image saved at {}'.format(filename)) - - # Release image - image_result.Release() - print('') - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts very similarly to the run_single_camera() functions of other - examples, except that the values for the sequences are also calculated here; - please see NodeMapInfo example for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - try: - result = True - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure sequencer to be ready to set sequences - result &= configure_sequencer_part_one(nodemap) - if not result: - return result - - # Set sequences - # - # *** NOTES *** - # In the following section, the sequencer values are calculated. This - # section does not appear in the configuration, as the values - # calculated are somewhat arbitrary: width and height are both set to - # 25% of their maximum values, incrementing by 10%; exposure time is - # set to its minimum, also incrementing by 10% of its maximum; and gain - # is set to its minimum, incrementing by 2% of its maximum. - num_sequences = 5 - - # Retrieve maximum width; width recorded in pixels - node_width = PySpin.CIntegerPtr(nodemap.GetNode('Width')) - if not PySpin.IsAvailable(node_width) or not PySpin.IsReadable(node_width): - print('Unable to retrieve maximum width. Aborting...\n') - return False - - width_max = node_width.GetMax() - - # Retrieve maximum height; height recorded in pixels - node_height = PySpin.CIntegerPtr(nodemap.GetNode('Height')) - if not PySpin.IsAvailable(node_height) or not PySpin.IsReadable(node_height): - print('Unable to retrieve maximum height. Aborting...\n') - return False - - height_max = node_height.GetMax() - - # Retrieve maximum exposure time; exposure time recorded in microseconds - exposure_time_max_to_set = 2000000 - - node_exposure_time = PySpin.CFloatPtr(nodemap.GetNode('ExposureTime')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum exposure time. Aborting...\n') - return False - - exposure_time_max = node_exposure_time.GetMax() - - if exposure_time_max > exposure_time_max_to_set: - exposure_time_max = exposure_time_max_to_set - - # Retrieve maximum gain; gain recorded in decibels - node_gain = PySpin.CFloatPtr(nodemap.GetNode('Gain')) - if not PySpin.IsAvailable(node_exposure_time) or not PySpin.IsReadable(node_exposure_time): - print('Unable to retrieve maximum gain. Aborting...\n') - return False - - gain_max = node_gain.GetMax() - - # Set initial values - width_to_set = width_max / 4 - height_to_set = height_max / 4 - exposure_time_to_set = node_exposure_time.GetMin() - gain_to_set = node_gain.GetMin() - - # Set custom values of each sequence - for sequence_num in range(num_sequences): - result &= set_single_state(nodemap, - sequence_num, - int(width_to_set), - int(height_to_set), - exposure_time_to_set, - gain_to_set) - if not result: - return result - - # Increment values - width_to_set += width_max / 10 - height_to_set += height_max / 10 - exposure_time_to_set += exposure_time_max / 10.0 - gain_to_set += gain_max / 50.0 - - # Calculate appropriate acquisition grab timeout window based on exposure time - # Note: exposure_time_to_set is in microseconds and needs to be converted to milliseconds - timeout = (exposure_time_to_set / 1000) + 1000 - - # Configure sequencer to acquire images - result &= configure_sequencer_part_two(nodemap) - if not result: - return result - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice, int(timeout)) - - # Reset sequencer - result &= reset_sequencer(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: {}'.format(ex)) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: {}.{}.{}.{}\n'.format(version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: {}\n'.format(num_cameras)) - - # Finish if there are no cameras - if num_cameras == 0: - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera {}...\n'.format(i)) - - result &= run_single_camera(cam) - print('Camera {} example complete...\n'.format(i)) - - # Release reference to camera - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SpinUpdate.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SpinUpdate.py deleted file mode 100644 index 409fb80..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/SpinUpdate.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# SpinUpdate.py is a sample firmware updater application that takes in -# command line arguments. The example also demonstrates usage of callback -# functions to keep track of current update progress. -# -# Run with arguments in format (no quotes): "-R -P -UU " - -import PySpin -import sys - - -last_action = '' - - -def progress_callback(action, address, global_percent, curr_percent): - """ - Example progress callback function. - NOTE: This function must take exactly 4 arguments, - otherwise the update process will hang/crash! - - :param action: Current action being done in firmware update (as a byte string). - :param address: Address in camera being written to. - :param global_percent: Global completion percentage of update. - :param curr_percent: Completion percentage of current action. - :type action: str - :type address: int - :type global_percent: int - :type curr_percent: int - :rtype: int - """ - global last_action - if action != last_action: - # Prints action only if changed from previous one - print('Action: %s' % action) - last_action = action - - return 1 - - -def message_callback(message): - """ - Example message callback function. - NOTE: This function must take exactly 1 argument, - otherwise the update process will hang/crash! - - :param message: Message from updator (as a byte string). - :type message: str - :rtype: None - """ - print('Message: %s' % message) - - return 1 - - -def main(): - # Register callbacks - PySpin.SetProgressCallback(progress_callback) - PySpin.SetMessageCallback(message_callback) - - # Example usage for firmware update: - # Use either UpdateFirmware() or UpdateFirmwareConsole(): - # - # cmd = "-R3932019 C:\\firmware\\bfly2_u3_python1300.zim" # Add -P to argument list for callbacks - # return UpdateFirmware(cmd); - - return PySpin.UpdateFirmwareConsole(sys.argv) # uses command line args - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger.py deleted file mode 100644 index 7917fc3..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger.py +++ /dev/null @@ -1,519 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger.py shows how to trigger the camera. It relies on information -# provided in the Enumeration, Acquisition, and NodeMapInfo examples. -# -# It can also be helpful to familiarize yourself with the ImageFormatControl -# and Exposure examples. As they are somewhat shorter and simpler, either -# provides a strong introduction to camera customization. -# -# This example shows the process of configuring, using, and cleaning up a -# camera for use with both a software and a hardware trigger. - -import os -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - set to off in order to select the trigger source. Once the trigger source - has been selected, trigger mode is then enabled, which has the camera - capture only a single image upon the execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen ...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose ...') - - try: - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - nodemap = cam.GetNodeMap() - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - node_trigger_selector= PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSelector')) - if not PySpin.IsAvailable(node_trigger_selector) or not PySpin.IsWritable(node_trigger_selector): - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - node_trigger_selector_framestart = node_trigger_selector.GetEntryByName('FrameStart') - if not PySpin.IsAvailable(node_trigger_selector_framestart) or not PySpin.IsReadable( - node_trigger_selector_framestart): - print('Unable to set trigger selector (enum entry retrieval). Aborting...') - return False - node_trigger_selector.SetIntValue(node_trigger_selector_framestart.GetValue()) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - node_trigger_source = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerSource')) - if not PySpin.IsAvailable(node_trigger_source) or not PySpin.IsWritable(node_trigger_source): - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - node_trigger_source_software = node_trigger_source.GetEntryByName('Software') - if not PySpin.IsAvailable(node_trigger_source_software) or not PySpin.IsReadable( - node_trigger_source_software): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_software.GetValue()) - print('Trigger source set to software...') - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - node_trigger_source_hardware = node_trigger_source.GetEntryByName('Line0') - if not PySpin.IsAvailable(node_trigger_source_hardware) or not PySpin.IsReadable( - node_trigger_source_hardware): - print('Unable to set trigger source (enum entry retrieval). Aborting...') - return False - node_trigger_source.SetIntValue(node_trigger_source_hardware.GetValue()) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - node_trigger_mode_on = node_trigger_mode.GetEntryByName('On') - if not PySpin.IsAvailable(node_trigger_mode_on) or not PySpin.IsReadable(node_trigger_mode_on): - print('Unable to enable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_on.GetValue()) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(nodemap, cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - node_softwaretrigger_cmd = PySpin.CCommandPtr(nodemap.GetNode('TriggerSoftware')) - if not PySpin.IsAvailable(node_softwaretrigger_cmd) or not PySpin.IsWritable(node_softwaretrigger_cmd): - print('Unable to execute trigger. Aborting...') - return False - - node_softwaretrigger_cmd.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam, nodemap, nodemap_tldevice): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :param nodemap: Device nodemap. - :param nodemap_tldevice: Transport layer device nodemap. - :type cam: CameraPtr - :type nodemap: INodeMap - :type nodemap_tldevice: INodeMap - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - # In order to access the node entries, they have to be casted to a pointer type (CEnumerationPtr here) - node_acquisition_mode = PySpin.CEnumerationPtr(nodemap.GetNode('AcquisitionMode')) - if not PySpin.IsAvailable(node_acquisition_mode) or not PySpin.IsWritable(node_acquisition_mode): - print('Unable to set acquisition mode to continuous (enum retrieval). Aborting...') - return False - - # Retrieve entry node from enumeration node - node_acquisition_mode_continuous = node_acquisition_mode.GetEntryByName('Continuous') - if not PySpin.IsAvailable(node_acquisition_mode_continuous) or not PySpin.IsReadable( - node_acquisition_mode_continuous): - print('Unable to set acquisition mode to continuous (entry retrieval). Aborting...') - return False - - # Retrieve integer value from entry node - acquisition_mode_continuous = node_acquisition_mode_continuous.GetValue() - - # Set integer value from entry node as new value of enumeration node - node_acquisition_mode.SetIntValue(acquisition_mode_continuous) - - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Retrieve device serial number for filename - # - # *** NOTES *** - # The device serial number is retrieved in order to keep cameras from - # overwriting one another. Grabbing image IDs could also accomplish - # this. - device_serial_number = '' - node_device_serial_number = PySpin.CStringPtr(nodemap_tldevice.GetNode('DeviceSerialNumber')) - if PySpin.IsAvailable(node_device_serial_number) and PySpin.IsReadable(node_device_serial_number): - device_serial_number = node_device_serial_number.GetValue() - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(nodemap, cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information; height and width recorded in pixels - # - # *** NOTES *** - # Images have quite a bit of available metadata including - # things such as CRC, image status, and offset values, to - # name a few. - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - # - # *** NOTES *** - # Images can be converted between pixel formats by using - # the appropriate enumeration value. Unlike the original - # image, the converted one does not need to be released as - # it does not affect the camera buffer. - # - # When converting images, color processing algorithm is an - # optional parameter. - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - # - # *** NOTES *** - # The standard practice of the examples is to use device - # serial numbers to keep images of one device from - # overwriting those of another. - image_converted.Save(filename) - print('Image saved at %s\n' % filename) - - # Release image - # - # *** NOTES *** - # Images retrieved directly from the camera (i.e. non-converted - # images) need to be released in order to keep from filling the - # buffer. - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - # - # *** NOTES *** - # Ending acquisition appropriately helps ensure that devices clean up - # properly and do not need to be power-cycled to maintain integrity. - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(nodemap): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - node_trigger_mode = PySpin.CEnumerationPtr(nodemap.GetNode('TriggerMode')) - if not PySpin.IsAvailable(node_trigger_mode) or not PySpin.IsReadable(node_trigger_mode): - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - node_trigger_mode_off = node_trigger_mode.GetEntryByName('Off') - if not PySpin.IsAvailable(node_trigger_mode_off) or not PySpin.IsReadable(node_trigger_mode_off): - print('Unable to disable trigger mode (enum entry retrieval). Aborting...') - return False - - node_trigger_mode.SetIntValue(node_trigger_mode_off.GetValue()) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam, nodemap, nodemap_tldevice) - - # Reset trigger - result &= reset_trigger(nodemap) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - - # Since this application saves images in the current folder - # we must ensure that we have permission to write to this folder. - # If we do not have permission, fail right away. - try: - test_file = open('test.txt', 'w+') - except IOError: - print('Unable to write to current directory. Please check permissions.') - input('Press Enter to exit...') - return False - - test_file.close() - os.remove(test_file.name) - - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger_QuickSpin.py b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger_QuickSpin.py deleted file mode 100644 index 9a33cb4..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/Examples/Python3/Trigger_QuickSpin.py +++ /dev/null @@ -1,422 +0,0 @@ -# coding=utf-8 -# ============================================================================= -# Copyright (c) 2001-2019 FLIR Systems, Inc. All Rights Reserved. -# -# This software is the confidential and proprietary information of FLIR -# Integrated Imaging Solutions, Inc. ("Confidential Information"). You -# shall not disclose such Confidential Information and shall use it only in -# accordance with the terms of the license agreement you entered into -# with FLIR Integrated Imaging Solutions, Inc. (FLIR). -# -# FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -# SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -# THIS SOFTWARE OR ITS DERIVATIVES. -# ============================================================================= -# -# Trigger_QuickSpin.py shows how to capture images with the -# trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker -# library that allows for simpler node access and control. -# -# This example demonstrates how to prepare, execute, and clean up the camera -# in regards to using both software and hardware triggers. Retrieving and -# setting node values using QuickSpin is the only portion of the example -# that differs from Trigger. -# -# A much wider range of topics is covered in the full Spinnaker examples than -# in the QuickSpin ones. There are only enough QuickSpin examples to -# demonstrate node access and to get started with the API; please see full -# Spinnaker examples for further or specific knowledge on a topic. - -import PySpin -import sys - -NUM_IMAGES = 10 # number of images to grab - - -class TriggerType: - SOFTWARE = 1 - HARDWARE = 2 - -CHOSEN_TRIGGER = TriggerType.SOFTWARE - - -def configure_trigger(cam): - """ - This function configures the camera to use a trigger. First, trigger mode is - ensured to be off in order to select the trigger source. Trigger mode is - then enabled, which has the camera capture only a single image upon the - execution of the chosen trigger. - - :param cam: Camera to configure trigger for. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** CONFIGURING TRIGGER ***\n') - - print('Note that if the application / user software triggers faster than frame time, the trigger may be dropped / skipped by the camera.\n') - print('If several frames are needed per trigger, a more reliable alternative for such case, is to use the multi-frame mode.\n\n') - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - print('Software trigger chosen...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Hardware trigger chose...') - - try: - result = True - - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - # Set TriggerSelector to FrameStart - # For this example, the trigger selector should be set to frame start. - # This is the default for most cameras. - if cam.TriggerSelector.GetAccessMode() != PySpin.RW: - print('Unable to get trigger selector (node retrieval). Aborting...') - return False - - cam.TriggerSource.SetValue(PySpin.TriggerSelector_FrameStart) - - print('Trigger selector set to frame start...') - - # Select trigger source - # The trigger source must be set to hardware or software while trigger - # mode is off. - if cam.TriggerSource.GetAccessMode() != PySpin.RW: - print('Unable to get trigger source (node retrieval). Aborting...') - return False - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Software) - print('Trigger source set to software...') - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) - print('Trigger source set to hardware...') - - # Turn trigger mode on - # Once the appropriate trigger source has been set, turn trigger mode - # on in order to retrieve images using the trigger. - cam.TriggerMode.SetValue(PySpin.TriggerMode_On) - print('Trigger mode turned back on...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def grab_next_image_by_trigger(cam): - """ - This function acquires an image by executing the trigger node. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Use trigger to capture image - # The software trigger only feigns being executed by the Enter key; - # what might not be immediately apparent is that there is not a - # continuous stream of images being captured; in other examples that - # acquire images, the camera captures a continuous stream of images. - # When an image is retrieved, it is plucked from the stream. - - if CHOSEN_TRIGGER == TriggerType.SOFTWARE: - # Get user input - input('Press the Enter key to initiate software trigger.') - - # Execute software trigger - if cam.TriggerSoftware.GetAccessMode() != PySpin.WO: - print('Unable to execute trigger. Aborting...') - return False - - cam.TriggerSoftware.Execute() - - # TODO: Blackfly and Flea3 GEV cameras need 2 second delay after software trigger - - elif CHOSEN_TRIGGER == TriggerType.HARDWARE: - print('Use the hardware to trigger image acquisition.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def acquire_images(cam): - """ - This function acquires and saves 10 images from a device. - Please see Acquisition example for more in-depth comments on acquiring images. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - - print('*** IMAGE ACQUISITION ***\n') - try: - result = True - - # Set acquisition mode to continuous - if cam.AcquisitionMode.GetAccessMode() != PySpin.RW: - print('Unable to set acquisition mode to continuous. Aborting...') - return False - - cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) - print('Acquisition mode set to continuous...') - - # Begin acquiring images - cam.BeginAcquisition() - - print('Acquiring images...') - - # Get device serial number for filename - device_serial_number = '' - if cam.TLDevice.DeviceSerialNumber.GetAccessMode() == PySpin.RO: - device_serial_number = cam.TLDevice.DeviceSerialNumber.GetValue() - - print('Device serial number retrieved as %s...' % device_serial_number) - - # Retrieve, convert, and save images - for i in range(NUM_IMAGES): - try: - - # Retrieve the next image from the trigger - result &= grab_next_image_by_trigger(cam) - - # Retrieve next received image - image_result = cam.GetNextImage(1000) - - # Ensure image completion - if image_result.IsIncomplete(): - print('Image incomplete with image status %d ...' % image_result.GetImageStatus()) - - else: - - # Print image information - width = image_result.GetWidth() - height = image_result.GetHeight() - print('Grabbed Image %d, width = %d, height = %d' % (i, width, height)) - - # Convert image to mono 8 - image_converted = image_result.Convert(PySpin.PixelFormat_Mono8, PySpin.HQ_LINEAR) - - # Create a unique filename - if device_serial_number: - filename = 'Trigger-%s-%d.jpg' % (device_serial_number, i) - else: # if serial number is empty - filename = 'Trigger-%d.jpg' % i - - # Save image - image_converted.Save(filename) - - print('Image saved at %s\n' % filename) - - # Release image - image_result.Release() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - # End acquisition - cam.EndAcquisition() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def reset_trigger(cam): - """ - This function returns the camera to a normal state by turning off trigger mode. - - :param cam: Camera to acquire images from. - :type cam: CameraPtr - :returns: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - # Ensure trigger mode off - # The trigger must be disabled in order to configure whether the source - # is software or hardware. - if cam.TriggerMode.GetAccessMode() != PySpin.RW: - print('Unable to disable trigger mode (node retrieval). Aborting...') - return False - - cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) - - print('Trigger mode disabled...') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def print_device_info(nodemap): - """ - This function prints the device information of the camera from the transport - layer; please see NodeMapInfo example for more in-depth comments on printing - device information from the nodemap. - - :param nodemap: Transport layer device nodemap. - :type nodemap: INodeMap - :returns: True if successful, False otherwise. - :rtype: bool - """ - - print('*** DEVICE INFORMATION ***\n') - - try: - result = True - node_device_information = PySpin.CCategoryPtr(nodemap.GetNode('DeviceInformation')) - - if PySpin.IsAvailable(node_device_information) and PySpin.IsReadable(node_device_information): - features = node_device_information.GetFeatures() - for feature in features: - node_feature = PySpin.CValuePtr(feature) - print('%s: %s' % (node_feature.GetName(), - node_feature.ToString() if PySpin.IsReadable(node_feature) else 'Node not readable')) - - else: - print('Device control information not available.') - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - return False - - return result - - -def run_single_camera(cam): - """ - This function acts as the body of the example; please see NodeMapInfo example - for more in-depth comments on setting up cameras. - - :param cam: Camera to run on. - :type cam: CameraPtr - :return: True if successful, False otherwise. - :rtype: bool - """ - try: - result = True - err = False - - # Retrieve TL device nodemap and print device information - nodemap_tldevice = cam.GetTLDeviceNodeMap() - - result &= print_device_info(nodemap_tldevice) - - # Initialize camera - cam.Init() - - # Retrieve GenICam nodemap - nodemap = cam.GetNodeMap() - - # Configure trigger - if configure_trigger(cam) is False: - return False - - # Acquire images - result &= acquire_images(cam) - - # Reset trigger - result &= reset_trigger(cam) - - # Deinitialize camera - cam.DeInit() - - except PySpin.SpinnakerException as ex: - print('Error: %s' % ex) - result = False - - return result - - -def main(): - """ - Example entry point; please see Enumeration example for more in-depth - comments on preparing and cleaning up the system. - - :return: True if successful, False otherwise. - :rtype: bool - """ - result = True - - # Retrieve singleton reference to system object - system = PySpin.System.GetInstance() - - # Get current library version - version = system.GetLibraryVersion() - print('Library version: %d.%d.%d.%d' % (version.major, version.minor, version.type, version.build)) - - # Retrieve list of cameras from the system - cam_list = system.GetCameras() - - num_cameras = cam_list.GetSize() - - print('Number of cameras detected: %d' % num_cameras) - - # Finish if there are no cameras - if num_cameras == 0: - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - print('Not enough cameras!') - input('Done! Press Enter to exit...') - return False - - # Run example on each camera - for i, cam in enumerate(cam_list): - - print('Running example for camera %d...' % i) - - result &= run_single_camera(cam) - print('Camera %d example complete... \n' % i) - - # Release reference to camera - # NOTE: Unlike the C++ examples, we cannot rely on pointer objects being automatically - # cleaned up when going out of scope. - # The usage of del is preferred to assigning the variable to None. - del cam - - # Clear camera list before releasing system - cam_list.Clear() - - # Release system instance - system.ReleaseInstance() - - input('Done! Press Enter to exit...') - return result - - -if __name__ == '__main__': - if main(): - sys.exit(0) - else: - sys.exit(1) diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/README.txt b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/README.txt deleted file mode 100644 index 8966c05..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/README.txt +++ /dev/null @@ -1,362 +0,0 @@ -============================================================================= -Copyright (c) 2001-2020 FLIR Systems, Inc. All Rights Reserved. - -This software is the confidential and proprietary information of FLIR -Integrated Imaging Solutions, Inc. ("Confidential Information"). You -shall not disclose such Confidential Information and shall use it only in -accordance with the terms of the license agreement you entered into -with FLIR Integrated Imaging Solutions, Inc. (FLIR). - -FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE -SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES -SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING -THIS SOFTWARE OR ITS DERIVATIVES. -============================================================================= - -============================================================================= -== -== README -== -============================================================================= - -PySpin is a wrapper for FLIR Integrated Imaging Solutions' Spinnaker library. - -FLIR Integrated Imaging Solutions' website is located at https://www.flir.com/iis/machine-vision - -The PySpin Python extension provides a common software interface -to control and acquire images from FLIR USB 3.0, GigE, -and USB 2.0 cameras using the same API under 32- or 64-bit Windows. - -============================================================================= -TABLE OF CONTENTS -============================================================================= -1. INSTALLATION -1.1 INSTALLATION ON WINDOWS -1.2 INSTALLATION ON LINUX -1.3 INSTALLATION ON MACOS -2. API DIFFERENCES -3. REMOVE PYSPIN - -============================================================================= -1. INSTALLATION -============================================================================= - ------------------------------------------------------------------------------ -1.1 WINDOWS ------------------------------------------------------------------------------ - -1. Install Python. Currently we support Python 2.7, 3.5-3.8. To download - Python, visit https://www.python.org/downloads/. Note that the Python - website defaults to 32-bit interpreters, so if you want a 64-bit version - of Python you have to click into the specific release version. - -2. (Optional) Set the PATH environment variable for your Python installation. - This may have been done automatically as part of installation, but to do - this manually you have to open Environment Variables through the following: - - My Computer > Properties > Advanced System Settings > Environment Variables - - Add your Python installation location to your PATH variable. For example, - if you installed Python at C:\Python38\, you would add the following entry - to the PATH variable: - - C:\Python38\ - -3. Configure your Python installation. From a command line, run the following - commands to update and install dependencies for your associated Python version: - - -m ensurepip - -m pip install --upgrade pip numpy matplotlib - - NumPy is a requirement for PySpin and needs to be at least version 1.15 or - above. Matplotlib is not required for the library itself but is used in some - of our examples to highlight possible usages of PySpin. For better support of - matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.8, install a supported Pillow using the following command: - - ex. py -3.8 -m pip install Pillow==7.0.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - py -2.7 -m pip install enum34 - -4. To ensure prerequisites such as drivers and Visual Studio redistributables - are installed on the system, run the Spinnaker SDK installer that corresponds - with the PySpin version number. For example, if installing PySpin 1.8.0.0, - install Spinnaker 1.8.0.0 beforehand, selecting only the Visual Studio - runtimes and drivers. - -5. Run the following command to install PySpin to your associated Python version. - This command assumes you have your PATH variable set correctly for Python: - - -m pip install spinnaker_python-2.x.x.x-cp3x-cp3x-win_amd64.whl - - Ensure that the wheel downloaded matches the Python version you are installing to! - -After installation, PySpin examples can be ran directly from the command prompt. -For example, if PySpin is installed for Python 3.8, run a preinstalled example -using the following: - - ex. py -3.8 Examples\Python3\Acquisition.py - ------------------------------------------------------------------------------ -1.2 LINUX ------------------------------------------------------------------------------ - -1. Check that pip is available for your respective Python versions - by running the following command: - - sudo apt-get install python-pip python3-pip - -2. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above for Ubuntu - 18.04 and version 1.19 or above for Ubuntu 20.04. Matplotlib is not required for - the library itself but is used in some of our examples to highlight possible - usages of PySpin. Install these dependencies by running one of the following - commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.5, user only (16.04 only): - python3.5 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.8, user only: - python3.8 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.8, site wide: - sudo python3.8 -m pip install --upgrade numpy matplotlib - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.8, install a supported Pillow using the following command: - - ex. python3.8 -m pip install Pillow==7.0.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -3. Ensure that the corresponding version of the Spinnaker SDK Debian packages - and their prerequisites are installed beforehand - (ex. install the 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -4. Install wheel for specific Python version. This can be installed site-wide - for all users or for a specific user. - - - Python 2.7, site wide: - sudo python -m pip install spinnaker_python-2.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 2.7, user only: - python -m pip install --user spinnaker_python-2.x.x.x-cp27-cp27mu-linux_x86_64.whl - - - Python 3.5, site wide (16.04 only): - sudo python3.5 -m pip install spinnaker_python-2.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.5, user only (16.04 only): - python3.5 -m pip install --user spinnaker_python-2.x.x.x-cp35-cp35m-linux_x86_64.whl - - - Python 3.6, site wide: - sudo python3.6 -m pip install spinnaker_python-2.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.6, user only: - python3.6 -m pip install --user spinnaker_python-2.x.x.x-cp36-cp36m-linux_x86_64.whl - - - Python 3.7, site wide: - sudo python3.7 -m pip install spinnaker_python-2.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.7, user only: - python3.7 -m pip install --user spinnaker_python-2.x.x.x-cp37-cp37m-linux_x86_64.whl - - - Python 3.8, site wide: - sudo python3.8 -m pip install spinnaker_python-2.x.x.x-cp38-cp38-linux_x86_64.whl - - - Python 3.8, user only: - python3.8 -m pip install --user spinnaker_python-2.x.x.x-cp38-cp38-linux_x86_64.whl - -5. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.8 Examples/Python3/DeviceEvents.py - ------------------------------------------------------------------------------ -1.3 MACOS ------------------------------------------------------------------------------ - -1. Check that Python is installed. MacOS comes with Python 2.7 installed, - but it may be an older build of Python. Up-to-date Python packages - can be downloaded from https://www.python.org/downloads. - -2. Update pip for Python. Run the following command for your version of Python: - - sudo -m ensurepip - - This will install a version of pip and allow you to update or install new wheels. - -3. Install library dependencies for PySpin: numpy and matplotlib. NumPy is a - requirement for PySpin and needs to be at least version 1.15 or above. - Matplotlib is not required for the library itself but is used in some of - our examples to highlight possible usages of PySpin. Install these - dependencies by running one of the following commands. - - - Install for Python 2.7, user only: - python -m pip install --upgrade --user numpy matplotlib - - - Install for Python 2.7, site wide: - sudo python -m pip install --upgrade numpy matplotlib - - - Install for Python 3.6, user only: - python3.6 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.6, site wide: - sudo python3.6 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.7, user only: - python3.7 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.7, site wide: - sudo python3.7 -m pip install --upgrade numpy matplotlib - - - Install for Python 3.8, user only: - python3.8 -m pip install --upgrade --user numpy matplotlib - - - Install for Python 3.8, site wide: - sudo python3.8 -m pip install --upgrade numpy matplotlib - - - For better support of matplotlib output image file formats, Pillow is suggested to be installed. - Note: some versions of Pillow might NOT support some Python versions. - - The full list of supported Pillow versions given a Python version can be found here: - https://pillow.readthedocs.io/en/stable/installation.html#notes - - For example, with Python 3.8, install a supported Pillow using the following command: - - ex. python3.8 -m pip install Pillow==7.0.0 - - Older installations of Python 2.7 do NOT come with enum34, which is required by - the Inference.py Python2 example. Install enum34 for Python 2.7 using the following command: - - python2.7 -m pip install enum34 - -4. Ensure that the corresponding version of the Spinnaker SDK MacOS packages - and their prerequisites are installed beforehand. - (ex. install 1.21.0.61 packages if the wheel version is also 1.21.0.61) - -5. Install the PySpin wheel for specific Python version. - ex. sudo python3.7 -m pip install spinnaker_python-2.x.x.x-cp37-cp37mu-macos_x86_x64.whl" for 64-bit Python 3.7 - -6. The examples are located in the Examples folder of the extracted tarball. Run with: - ex. python3.7 Examples/Python3/DeviceEvents.py - -============================================================================= -2. API DIFFERENCES -============================================================================= - -Except for the changes listed below, most function names are exactly the same -as the C++ API. See examples for PySpin usage! - -- All methods of SpinnakerException no longer exist, please replace all - usages of SpinnakerException with any of the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, - build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The SpinnakerException instance itself can be printed, as it derives from - the BaseException class and has a default __str__ representation. - See examples for usage. - -- Image creation using NumPy arrays (although the int type of the array must be uint8) - -- The majority of headers from the C++ API have been wrapped, with the exception of: - - Headers with "Adapter" or "Port" in the name - - NodeMapRef.h, NodeMapFactory.h - - Synch.h, GCSynch.h, Counter.h, filestream.h - -- INode and IValue types (esp. returned from GetNode()) have to - be initialized to their respective pointer types - (ex. CFloatPtr, CEnumerationPtr) to access their functions - -- CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr - have to be manually released and/or deleted before program exit (use del operator) - - See EnumerationEvents example - -- Image.GetData() returns a 1-D NumPy array of integers, the int type - depends on the pixel format of the image - -- Image.GetNDArray() returns a 2 or 3-D NumPy array of integers, only for select - image formats. This can be used in libraries such as PIL and/or OpenCV. - -- Node callbacks take in a callback class instead of a function pointer - - Register is now RegisterNodeCallback, Deregister is now DeregisterNodeCallback - - See NodeMapCallback example for more details - -- IImage.CalculateChannelStatistics(StatisticsChannel channel) returns - a ChannelStatistics object representing stats for the given channel - in the image. These stats are properties within the ChannelStatistics object, - Please see the docstring for details. This replaces ImageStatistics! - -- Pass-by-reference functions now return the type and take in void - - GetFeatures() returns a Python list of IValue, instead of taking - in a FeatureList_t reference - - GetChildren() returns a Python list of INode, instead of taking - in a NodeList_t reference - - Same with GetEntries(), GetNodes() - - GetPropertyNames() returns a Python list of str, - instead of taking in a gcstring_vector reference - - See DeviceEvents example for usage - -- Methods Get() and Set() for IRegister and register nodes use NumPy arrays - - Get() takes in the length of the register to read and two optional - bools, returns a NumPy array - - Set() takes in a single NumPy array - -============================================================================= -3. REMOVE PYSPIN -============================================================================= - -Removing or updating PySpin is similar to removing or updating other wheels. - -For Windows, if you need to remove PySpin, the following command needs to be -run from an administrator command prompt to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a user-specific install, run -the following command to remove your associated Python version: - - -m pip uninstall spinnaker-python - -For Linux or MacOS, if you need to remove PySpin from a site-wide install the -following command needs to be run as sudo to remove your associated Python version: - -sudo -m pip uninstall spinnaker-python \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.chm b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.chm deleted file mode 100644 index 4e69f95..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.chm and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.pdf b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.pdf deleted file mode 100644 index 5b2a889..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/docs/PySpinDoc.pdf and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/FFmpeg_compliance_doc.txt b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/FFmpeg_compliance_doc.txt deleted file mode 100644 index 7b06e29..0000000 --- a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/FFmpeg_compliance_doc.txt +++ /dev/null @@ -1,2 +0,0 @@ -This software uses code of FFmpeg http://ffmpeg.org licensed under the LGPL v2.1 (http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -The FFmpeg code can be found online at https://github.com/FFmpeg/FFmpeg/tree/5156578d1f486163d5b83f1d63246cd23d107933. \ No newline at end of file diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/Spinnaker-Open-Source-Licenses.pdf b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/Spinnaker-Open-Source-Licenses.pdf deleted file mode 100644 index 55a8894..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/licenses/Spinnaker-Open-Source-Licenses.pdf and /dev/null differ diff --git a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64.whl b/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64.whl deleted file mode 100644 index 79472e1..0000000 Binary files a/FLIR/old/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64/spinnaker_python-2.2.0.48-cp38-cp38-win_amd64.whl and /dev/null differ diff --git a/andor_repo/andor/andor_driver.py b/andor_repo/andor/andor_driver.py index 37fd038..e922517 100644 --- a/andor_repo/andor/andor_driver.py +++ b/andor_repo/andor/andor_driver.py @@ -8,7 +8,7 @@ class ANDOR: """Driver for ANDOR camera """ def __init__(self): - self.cam = atmcd("") #load the atmcd library + self.cam = atmcd()# atmcd("") was working. Switch back if a problem! Without the "" also appears to be working #load the atmcd library # self.reset() diff --git a/flir_repo/flir.egg-info/SOURCES.txt b/flir_repo/flir.egg-info/SOURCES.txt index c7fb78e..b6fb7f0 100644 --- a/flir_repo/flir.egg-info/SOURCES.txt +++ b/flir_repo/flir.egg-info/SOURCES.txt @@ -2,6 +2,7 @@ setup.py flir/__init__.py flir/aqctl_flir.py flir/driver.py +flir/testing.py flir.egg-info/PKG-INFO flir.egg-info/SOURCES.txt flir.egg-info/dependency_links.txt