Python Reference Documentation¶
fluxEngine Hyperspectral Data Processing Engine
-
fluxEngine.versionString()¶ Get the version string of fluxEngine
The string that is returned here should not be parsed by the user, and the user should not make any assumptions based on the format of the string. It is purely for informational purposes, if the user of fluxEngine wants to show that string to the end-user, for example. If version-based checks are to be done, please use versionMajor() and versionMinor() instead.
Returns: The current version of fluxEngine Return type: str
-
fluxEngine.versionMajor()¶ Get the major version of fluxEngine
Returns: The current major version of fluxEngine Return type: int
-
fluxEngine.versionMinor()¶ Get the minor version of fluxEngine
Returns: The current minor version of fluxEngine Return type: int
-
class
fluxEngine.Handle(licenseData)¶ fluxEngine Handle
This class represents a handle to fluxEngine’s functionality. It is required to perform any operation with fluxEngine.
Currently only one initialized handle may be created at a time. (This restriction will be relaxed in a future version.)
Important: this has the consequence that if a new handle is to be created, the old handle has to be properly deleted, via the
delkeyword.Each handle is associated with a number of processing threads that the user can manage. A handle may only be used to process a single model at the same time, though multiple models may be loaded for a given handle.
Valid license data must be passed to the constructor, otherwise fluxEngine will not initialize itself. It is up to the user to read the license data from the given license file, if they choose to store it in a file.
If an error occurs (for example because the license was not valid), an exception will be thrown.
Parameters: licenseData (binary) – The raw bytes of the license file -
createProcessingThreads(count, initFunction=None)¶ Create processing threads
fluxEngine may use parallization to speed up processing. In order to achieve this background threads must be created to run on additional CPU cores.
Calling this method is optional: by default processing will be single-threaded.
This method will start
count - 1threads when called, as the thread that asks for processing is always considered to be the first thread (with id0). For example, if4is supplied tocountthis function will start3threads that run in the background. The thread that the user uses to call ProcessingContext.processNext() will be considered the thread with id0, making processing use a total of4threads, which is the value supplied for count.This method may only be called if there are currently no background threads associated with this handle. Otherwise stopProcessingThreads() must be called first to change the number of threads.
Any processing context that was created before a call to this method was made is marked as invalid and can only be destroyed, but not used anymore.
If
initFunctionis notNoneit will be called at the beginning of every newly created background thread. This allows the user to customize the thread properties (such as the CPU affinity) themselves.This method will only return once all threads have been created and their initialization functions (if specified) have run.
The thread initialization functions are only called for the background threads that are started by this method; this means that for a
countof4the initialization function will be called in three background threads, and it is up to the user to alter the thread in which they call ProcessingContext.processNext() to process data with fluxEngine.The threads will be created sequentially, the next thread being created only after the previous thread’s initialization function has completed. This allows the user to directly modify global data structures in the initialization functions without the need for locking.
An example call to this method could be something like this:
def init_thread(threadId, threadCount): print("Creating thread {0} of {1}".format(threadId, threadCount)) handle.createProcessingThreads(4, init_thread)
If the user detects an error condition during thread initialization and wants to abort, they should throw an exception in the initialization function they supplied, which will be propagated out of the call to this method.
Important: any attempt to call a method that accesses this handle inside the initialization functions will create a deadlock.
If an error occurs, an exception will be thrown.
Parameters: - count (int) – The number of threads to use for parallel processing (one less than this number will be created by this method, see the description for details)
- initFunction (callable) – The thread initialization function, or
Noneif no special thread initialization is to be used
-
setDriverBaseDirectory(path)¶ Set the driver base directory
When loading drivers this sets the base directory where the device drivers may be found. If this method is not called, or an empty value or None is passed, a default will be used that is non sensible for the use in a Python context, so the user should call this when intending to use fluxEngine in combination with drivers..
The directory specified here must exist, otherwise it will not be used and an error will be raised.
-
setDriverIsolationExecutable(path)¶ Set the path to the driver isolation executable
Drivers are loaded via the fluxDriverIsolation executable (on Windows fluxDriverIsolation.exe), in case the default is not where the executable is deployed.
By default the driver isolation executable will be searched for in the directory of the Python module itself.
-
stopProcessingThreads()¶ Stop all existing processing threads.
This will stop any background threads that are currently associated with a given handle. If processing is currently active on the handle, it will be aborted, as if ProcessingContext.abort() had been called. In that case this method may take a bit of time, as abort operations are not immediate, and this method will wait until the abort has completed.
Any processing context that was created before a call to this method was made is marked as invalid and can only be destroyed, but not used anymore.
This method is always successful: the only errors that could occur when calling this method would be non-recoverable.
-
-
class
fluxEngine.Model(handle, modelData)¶ Runtime Model
This class wraps a runtime model that has been loaded into fluxEngine.
If the user destroys the library handle while this object still exists, this object will be marked as invalid and no more operations may be performed on this object.
The user must supply fluxEngine with the raw bytes of a serialized runtime model, as a bytes-like object.
If an error occurs an exception will be thrown.
While the raw C API supports reading a model directly by specifying a file name, the Python API doesn’t, as it is extremely convenient to read a file in Python directly, and the error reporting of that is more in line with the rest of Python.
The following example loads a model from hard disk:
with open('model.fluxmdl', 'rb') as f: model = fluxEngine.Model(handle, f.read()) # At this point model may be used
Parameters: - handle (Handle) – The fluxEngine handle to load the model into. This is required as the loaded license determines which specific features within a model are allowed
- modelData (bytes) – The raw binary data of the model
-
class
GroupInfo(name, color)¶ Group information
This structure contains the information about a group that is stored within a given runtime model.
-
name¶ The name of the group
Type: str
-
color¶ The color of the group, encoded in the format
0xffRRGGBB. To obtain the red, green and blue values of the color one may use the helper methods that are part of this class.Type: int
-
blueComponent()¶ Obtain the blue color value of the group’s color
This helper method returns the blue color value of the group’s color, in a range of
0to255.
-
greenComponent()¶ Obtain the green color value of the group’s color
This helper method returns the green color value of the group’s color, in a range of
0to255.
-
redComponent()¶ Obtain the red color value of the group’s color
This helper method returns the red color value of the group’s color, in a range of
0to255.
-
-
groupInfos()¶ Get the information about all groups in a model
Returns the information about all groups in a model as a list. The index of the list is also the group id (that may be returned by a classifier).
Each group consists of a name and a color, and they are returned in form of a Model.GroupInfo structure.
For example, the following code lists all groups and their colors in a given model:
for groupInfo in model.groupInfos(): r = groupInfo.redComponent() g = groupInfo.greenComponent() b = groupInfo.blueComponent() print("Group with name {0} has color rgb({1}, {2}, {3})".format(groupInfo.name, r, g, b))
-
class
fluxEngine.ProcessingContext(model, contextType, **kwargs)¶ Processing Context
This class wraps a processing context, the main interface to processing data with fluxEngine.
Parameters: - model (Model) – The model to create the processing context for. For instrument
device recording or preview contexts this should be set to
None. - contextType (int) – The type of processing context to create. This must be either
ProcessingContext.HSICube,ProcessingContext.PushBroomFrame,ProcessingContext.InstrumentPreview,ProcessingContext.InstrumentHSIRecording, orProcessingContext.InstrumentProcessing. Depending on this value specific keyword arguments may be supplied.
Keyword Arguments: - storageOrder (HSICube_StorageOrder or PushBroomFrame_StorageOrder) – (Non-device processing) The storage order of the input data
- dataType (numpy.dtype) – (Non-device processing) The scalar data type of the input data of the processing context. Not all possibly numpy types are supported, the following are allowed: int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64.
- maxHeight (int) – (Non-device HSI Cubes) The maximum height of a cube that will be processed using this processing context
- height (int) – (Non-device HSI Cubes only) Specify
-1here to leave the cube height dynamic (which might not be as efficient at runtime for some models), or the same value asmaxHeightto fix the height and indicate it will always be the same for every cube that is being processed - maxWidth (int) – (Non-device HSI Cubes) The maximum width of a cube that will be processed using this processing context
- width (int) –
(Non-device HSI Cubes) Specify
-1here to leave the cube width dynamic (which might not be as efficient at runtime for some models), or the same value asmaxWidthto fix the width and indicate it will always be the same for every cube that is being processed(Non-device PushBroom Frames) The spatial dimension of each PushBroom frame that is supplied (if the storage order indicates that wavelengths are across the x direction of the frame, this indicates the size of the frame in the y direction, and vice-versa)
- wavelengths (list or numpy.array) –
(Non-device processing) a 1d list of wavelengths that determine the bands of the input data.
(Instrument HSI recording) A list of floating point values indicating the wavelength grid onto which to interpolate the data. This may be None to indicate that no interpolation should occur.
- referenceInfo (ReferenceInfo) – (Non-device processing) how the data should be referenced. See the documentation of the ReferenceInfo type for further details
- device (InstrumentDevice) – (Instrument preview/recording/processing) The device to create the processing context for. This must always be specified when creating contexts for processing instrument data directly.
- valueType (ValueType) – (Instrument HSI recording) Specifies the value type of the data that is to be recorded. If ValueType.Reflectance is specified a white reference must typically be provided, unless the driver directly returns reflectance values. (Which is only the case for virtual drivers reading reflectance data.)
- instrumentParameters (InstrumentParameters) – (Instrument HSI recording and instrument processing) Specifies the white and dark references required to standardize the data
Notes
For
ProcessingContext.HSICubetype contexts the following keyword arguments are required (and the others should not be specified):- storageOrder
- dataType
- maxHeight
- height
- maxWidth
- width
- wavelengths
- referenceInfo
For
ProcessingContext.PushBroomFrametype contexts the following keyword arguments are required (and the others should not be specified):- storageOrder
- dataType
- maxWidth
- width
- wavelengths
- referenceInfo
For
ProcessingContext.InstrumentPreviewtype contexts the following keyword arguments are required (and the others should not be specified):- device
For
ProcessingContext.InstrumentHSIRecordingtype contexts the following keyword arguments are required (and the others should not be specified):- device
- valueType
- instrumentParameters
- wavelengths (optional)
For
ProcessingContext.InstrumentProcessingtype contexts the following keyword arguments are required (and the others should not be specified):- device
- instrumentParameters
-
HSICube= 0¶ HSI Cube Context Type
This value may be supplied to the constructor to indicate that a processing context is to be created for processing entire HSI cubes.
-
InstrumentHSIRecording= 3¶ Instrument HSI Recording Context Type
This value may be supplied to the constructor to indicate that a processing context is to be created for recording HSI data from a device. The model parameter must be set to None and a keyword parameter
devicemust be specified to indicate the device to generate the context for.
-
InstrumentPreview= 2¶ Instrument Preview Context Type
This value may be supplied to the constructor to indicate that a processing context is to be created for generating a standardized preview of the device data. The model parameter must be set to None and a keyword parameter
devicemust be specified to indicate the device to generate the context for.
-
InstrumentProcessing= 4¶ Instrument Processing Context Type
This value may be supplied to the constructor to indicate that a processing context is to be created for processing data directly from a device. The model parameter must be set to the requested model and a keyword parameter
devicemust be specified to indicate the device to generate the context for.
-
PushBroomFrame= 1¶ PushBroom Frame Context Type
This value may be supplied to the constructor to indicate that a processing context is to be created for processing a sequence of PushBroom frames.
-
abort()¶ Abort processing.
This method may be called from a different thread while processing is currently active. It will signal the processing context to abort processing. This method will return immediately, but the processing context is likely still active. Use the wait() method to wait until the processing context is no longer active. After a call to this methgod the processing context needs to be reset via the method resetState() before it may be used again.
-
findOutputSink(outputId)¶ Find the index of an output sink with a given output id
If there is exactly one output sink in the model with a given output id, this will return the index of that sink. If there are no output sinks with that id, or that output id is used multiple times, this will throw an error.
Returns: The index of the sink Return type: int
-
hsiRecordingResultInfo()¶ Get the HSI recording result information
This only applies to processing contexts for Instrument HSI recordings. This will additional inforamtion that the user may need to properly interpret the recording data.
On other processing contexts None will be returned.
-
numOutputSinks()¶ Get the number of output sinks
Returns: The number of output sinks Return type: int
-
outputSinkData(index)¶ Get the resulting output sink data after processing
This may only be called after processNext() has been called at least once and resetState() has not been called since the last call to processNext().
Returns the data that arrived at the output sink during the last processing execution. For output sinks that return tensor data a numpy.array will be returned, while for output sinks that return lists of objects a
listof OutputObject objects will be returned.Note: at the moemnt a copy of the data returned by fluxEngine is made before it is passed back to the user, as the internal memory management of fluxEngine is not easily mapped onto the memory ownership model of numpy or Python. This might change in a future version of fluxEngine.
Parameters: index (int) – The index of the output sink to obtain the data from Returns: The output sink data, depending on the output sink type Return type: object
-
outputSinkInfo(index)¶ Get information about a specific output sink
Parameters: index (int) – The index of the output sink Returns: The information about the given output sink Return type: OutputSinkInfo
-
outputSinkInfos()¶ Get information about all output sinks in the model
The position in the list will indicate the index of the sink. For example, the first entry of the list will correspond to an output sink index of
0, the second to1, etc.Returns: A list of OutputSinkInfo objects for each output sink Return type: list
-
processNext()¶ Perform data processing
After setSourceData() has been called process that data with fluxEngine. The results may be queried via the outputSinkData() method.
-
resetState()¶ Reset the state of the processing context
This method may only be called in between calls of processNext().
When the data to be processed is in the form of entire HSI cubes, that is, the context was created via the variant of the constructor that indicates HSI cubes should be processed, this method will have no effect. (Unless processing was aborted via abort(), in which case this must be called to clean up the state.)
When the data to be processed is in the form of consecutive PushBroom frames, that is, the context was created via the overload of the constructor that indicates PushBroom frames should be processed, this method will reset the internal state and make the context appear as if it had been freshly created. This means that any operation that remembers past state to gain spatial information in the y direction will be reset to the beginning. This affects mostly object-based operations.
This would typically be called when a system with a PushBroom camera is started up again after a pause, and the previously processed data has no direct relation to the data to be processed from this point onwards.
-
setSourceData(data)¶ Set the source data for the next processing iteration
In contrast to the C/C++ APIs this method must be called before each call to processNext(), otherwise the same data will be processed each time.
HSI Cubes
If the input cube size was fixed during the creation of the processing context, the height and width parameters must match the height and width specified during creation of the context, or an error will be thrown.
If the input cube size was variable during the creation of the processing context, the height and width parameters must be smaller than or equal to the maximum size specified during the creation of the context.
The storage order of the cube that has been specified during the creation of the processing context will be used. This means that the height and width parameters may refer to different dimensions of the cube depending on the storage order:
- For a BIP cube, the cube will be indexed via
(y, x, band), meaning the height parameter referes to the dimension 0, the width parameter to dimension 1 and the wavelength count supplied during creation of the cube to the dimension 2 of the cube. This means the supplied data must have the shape(height, width, bands) - For a BIL cube, the cube will be indexed via
(y, band, x), meaning the height parameter referes to the dimension 0, the width parameter to dimension 2 and the wavelength count supplied during creation of the cube to the dimension 1 of the cube. This means the supplied data must have the shape(height, bands, width) - For a BSQ cube, the cube will be indexed via
(band, y, x), meaning the height parameter referes to the dimension 1, the width parameter to dimension 2 and the wavelength count supplied during creation of the cube to the dimension 0 of the cube. This means the supplied data must have the shape(bands, height, width)
PushBroom Frames
The input PushBroom frame size had to be fixed during the creation of the processing context, and the size of the frame must be equal to
widthandbands.The storage order of the cube that has been specified during the creation of the processing context will be used. The supplied frame must be a 2D image with the following dimensions:
- For LambdaX storage order, the width of the image must be equal to the wavelength count specified during the creation of the processing context, while the height of the image must be equal to the specified spatial width.
- For LambdaY storage order, the height of the image must be equal to the wavelength count specified during the creation of the processing context, while the width of the image must be equal to the specified spatial width.
Note: at the moment a copy of the source data will be made as soon as this method is called, as the internal memory management of fluxEngine is not easily mapped onto the memory ownership model of numpy. This might change in a future version of fluxEngine.
Devices
A BufferInfo or PersistentBufferInfo object must be supplied that was retrieved from the device.
Parameters: data (numpy.array or BufferInfo) – The new source data to set - For a BIP cube, the cube will be indexed via
-
wait()¶ Wait until processing or an abort is complete.
This method may be called from a different thread while processing is currently active. It will wait until the processing context is not in use anymore, either because processing has completed in the mean time, or an abort was requested and the abort has completed.
Note that ProcessingContext::processNext() already blocks and this method must only be used from different threads that also want to wait for the processing of a specific context to complete.
- model (Model) – The model to create the processing context for. For instrument
device recording or preview contexts this should be set to
-
class
fluxEngine.HSICube_StorageOrder¶ Hyperspectral data cube storage order
Hyperspectral cubes consist of three dimensions, and the storage order defines how these dimensions are mapped into linear memory.
The introductory documentation also contains a visual depiction of the various storage orders of HSI cubes.
-
BIL= 1¶ Band Interleaved by Line Storage Order
In this storage order all pixels of a line are next to each other in memory, and wavelengths are grouped by line. This means that input arrays have the shape
(y, λ, x).
-
BIP= 0¶ Band Interleaved by Pixel Storage Order.
In this storage order all wavelengths of each pixel are next to each other in memory. This means that input arrays have the shape
(y, x, λ).
-
BSQ= 2¶ Band Sequential Storage Order
In this storage order all pixels of an individual band are next to each other in memory, and wavelengths are grouped by image. This means that input arrays have the shape
(λ, y, x).
-
-
class
fluxEngine.PushBroomFrame_StorageOrder¶ Hyperspectral PushBroom frame storage order
A PushBroom camera is a hyperspectral camera that uses a 2D sensor to image a single line, where the optics project different wavelengths of the incoming light onto one of the sensor dimensions. The other sensor dimension is used to spatially resolve the line that is being imaged.
There are two possible orientations of the optics: the wavelengths could be mapped onto the x- or the y-direction of the camera sensor. This enumeration allows the user to select which of these storage orders is actually used.
-
LambdaX= 0¶ Wavelengths are in X-direction
The y direction of the frame contains the spatial information.
-
LambdaY= 1¶ Wavelengths are in Y-direction
The x direction of the frame contains the spatial information.
-
-
class
fluxEngine.ValueType¶ The value type of a given input
Determines how to interpret the input values the user has provided.
-
Intensity= 0¶ Intensities
The data supplied by the user are raw intensities. If the model is set to process reflectances and/or absorbances reference data must be provided before processing can occur.
-
Reflectance= 1¶ Reflectances
The data supplied by the user are reflectances.
-
-
class
fluxEngine.ReferenceInfo(valueType, whiteReference=None, darkReference=None)¶ Information about references
This information structure must be supplied when creating a processing context. It specifies the input value type of the processing context, as well as any references.
There are three primary ways to handle referencing of data:
- The source in the model is set to raw intensities, and raw intensities are supplied by the user for the input data of the model while processing. In that case any references provided will be ignored
- The source in the model is set to reflectances or absorbances, and the user provides reflectances for the input data of the model while processing. In that case any references provided will be ignored
- The source in the model is set to reflectances or absorbances, and the user provides raw intensities for the input data of the model while processing. In that case a white reference must be provided to automatically reference the input data, and optionally a dark reference may be provided.
When referencing input data, if only a white reference is provided, reflectances are calculated with the following formula:
reflectance = intensity / white
If a dark reference is also present, reflectances are calculated with the following formula:
reflectance = (intensity - dark) / (white - dark)
-
valueType¶ The value type of the input data, determining how to preprocess the data (if at all) before using it for the model
Type: ValueType
-
whiteReference¶ The white reference data. This must be a numpy array that contains the white reference that will be used in conjunction with the input data.
Since it is advantageous to average multiple reference measurements, this array has to have an additional dimension to denote a list of input frames.
- For HSI cubes in BIP order this means that the shape of the
reference array has to be
(N, height, width, bands). - For HSI cubes in BIL order this means that the shape of the
reference array has to be
(N, height, bands, width). - For HSI cubes in BSQ order this means that the shape of the
reference array has to be
(N, bands, height, width). - For PushBroom frames in LambdaX order the shape of the
reference array has to be
(N, width, bands) - For PushBroom frames in LambdaX order the shape of the
reference array has to be
(N, bands, width)
The number of averages, N, may be 1, indicating that no average is to be calculated. In that case
numpy.expand_dimsmay be used to convert a single measurement to the desired format:info.whiteReference = numpy.expand_dims(white_ref_cube, axis=0)If no white reference is present, the user may specify
None.Type: numpy.array - For HSI cubes in BIP order this means that the shape of the
reference array has to be
-
darkReference¶ The dark reference data. This must have the same structure as the white reference data.
If no dark reference is present, the user may specify
None.Type: numpy.array
-
class
fluxEngine.OutputSinkTensorStructure(dataType, maxSizes, fixedSizes)¶ Tensor Structure of an output sink
An object of this type will be assigned to the
structuremember of the OutputSinkInfo object when querying an output sink that returns tensor (numpy array) data. It will contain information about what type of data the output sink returns.-
dataType¶ The numpy data type of the array that will be returned
Type: numpy.dtype
-
maxSizes¶ The maximum shape of the data that will be returned. Any data returned from this output sink will always be an array that has a shape with the same number of dimensions, but each dimension will be at most the corresponding entry in this tuple.
Type: tuple
-
fixedSizes¶ The fixed shape of the data that will be returned. The number of entries in this tuple will indicate to the user the number of dimensions of the data that is being returned. If a specific dimension is dynamic, i.e. the number of elements that are returned may change, the corresponding entry will be -1, otherwise it will be the size that will be returned in all cases.
Type: tuple
-
-
class
fluxEngine.OutputSinkObjectListStructure(maxObjectCount, additionalDataSize=0, additionalDataType=None)¶ Output Sink Object List Structure
An object of this type will be assigned to the
structuremember of the OutputSinkInfo object when querying an output sink that returns a list of objects.-
maxObjectCount¶ The maximum number of objects that may be returned during a single iteration of processing. This number is typically very high and will be an indication of the theoretical maximum that could be returned, but the actual number will in practice be quite a bit lower.
Type: int
-
additionalDataSize¶ If additional per-object data is returned in form of a numpy array, this indicates the size of the data returned. Additional data will always have only one dimension, and will always be of a fixed size. If this is
0no additional data will be returned together with the objects.Type: int
-
additionalDataType¶ If additional per-object data is returned this will contain the numpy datatype of the additional data.
Type: numpy.dtype
-
-
class
fluxEngine.OutputSinkInfo(outputId, name, structure, delay)¶ Output Sink Information
Objects of this type will be returned when querying information about output sinks of a model.
To determine whether an output sink returns tensor data (in the form of numpy arrays) or lists of objects, the following code may be used:
if isinstance(info.structure, fluxEngine.OutputSinkTensorStructure): print("output sink returns tensor data") elif isinstance(info.structure, fluxEngine.OutputSinkObjectListStructure): print("output sink returns object list") else: print("output sink returns unknown data")
-
outputId¶ The output id of the given output sink. This may be assigned by the user in fluxTrainer.
Type: int
-
name¶ The name the user has assigned to the output sink in fluxTrainer.
Type: str
-
structure¶ This may either be of type OutputSinkTensorStructure or of type OutputSinkObjectListStructure, and will contain further information about the output sink.
Type: object
-
delay¶ The input delay of the output sink.
This is only relevant when processing sequences of PushBroom frames, please see the advanced topics chapter in the documentation for further details.
Type: int
-
-
class
fluxEngine.OutputObject(boundingBox, gravityCenter, area, mask, primaryClass, additionalData)¶ An object that is output
If an output sink is configured to output object data, it will return a list of objects of this type, containing the information related to each object.
This class provides some helper methods that perform some common operations.
-
boundingBox¶ The bounding box of the object, in form of a tuple with the elements
(x, y, width, height). Each member of the tuple is of typeint.Type: tuple
-
gravityCenter¶ The center of gravity of the object, in form of a tuple with the elements
(x, y). Each member of the tuple is of typefloat.Type: tuple
-
area¶ The area of the object in pixels
Type: int
-
mask¶ The mask of the object within the bounding box. The shape of this array will always be
(height, width), whereheightandwidthare taken from the bounding box. A value of0indicates that a given pixel belongs to the object, while a value of-1indicates that a given pixel does not belong to the object.It may be the case that this is not present and
None.There are helper methods, isObjectPresentAt() and isObjectPresentAtAbsolute(), that may be used to determine whether a given pixel belongs to this object.
Type: numpy.array
-
primaryClass¶ The primary class of the object. If this is
Noneit indicates that no classifier was applied to this object in the processing chain. If this is of typeintit indicates that the object was subject to a classifier, but it may still be that the classifier couldn’t find a matching class for this object, in which case the value will be-1. If the value is non-negative it corresponds to the group id of the class within the model.Important: since
0is a valid class, the user should take care to use the checkif object.primaryClass is not None:instead of a simpleif object.primaryClassto test for the presence of a primary class.Type: int
-
isObjectPresentAt(x, y)¶ Determine if a given pixel is part of the detected object
For a given set of coordinates for a pixel that are measured relative to the top-left corner of the bounding box this method will determine if that pixel belongs to the object or not. If the object does not contain any mask information, this will always return false.
Parameters: - x (int) – The x coordinate relative to the top-left corner of the bounding box of the object to check
- y (int) – The y coordinate relative to the top-left corner of the bounding box of the object to check
Returns: Whether a pixel is part of the object
Return type: bool
-
isObjectPresentAtAbsolute(x, y)¶ Determine if a given pixel is part of the detected object
For a given set of coordinates for a pixel that are measured absolutely to the start of the cube this method will determine if that pixel belongs to the object or not. For sequences of PushBroom frames that are being processed the
ycoordinate is measured in the number of frames since the last reset via ProcessingContext.resetState(). If the object does not contain any mask information, this will always return false.Parameters: - x (int) – The absolute x coordinate
- y (int) – The absolute y coordinate
Returns: Whether a pixel is part of the object
Return type: bool
-
-
class
fluxEngine.ParameterInfo(rawInfo)¶ Parameter Information
This class contains information about parameters in various contexts. Most notably it will provide information about parameters required to connect to a device, as well as parameters of a connected device itself.
Objects of this class should never be created directly by the user, but it will be returned by various device-related methods.
-
class
AccessMode¶ The access mode of a given parameter
The access mode describes whether a parameter may be read from or written to.
-
NotAvailable= 0¶ The parameter is not available
This indicates that the parameter can currently neither be read nor written.
-
ReadOnly= 1¶ The parameter is read-only
-
ReadWrite= 3¶ The parameter may be read from and written to
This is the case for most parameters.
-
WriteOnly= 2¶ The parameter is write-only
This is typically only the case for ParameterInfo.Type.Command type parameters.
-
-
class
EnumerationEntry(name, value, displayName=None)¶ Enumeration Entry
This structure describes an enumeration entry that is part of an enumeration parameter.
The user should never need to create this structure themselves, rather it is returned by accessors of the ParameterInfo class.
-
name¶ The name of the enumeration entry
This will be unique within the enumeration parameter.
Type: str
-
value¶ The value of the enumeration entry
This should be unique within the enumeration parameter, but aliases for the same value may exist. (The first entry in the list is the canonical name.)
Type: int
-
displayName¶ The display name of the enumeration entry
If this is not None this contains a more user-friendly string that describes this entry.
Type: str or None
-
effectiveDisplayName()¶ Get the effective display name of the entry
If the display name is not set, the entry’s name will be returned instead.
Returns: The effective display name of the entry Return type: str
-
-
class
Parameter(name, type, accessMode, displayName=None)¶ Complete Parameter Information
This structure contains all of the information of a given parameter collected into a single structure. It is returned by both ParameterInfo.parameter() and ParameterInfo.parameters().
-
name¶ The name of the parameter
This will be unique within the parameter information structure.
Type: str
-
type¶ The type of the parameter
Type: ParameterInfo.Type
-
accessMode¶ The access mode of the parameter
The access mode determines if a parameter can be read from or written to – or, in case of commands, if it can be executed.
Type: ParameterInfo.AccessMode
-
displayName¶ The display name of the parameter
If not None this is a more human-readable name of the parameter.
Type: str or None
-
shortDescription¶ A short description of the parameter
If not None this is typically shown in form of a tool-tip when hovering over a parameter.
Type: str or None
-
longDescription¶ A long description of the parameter
Type: str or None
-
affectedParameters¶ A list of affected parameters
If the value of this parameter is changed by the user, this list of parameter names indicates which parameters may also change due to that write. Affected parameters may have a different value, access mode, minmum, maximum or increment when a parameter changes.
The names in this list denote the unique name of each affected parameter, not the display name.
It is not necessary that a change to this parameter actually changes one of the affected parameters, it only indicates that such a change is possible.
Type: list(str)
-
defaultValue¶ The default value of a parameter
For device parameters there is no default value, there is only the currently set value. (As well as potentially the initial value after a connection to the device is established, and it would be up to the user to determine that – though it is not guaranteed that the initial value hasn’t been affected by previous connections while the device has been powered on.)
For parameters describing how to connect to a specific device there may be a default value, and this attribute will contain that value.
If the attribute is None there is no default value present.
If the field is of any other type it will contain the default value depending on the type of the parameter. String and file parameters will have default values in the form of a str object, integer and enumeration parameters will have default values of int type, floating point parameters will have default values of float type, and boolean parameters will have default values of bool type.
Type: str or int or float or bool or None
-
unit¶ The unit of a value
Numeric (integer and floating point) parameters may have a unit associated with them, such as “ms” or “Hz”. If present this will contain that unit.
This will always be None for parameters that do not have a unit (because it is either not set or they are of a type that doesn’t have units).
Type: str or None
-
enumerationEntries¶ The list of available enumeration entries
For ParameterInfo.Type.Enumeration type parameters this will contain a list of all entries in the given enumeration.
Type: list(ParameterInfo.EnumerationEntry)
-
minimum¶ The minimum value
For numeric (integer and floating point) parameters this will contain the lowest value that the parameter accepts.
In all other cases this will be None.
Type: int or float or None
-
maximum¶ The maximum value
For numeric (integer and floating point) parameters this will contain the largest value that the parameter accepts.
In all other cases this will be None.
Type: int or float or None
-
increment¶ The increment value
For ParameterInfo.Type.Integer type parameters this will contain the increment value required to obtain a valid value of this parameter. Specifically, a valid value for the given integer must take the form value = minimum + N * increment, where N is an arbitrary positive integer.
For ParameterInfo.Type.Float type parameters this will give an indication of the increment to use while the user is editing this parameter. If an increment is actually enforced for floating point values, it means that the supplied value will be rounded to the nearest allowed value upon write.
In all other cases this will be None.
Type: int or float or None
-
effectiveDisplayName()¶ Get the effective display name of the parameter
If the display name is not set, the parameter’s name will be returned instead.
Returns: The effective display name of the parameter Return type: str
-
-
class
Type¶ The type of parameter
-
Boolean= 0¶ Boolean
The parameter can either be True or False.
-
Command= 6¶ Command
A command parameter is a parmaeter that can be used to trigger an action on the device.
-
Enumeration= 3¶ Enumeration
The parameter can be chosen from a set of predetermined values. Each predetermined value is associated with an integer value as well as a unique name.
-
File= 5¶ File
The parameter is the path to a file in the filesystem. The path can be accessed like a string.
Values supplied for this parameters must be of type str (unicode), not of type bytes or any other path-like object.
-
Float= 2¶ Floating Point
The parameter is a floating point value. There may be additional limits imposed on the range of the floating point value.
-
Integer= 1¶ Integer
The parameter is an integer value. There may be additional limits imposed on the range of the integer value.
-
String= 4¶ String
-
Unknown= -1¶ Unknown type
This is returned if a specific parameter does not fall into one of the other parameter types.
-
-
numParameters()¶ Return the number of parameters
Returns: The number of parameters Return type: int
-
parameter(i)¶ Get all information about a specific parameter
Returns all information about a specific parameter all at once.
If a parameter with that index or name does not exist, an error will be raised.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: All information about a specific parameter Return type: ParameterInfo.Parameter
-
parameterAccessMode(i)¶ Get the access mode of a parameter
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The access mode of the parameter Return type: ParameterInfo.AccessMode
-
parameterAffectedParameters(i)¶ Get the parameters affected by changes to a parameter
For a given parameter, determine the list of parameters that might change if the value of the chosen parameter changes. For example, when changing the BinningHorizontal parameter of a camera, the value and limits of the OffsetX and Width parameters of that camera may change as a result of the change in binning. The parameters that may be affected by a change in parameter values are listed here.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The names of the parameters that might be affected by changes to the specified parameter Return type: list(str)
-
parameterDefaultValue(i)¶ Get the default value of a parameter
Returns the default value of a parameter (if available) in the correct type for that specific parameter.
For device parameters there is no default value, there is only the currently set value. (As well as potentially the initial value after a connection to the device is established, and it would be up to the user to determine that – though it is not guaranteed that the initial value hasn’t been affected by previous connections while the device has been powered on.) In that case this method will raise an error.
For parameters describing how to connect to a specific device there may be a default value, and that will be returned by this method.
Note that the default value of an enumeration parameter will be of integer type, indicating the default enumeration value. (The name of the default enumeration entry can then be looked up separately.)
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The default value of the parameter in the approriate type, or None. Return type: str or int or float or bool or None
-
parameterDisplayName(i)¶ Get the display name of a parameter
A display name is an optional more human-readable name of a parameter.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The display name of the parameter Return type: str or None
-
parameterEffectiveDisplayName(i)¶ Get the effective display name of a parameter
This will return the parameter’s display name, if set, or otherwise the parameter’s name. This is a convenient accessor to always obtain a name that may be shown to the user, but that will show a more human-readable name if possible.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The effective display name of the parameter Return type: str
-
parameterEnumerationEntryDisplayName(i, j)¶ Get the display name of an enumeration entry of an enumeration parameter
For a parameter of type ParameterInfo.Type.Enumeration return the display name of a specific enumeration entry.
If the parameter is not of enumeration type, or the specified entry does not exist, an error will be raised.
Parameters: - i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter.
- j (int or str) – Either the index of the enumeration entry (starting at zero, up to one less than the size of the list returned by ParameterInfo.parameterEnumerationEntryNames()), or the name of the enumeration entry.
Returns: The display name of the enumeration entry
Return type: str or None
-
parameterEnumerationEntryEffectiveDisplayName(i, j)¶ Get the effective display name of an enumeration entry of an enumeration parameter
For a parameter of type ParameterInfo.Type.Enumeration return the effective display name of a specific enumeration entry. This will either be the display name of the entry (if set) or the name of the entry.
If the parameter is not of enumeration type, or the specified entry does not exist, an error will be raised.
Parameters: - i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter.
- j (int or str) – Either the index of the enumeration entry (starting at zero, up to one less than the size of the list returned by ParameterInfo.parameterEnumerationEntryNames()), or the name of the enumeration entry.
Returns: The effective display name of the enumeration entry
Return type: str
-
parameterEnumerationEntryNames(i)¶ Get the names of all enumeration entries of an enumeration parameter
For a parameter of type ParameterInfo.Type.Enumeration return a list of the names of all enumeration entries of that parameter.
If the parameter is not of enumeration type, an error will be raised.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The list of enumeration entry names for that parameter Return type: list(str)
-
parameterEnumerationEntryValue(i, j)¶ Get the value of an enumeration entry of an enumeration parameter
For a parameter of type ParameterInfo.Type.Enumeration return the value of a specific enumeration entry.
If the parameter is not of enumeration type, or the specified entry does not exist, an error will be raised.
Parameters: - i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter.
- j (int or str) – Either the index of the enumeration entry (starting at zero, up to one less than the size of the list returned by ParameterInfo.parameterEnumerationEntryNames()), or the name of the enumeration entry.
Returns: The value of the enumeration entry
Return type: int
-
parameterIncrement(i)¶ Get the increment of the parameter
For numeric parameters (ParmaeterInfo.Type.Integer or ParameterInfo.Type.Float) return the largest value that is allowed for the parameter.
For ParameterInfo.Type.Integer type parameters this will contain the increment value required to obtain a valid value of this parameter. Specifically, a valid value for the given integer must take the form value = minimum + N * increment, where N is an arbitrary positive integer.
For ParameterInfo.Type.Float type parameters this will give an indication of the increment to use while the user is editing this parameter. If an increment is actually enforced for floating point values, it means that the supplied value will be rounded to the nearest allowed value upon write.
If the parameter is of the wrong type, an error will be raised.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The increment of the parameter Return type: int or float
-
parameterLongDescription(i)¶ Get the long description of a parameter
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The long description of the parameter Return type: str or None
-
parameterMaximum(i)¶ Get the maximum value of the parameter
For numeric parameters (ParmaeterInfo.Type.Integer or ParameterInfo.Type.Float) return the largest value that is allowed for the parameter.
If the parameter is of the wrong type, an error will be raised.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The maximum value of the parameter Return type: int or float
-
parameterMinimum(i)¶ Get the minimum value of the parameter
For numeric parameters (ParmaeterInfo.Type.Integer or ParameterInfo.Type.Float) return the lowest value that is allowed for the parameter.
If the parameter is of the wrong type, an error will be raised.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The minimum value of the parameter Return type: int or float
-
parameterNames()¶ Return the list of parameter names
Returns: The list of parameter names Return type: list(str)
-
parameterShortDescription(i)¶ Get the short description of a parameter
If set a short description is often displayed in form of a tool-tip to the user.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The short description of the parameter Return type: str or None
-
parameterType(i)¶ Get the type of a parameter
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The type of the parameter Return type: ParameterInfo.Type
-
parameterUnit(i)¶ Get the unit of a parameter
Numeric parameters (ParameterInfo.Type.Integer and ParameterInfo.Type.Float) may have a unit assigned to them that describes the physical unit of the parameter, such as “ms” or “Hz.
Parameters: i (int or str) – Either the index of the parameter (starting at zero, up to one less than the result of ParameterInfo.numParameters()), or the name of the parameter. Returns: The unit of the parameter, or None if no unit is set Return type: str or None
-
parameters()¶ Get all information about all available parameters
Returns: All information about all available parameters Return type: list(ParameterInfo.Parameter)
-
class
-
class
fluxEngine.DriverType¶ Driver Type
-
Instrument= 0¶ Instrument driver
This driver accesses instrument devices, such as cameras, spectrometers, and other sensors.
-
LightControl= 2¶ Light control device
This driver accesses light control devices that can be used to switch a light on and off, and possibly set the light intensity.
-
-
class
fluxEngine.DriverState¶ Driver state
Describes the state of the driver at the end of the enumeration process. This can be used to detect issues with the driver.
-
Crashed= 4¶ Driver crashed
The driver crashed during enumeration. This typically indicates that there is an issue with a missing dependency of the driver.
-
EnumerationError= 3¶ Enumeration error
The driver generated an error message during the enumeration process. That error can be queried from the enumeration result.
-
LoadError= 2¶ Driver load error
The driver could not be loaded, for example because the driver file is not valid, or the isolation executable could not be found (in which case all drivers will suffer from this error).
-
LoadTimeout= 1¶ Driver load timeout
The driver didn’t respond at all within the specified enumeration timeout, indicating that it didn’t load in time. If a sufficiently long timeout has been provided (e.g. more than 3 seconds) this is typically an indication that there is an issue with the driver.
-
OK= 0¶ OK
The driver could successfully perform the enumeration. This is a valid state even if the driver didn’t find any device.
-
Unknown= -1¶ The state is unknown
This likely indicates an internal error during enumeration.
-
-
class
fluxEngine.EnumeratedDriver(name, type, description, version, state)¶ Enumerated driver
Describes a driver that was used during enumeration. Failed drivers will also have such a structure, even though they will not have any associated devices.
This structure is returned as part of an enumeration process. The user will never need to create a structure of this type themselves, but will access the properties of the driver through the attributes.
-
name¶ The name of the driver
This is the filename component of the driver and may be used to identify the driver for connection purposes.
Type: str
-
type¶ The type of the driver
This is required for identifying the driver for connection purposes.
Type: DriverType
-
description¶ A human-readable name of the driver
Type: str
-
version¶ A human-readable version of the driver
Type: str
-
state¶ The state of the driver
Type: DriverState
-
devices¶ The devices the driver has found
This list may be empty if a specific driver has found no devices.
Type: list(EnumeratedDevice)
-
-
class
fluxEngine.EnumeratedDevice(id, driver, displayName, manufacturer, model, serialNumber, parameterInfo)¶ Enumerated device
Describes a device that was found during enumeration.
Note that some drivers can’t actually enumerate the available devices in the system, and rely on probing to actually connect to a device. In that case a device entry will appear regardless of whether the device is actually present, and connection failure is the only way of ascertaining that the device is not actually present.
This structure is returned as part of an enumeration process. The user will never need to create a structure of this type themselves, but will access the properties of the device through the attributes.
-
id¶ A driver-specific id of the device
This id must be provided in combination with the type and name of the driver for a connection attempt.
The id is guaranteed to be stable for a short period of time after enumeration so that it may be used for connection purposes.
It is not guaranteed to be stable across reboots, software updates, etc. The user should never rely on the specific content of this id, even if it appars to be stable at the moment.
Type: bytes
-
driver¶ The driver that enumerated the device
Type: EnumeratedDriver
-
displayName¶ The display name of the device
This is a human-readable text that is of the format Vendor Model (Serial Number), but in such a manner that if one or more of these strings is empty a sensible text will still be generated – for example, if a device has no serial number, the format will be Vendor Model instead.
Type: str
-
manufacturer¶ The manufacturer of the device
Type: str
-
model¶ The model of the device
Type: str
-
serialNumber¶ The serial number of the device
This may be empty, which can mean two things: either the device has no serial number, or the serial number could not be obtained during device enumeration and requires the user to connect to the device to actually read it.
Type: str
-
parameterInfo¶ The parameter info for the connection parameters
Contains information about all connection parameters of the device. For some devices it is necessary to set the some parameters (such as the path to a calibration file) when connecting to the device. This contains the available parameters.
Type: ParameterInfo
-
-
class
fluxEngine.EnumerationWarning(driver, message)¶ Enumeration warning
Describes a warning that was encountered during enumeration. This could be a USB device that could not be accessed because the correct kernel driver is not installed, or a network device that was found but was on the wrong subnet for a given network interface.
This structure is returned as part of an enumeration process. The user will never need to create a structure of this type themselves, but will access the properties of the device through the attributes.
-
driver¶ The driver for which the warning occurred
Type: EnumeratedDriver
-
message¶ The warning message
Type: str
-
-
class
fluxEngine.EnumerationError(driver, message)¶ Enumeration error
Describes an error that occurred during enumeration, for example a driver that crashed.
This structure is returned as part of an enumeration process. The user will never need to create a structure of this type themselves, but will access the properties of the device through the attributes.
-
driver¶ The driver for which the error occurred
Type: EnumeratedDriver
-
message¶ The error message
Type: str
-
-
class
fluxEngine.EnumerationResult(devices, drivers, warnings, errors)¶ The result of an enumeration process
This structure is returned by an enumeration process. The user will never need to create a structure of this type themselves, but will access the properties of the device through the attributes.
-
devices¶ The devices that were found
Type: list(EnumeratedDevice)
-
drivers¶ The drivers that were used during enumeration
Type: list(EnumeratedDriver)
-
warnings¶ Warnings that occurred during enumeration
Type: list(EnumerationWarning)
-
errors¶ Errors that occurred during enumeration
Type: list(EnumerationError)
-
-
fluxEngine.enumerateDevices(handle, driverType, timeout)¶ Enumerate devices
This function enumerates all devices that are connected to the system for which drivers have been installed. Please note that Handle.setDriverBaseDirectory() must be called before this function to indicate where the drivers are to be found. Also, if the user has changed the path to the fluxDriverIsolation.exe (by default it is deployed along with the Python module) they must also call Handle.setDriverIsolationExecutable() before this function.
Parameters: - handle (Handle) – The fluxEngine handle
- driverType (DriverType or None) – The type of driver to enumerate. Specify None to indicate all driver types should be enumerated.
- timeout (int) – How long to enumerate in milliseconds. This method will always wait this long for the enumeration process to complete and will then return all devices that were found within that given timespan. It is recommended to set this to at least 3.5 seconds.
Returns: The enumerated devices
Return type:
-
class
fluxEngine.ConnectionSettings(driverName, driverType, id)¶ Connection settings
This structure must be passed to DeviceGroup() constructor and contains the required information to connect to a given device.
The constructor of this class takes the minimum required information for connecting to any device. If the device requires additional settings, the user should modify the corresponding attributes directly.
Parameters: - driverName (str) –
The name of the driver
This should be the value taken from the EnumeratedDriver.name
- driverType (str) –
The type of the driver
This should be the value taken from the EnumeratedDriver.type
- id (bytes) –
The id of the device to connect to
This should be the value taken from the EnumeratedDevice::id
Note that while it may be tempting to hard-code this id instead of reenumerating devices each time, and even if it appears to be the case right now, there is no guarantee that the id is stable across reboots of the machine or even different versions of fluxEngine.
-
driverName¶ The name of the driver
This should be the value taken from the EnumeratedDriver.name
Type: str
-
driverType¶ The type of the driver
This should be the value taken from the EnumeratedDriver.type
Type: str
-
id¶ The id of the device to connect to
This should be the value taken from the EnumeratedDevice::id
Note that while it may be tempting to hard-code this id instead of reenumerating devices each time, and even if it appears to be the case right now, there is no guarantee that the id is stable across reboots of the machine or even different versions of fluxEngine.
Type: bytes
-
connectionParameters¶ The connection parameters to use
This is a dictionary with keys of type str and values of type str.
The key of this dict is the name of the parameter; it must be identical to the name of the parameter returned by ParameterInfo.parameterNames() or ParameterInfo.Parameter.name.
The value of this dict is the serialized string of the value of the parameter:
- For boolean this must be “True”, “On”, “Yes” or “1” for true and “False”, “Off”, “No” or “0” for false.
- For integer parameters this must be the integer converted to a string, e.g. “123” or “-1”.
- For floating point parameters this must be the floating point value serialized as a string, scientific notation with ‘e’ is allowed, using ‘.’ as the decimal separator; the following are valid floating point values: “123”, “42.6” and “-146.1468e-43”.
- For enumeration parameters this must contain the name (not the display name!) of the selected enumeration entry. The name is case-sensitive.
- For file parameters (e.g. calibration files) the file name must be specified as a str (unicode) object, bytes and/or other path-like objects will not be accepted.
For integer, floating point and boolean values converting it to a string directly in Python should suffice, for example:
connectionSettings.connectionParameters[‘Key’] = str(42.67)If a parameter is not specified here, its default will be used. There are no defaults for file parameters, and if a file is required for the connection process, the connection attempt will fail.
Type: dict
-
timeout¶ The connection timeout in milliseconds
Typically a value of 60 seconds is a good option here; some devices may be able to connect in less time, but anything less than 10 seconds will nearly always be too short, and for some cameras even 10 seconds is not enough. The actual time required to connect can vary, so it is prudent to use at least three times the amount of time that it takes in a lab environment to connect to a specific device.
If this timeout occurs while the connection is still in progress, the driver subprocess will be terminated (as there is no other way to abort the connection attempt), which could leave the device in an undefined state. It is therefore not recommended to make this extremely short.
Type: int
- driverName (str) –
-
class
fluxEngine.DeviceType¶ The type of the device
-
Instrument= 0¶ Instrument device
The device in question is an instrument, e.g. a camera or a spectrometer.
-
LightControl= 2¶ Light control device
-
-
class
fluxEngine.DeviceGroup(handle, connectionSettings)¶ Device Group
This structure describes a device group, the result of a connection process. When connecting to a device the actual result of a connection is a device group: the device itself and potentially some subdevices. For example, an instrument device might have a subdevice that is actually a light control device.
Each device group has a primary device that can be obtained via the DeviceGroup.primaryDevice() function. The primary device will have the type correpsonding to the driver’s primary type. A subdevice may be of a completely different type.
It is possible to completely ignore subdevices.
Note: currently there are no drivers that actually provide subdevices.
This method attempts to connect to a device (group). If successful a device group handle is returned to the user.
If the fluxEngine license was tied to a instrument device serial number, and the connected device is an instrument, a license check will be performed at this point. If it fails the device will be disconnected again. If it succeeds the user will be able to create processing contexts and process data, even if the data is not from the device. When the device group is disconnected the user will not be able to continue processing at this point.
Parameters: - handle (Handle) – The fluxEngine handle
- connectionSettings (ConnectionSettings) – The settings that select the device and the connection parameters.
-
class
Notification(type_, device, message)¶ Device notification
Parameters: - type (DeviceGroup.NotificationType) – The type of the notification
- device (Device) – The device the notification has occurred for
- message (str) – The notification message
-
type¶ The type of the notification
Type: DeviceGroup.NotificationType
-
message¶ The notification message
Type: str
-
class
NotificationType¶ Device notification type
This enumeration describes the various types of notifications that devices can generate. Notifications must be retrieved by the user manually via DeviceGroup::nextNotification(), but the handle returned by DeviceGroup::notificationEventHandle() may be used to add notifications to the event loop.
-
IrrecoverableError= 0¶ Irrecoverable error
This notification is generated whenever the device switches into an irrecoverable error state.
See also: - LightControlDevice.Status.IrrecoverableError - InstrumentDevice.Status.IrrecoverableError
-
RecoverableError= 1¶ Recoverable error
This notification is generated whenever the device switches into a recoverable error state.
See also: - LightControlDevice.Status.RecoverableError - InstrumentDevice.Status.RecoverableError
-
Warning= 2¶ Warning
This notification is generated whenever the device encounters a warning. This could for example be that the temperature is outside of the operating range in the specifications. For example, if an instrument requires a stabilized sensor, and that temperature should be at 20C, if the device measures a value that is not around that value, the device could generate a warning.
-
-
disconnect(timeout=5000)¶ Disconnect from the device group
This method attempts to disconnect from a device group. If that does not succeed within the specified timeout, the driver isolation process is force-unloaded.
Important: all handles of the device group and all devices in the group will no longer be valid after this point. This means the user must not access any of the following objects belonging to this device group after a call to this function:
- The device group itself
- Any device within the device group
- Any instrument buffer retrieved from the device
The user does, however, need to explicitly free any processing contexts they created for a device in this group, any reference buffer and any parameter list.
Parameters: timeout (int) – The timeout in milliseconds, after which the device will be forcibly disconnected by terminating the driver isolation process. A sensible value here is 5 seconds.
-
driverDescription()¶ Get the driver description
Returns a human-readable name/description of the driver.
Returns: The driver description Return type: str
-
driverName()¶ Get the name of the driver
The driver name is the same that was supplied with the connection settings.
Returns: The name of the driver Return type: str
-
driverType()¶ Get the type of the driver
The driver type is the same that was supplied with the connection settings.
Returns: The type of the driver Return type: DriverType
-
driverVersion()¶ Get the driver version
Returns a human-readable version string of the driver.
Returns: The driver version Return type: str
-
nextNotification()¶ Retrieve the last notification
Retrieves the last notification in the internal notification buffer of the device group. If no notification is present this will be None.
The user may use this to poll the device for notifications.
Returns: The next notification in the internal notification buffer Return type: DeviceGroup.Notification or None
-
class
fluxEngine.Device(wrapped)¶ A device
This base class describes a device that has been connected. The actual class of the device object will be a subclass of this class, depending on the precise type of device.
In addition to checking whether an object is an instance of a specific subclass of the Device class it is also possible to use the Device.type() method to obtain the device type as an enumeration value.
Device objects are only valid as long as the device group remains connected. Once the device group is disconnected or the driver unloaded, all device objects will cease to be valid. Accessing them will result in an error being raised.
A device object should never be created by the user directly, it is always returned by other methods.
See also
DeviceGroup.primaryDevice() Device.subdevices()
-
class
ParameterListType¶ Parameter list type
While all device parameters live in the same namespace, there are specific lists of parameters for different purposes. This enumeration describes the different purposes, and parameter information lists can be queried for each type.
When reading and/or writing a parameter it is of no consequence to which type of list the parameter belongs to. A parameter could also be a part of multiple lists.
-
MetaInfo= 1¶ Meta information
This list will contain the read-only meta information that is fixed and won’t change while the device is connected. This could be calibration data for the device, but also information about the manufacturer and similar items.
-
Parameter= 0¶ A standard parameter
This list will contain the parameters that change the behavior of a device. This could be the exposure time of a camera, or the intensity of a light control device.
-
Status= 2¶ Status information
This list will contain read-only parameters that describe the device’s current status, such as built-in temperature sensors that allow the user to verify the device is in its correct operating range.
-
-
description()¶ Get the device’s description
Some devices may have an additional description that they may return.
This may be empty.
Returns: The device’s description Return type: str
-
executeParameterCommand(name)¶ Execute a command parameter
Parameters: name (str) – The name of the parameter
-
getParameter(name)¶ Get the value of a parameter
Returns the current value of the parameter.
Depending on the type of the parameter the return type may be different.
Parameters: name (str) – The name of the parameter Returns: The current value of the parameter Return type: str or int or float or bool
-
isParameterCommandComplete(name)¶ Is a command parameter complete
Some commands can be executed in the background (returning from the execute command call earlier than execution is done) and whether they are done can be queried with this method. If the command has already completed, is always executed synchronously (and thus has completed after the command execution function returned), or has never been executed, this method will return as if the command has completed.
Parameters: name (str) – The name of the parameter Returns: Whether the command has completed (or was never executed) Return type: bool
-
manufacturer()¶ Get the device’s manufacturer
Returns: The device’s manufacturer Return type: str
-
model()¶ Get the device model
Returns: The device model Return type: str
-
parameterList(listType)¶ Get a specific parameter list of the device
The resulting parameter list is dynamically tied to this device; changing a parameter may change the limits of other parameters and the list will always return the most current data.
Parameters: listType (Device.ParameterListType) – The type of parameter list to get Returns: The parameter list Return type: ParameterInfo
-
ping()¶ Ping a device
This method ensures that the device is still responsive, without actually performing an action.
This may be used by the user to verify that everything is still OK with the device without performing an action that change something on the device. The user should query the state of the device after this method, even if it is successful.
-
resetError()¶ Reset a recoverable error
Reset a recoverable error of a device. This method will only work if the device is in a recoverable error state and the error condition has since disappeared.
-
serialNumber()¶ Get the device’s serial number
Some devices may have no serial number (in which case this will be empty), but instrument devices will typically all have one.
If a serial number is available during device enumeration it will be identical to the serial number returned here. However it is possible for a device to have a serial number that cannot be obtained during enumeration, so that it is only accessible after the device has already been connected.
Returns: The device’s serial number Return type: str
-
setParameter(name, value)¶ Set a parameter
This will change a device parameter. The value specified must be of the correct type for the given parameter, otherwise the method will raise an error. The correct types are:
- str for string parameters
- int for integer and enumeration parameters
- bool for boolean parameters
- float for floating point parameters
- Additionally, a string may be supplied for any of the other mentioned types, as long as it is encoded according to the rules indicated in the documentation for ConnectionSettings.connectionParameters.
Note that changing some parameters will cause instrument devices to internally stop acquisition. In that case the status of the device will switch to InstrumentDevice.Status.ForcedStop to indicate this. The user must then call InstrumentDevice.stopAcquisition() to stop acquisition on fluxEngine’s side and may then use InstrumentDevice.startAcquisition() to restart acquisition in that case. This will definitely happen when a parameter changes the size or structure of the buffer that is returned, but some drivers may require this to be the case for all parameters. To avoid having to check for this state it is therefore recommended that parameters be changed only when acquisition is stopped, although that is not a requirement.
Parameters: - name (str) – The name of the parameter
- value (str or int or float or bool) – The new value of the parameter
-
subDevices()¶ Get a list of subdevices of this device
Devices may have subdevices that perform a different function than the device itself (for example a build in light control device). This will return a list of all subdevices of the device.
Most devices don’t have subdevices, so this will be empty.
Returns: A list of all subdevices Return type: list(Device)
-
type()¶ Get the device type
Returns: The device type Return type: DeviceType
-
class
-
class
fluxEngine.LightControlDevice(wrapped)¶ Light control device
A light control device allows the user to control whether a light source is active and possibly also the intensity of that light source. This may be helpful for measuring a dark reference (by disabling the light source before the start of the measurement).
As this is a subclass of the Device class it provides all of the functionality of that class (especially when it comes to changing parameters) as well as functionality specific to light control devices.
Light control devices are controlled in two manners:
- The parameters indicate the normal setting of the device. This should typically be configured by the user for the specific use case.
- In addition a “force state” may be set programmatically that allows the user to force the light control device to be either off (regardless of the current parameter settings) or to perform a ramp that starts the light at the off and then gradually increase the light intensity to the setting in the parameters. This may be used for nonlinearity correction reference measurements. (See the documentation about advanced features for more details on this topic.)
-
class
ForceState¶ The force state of the light control device
This describes whether / how the parameters of the device are to be overwritten temporarily.
-
None_= 0¶ The device should be parametrized
The light will be on or off depending on its parameters.
-
Off= 1¶ The light should be forced off
The light will be forced off, regardless of its parameters, and can only be turned on again by changing the force state.
-
Ramp= 2¶ The light should perform a ramp-up
The should perform a ramp-up from being off to going to the level of intensity described by its parameters. This force state will automatically reset to LightControlDevice.ForceState.None once the ramp has completed.
-
-
class
Status¶ Light control device status
-
ForcedOff= 2¶ The light has been forced off
The light has been forced off regardless of the parametrization settings.
-
ForcedRamp= 3¶ The light has been forced into a ramp
The light has been forced to perform a ramp from being switched off completely to being on up to the intensity specified by the settings. This can be used to record references for non-linearity corrections.
This state will always be temporary, after the ramp is complete the device will automatically switch back into the LightControlDevice.Status.Parametrized state.
-
Invalid= -3¶ The device handle is invalid
This can happen if the fluxEngine handle is closed while the device was still connected. In that case the device is forcibly disconnected and will have this status.
-
IrrecoverableError= -2¶ Irrecoverable error occurred
An error occurred that can’t be easily recovered from. For example, if a device is unplugged mid-use, this will be the status the device will have.
Note that it may be possible to reconnect to the device in that case, but the device group must be disconnected first if the state of a device changes in this manner.
-
Off= 0¶ The light is off
Some light control devices are initialized to be off by default, for example because they could be a hazard if automatically switched on during connection. In that case the use must explicitly set a parameter to turn the light on.
This can only be the status of the light after initial connection to indicate this. If the light is on by default after connecting to it, it will be in the state LightControlDevice.Status.Parametrized instead. If the light is switched off again via parameters it will still remain in the LightControlDevice.Status.Parametrized state.
-
Parametrized= 1¶ The light is controlled via parameters
Various settings control whether the light is on or off; if there are multiple lights potentially whether each individual light is on or off; and if lights can be dimmed, what their intensity is.
-
RecoverableError= -1¶ Recoverable error occurred
If an error occurred (for example a strict temperature limit has been exceeded) that can be recovered from (by resetting the device via Device.resetError()) then this will be the status the device will have.
-
-
setForceState(state, rampDuration)¶ Set the force state of the light control device
Parameters: - state (LightControlDevice.ForceState) – The new force state
- rampDuration (int) – The ramp duration in milliseconds, if the device supports it. If the device can only switch the light on and off (but not vary its intensity) this will be ignored and the light will just be switched on; the duration of that process will be fixed within the driver (as that will depend on the hardware and can’t be influenced). If the light’s intensity can be modified the driver will gradually adjust the intensity from zero to the parametrized value with a speed that is adjusted to this time.
-
status()¶ Get the status of a light control device
Returns: The status of the light control device Return type: LightControlDevice.Status
-
waitForRamp()¶ Wait for the device to complete its ramp
This may be called after setting a ramp force state to wait
-
class
fluxEngine.InstrumentDevice(wrapped)¶ Instrument Device
An instrument device is a device that allows the user to perform measurements and use the measured data. This includes spectrometers, cameras, but also other sensors.
Each measurement result is stored in a buffer (see the BufferInfo structure for details) that can be retrieved from the instrument. The measurements are added to a queue, and the user may retrieve each measurement from that queue, use that data, and then return the buffer to the system so it may be used for future measurements.
In order to obtain data from an instrument device, the following steps need to be taken:
- The buffers need to be set up initially. This may be done via InstrumentDevice.setupInternalBuffers() method.
- The user starts acquisition using the InstrumentDevice.startAcquisition() method.
- In a loop the user first retrieves a buffer via the InstrumentDevice.retrieveBuffer() method, then uses that buffer, and finally returns the buffer via the InstrumentDevice.returnBuffer() method
- The user may stop data acquisition via the InstrumentDevice.stopAcquisition() method
-
class
AcquisitionParameters(bufferCount=0, referenceName=None)¶ Acquisition parameters
These parameters are to be supplied when starting acquisition. They may influence the acquisition process in some manner.
Parameters: - bufferCount (int) –
The number of buffers to use
This will be used to initialize the bufferCount attribute.
- referenceName (str) –
The name of the reference to measure
This will be used to initialize the referenceName attribute.
-
bufferCount¶ The number of buffers to use
If this is 0, all of the buffers that have been created in the shared memory region will be used during acquisition. If this is non-zero only this amount of buffers will be used, instead. If this is larger than the amount of buffers allocated in shared memory, starting acquisition will fail.
This may be useful to allocate more buffers for recording purposes while setting up the shared memory, but only use a lesser amount during processing.
The amount of buffers trades off latency for dropped buffers: the more buffers are used in shared memory, the less likely it is that a buffer may be dropped due to timing issues, as more buffers are available. For recording data it is generally useful to use more buffers. (Though too many buffers will result in too much RAM usage.) Unfortunately more buffers increases the latency of data processing, so if a low latency is required it is better to use less buffers.
The minimum number of buffers that may be used is 5; if the number is lower 5 buffers will be used regardless.
Type: int
-
referenceName¶ The name of the reference to measure
Some drivers may react differently when they know a reference is to be measured during the next acquisition. For example, the virtual pushbroom camera driver will return the data of the reference cubes instead of the main cube when a reference is to be measured. But even drivers for real hardware may react differently: some cameras may have an integrated shutter that they can close, and during dark reference measurement this is what will happen in that case.
If this is None this indicates that a normal (non-reference) measurement is to be performed.
Otherwise this must be either “WhiteReference” or “DarkReference”.
In most cases it does not make any difference whether a reference measurement is to be performed or not, and there is no effect of this setting. The user is also not required to perform the reference measurements in this manner – if the special functionality associated (e.g. shutter for dark reference measurements) is not required (because the user just shuts of the light, for example), then the user may perform the reference measurement by just normal acquisition.
Type: str
- bufferCount (int) –
-
class
Status¶ Instrument device status
-
Busy= 1¶ The instrument is busy with an operation
This state will never last very long, but in some cases a parameter change may trigger an operation that happens on the device in the background, and during that operation this will be the state of the device. The device will automatically return to its previous state after the operation has completed. (This is rare.)
-
ForcedStop= 3¶ The instrument was forced to stop
A parameter change caused the instrument to stop. In that case the user must also stop acquisition on their end and start it again. The structure of the individual buffers that the instrument returns may have changed.
Any processing context created for use with the instrument may not be applicable anymore. (It may still be possible to supply the device’s data to the processing context if the size and scalar type match, but the processing context will likely not perform the correct operations.)
-
Idle= 0¶ The instrument is idle
The instrument is idle and not returning data.
-
Invalid= -3¶ The device handle is invalid
This can happen if the fluxEngine handle is closed while the device was still connected. In that case the device is forcibly disconnected and will have this status.
-
IrrecoverableError= -2¶ Irrecoverable error occurred
An error occurred that can’t be easily recovered from. For example, if a device is unplugged mid-use, this will be the status the device will have.
Note that it may be possible to reconnect to the device in that case, but the device group must be disconnected first if the state of a device changes in this manner.
-
RecoverableError= -1¶ Recoverable error occurred
If an error occurred (for example a strict temperature limit has been exceeded) that can be recovered from (by resetting the device via Device.resetError()) then this will be the status the device will have.
-
Streaming= 2¶ The instrument is streaming data
The instrument is streaming data to the user.
-
-
allocatePersistentBuffer()¶ Allocate a persistent buffer info
Allocate a memory region that is large enough to fit a buffer that is returned by the instrument upon acquisition. This may be used by the user to pre-allocate memory to later copy data into.
Note that the allocated PersistentBufferInfo will have the size of the instrument with respect to the current set of parameters – if a parameter is changed that causes the size to change, the buffers returned by the instrument will no longer match the persistent buffer.
The contents of the persistent buffer will be initialized with zero and the buffer number will be set to -1.
Returns: The newly allocated persistent buffer Return type: PersistentBufferInfo
-
maxBufferSize()¶ Get the maximum buffer size (in bytes) that the instrument may return
This will return the maximum size (in bytes) that the device may require to return data to the user. This size is guaranteed to be large enough that regardless of how the device is parametrized it will always be able to hold the data of a single buffer.
Returns: The maximum buffer size the instrument may return Return type: int
-
rawBufferScalarType()¶ Get the scalar type of buffers returned by the device
Given the current settings of the device return the scalar type of buffers that would be returned by the device.
Returns: The current scalar type of buffers returned by the device Return type: BufferScalarType
-
rawBufferShape()¶ Get the shape of buffers returned by the device
Given the current settings of the device return the shape of buffers that would be returned by the device.
Returns: The current shape of buffers returned by the device Return type: tuple
-
recommendedBufferCount()¶ Get the number of recommended buffers
This will return a number that the driver recommends the user use for operating the device. This does not apply to recording mode, where it is convenient to use a larger number of buffers.
Returns: The number of recommended buffers Return type: int
-
retrieveBuffer(timeout, abortCheck=None)¶ Retrieve a buffer from the device
Acquisition must be active for this to succeed.
The buffer retrieved here must be returned via InstrumentDevice.returnBuffer() after the user has no more use for it, otherwise data acquisition from the device will stall.
If specified this method will call an abort check function during the wait time to see if the user has externally aborted acquisition in the mean time. That function will be called quite often and should be light-weight, such as reading an atomic flag.
Parameters: - timeout (int) – How long to wait before returning without a buffer. The actual wait might be larger than this, depending on the scheduler of the operating system.
- abortCheck (callable or None) –
The function that checks whether an external abort has been initiated. If the function returns true an external abort has been requested.
If this is None no abort check is performed.
Returns: The buffer that was retrieved. If None is returned this indicates that no buffer was returned within the specified timeout, or the abort check function returned True.
Return type: BufferInfo or None
-
returnBuffer(bufferInfo)¶ Return a buffer to the instrument
This returns a buffer to the instrument device. The user must not attempt to access the buffer after they have returned it via this method.
Parameters: bufferInfo (BufferInfo) – The buffer to return
-
setupInternalBuffers(count)¶ Setup internal buffers for the device
This will allocate the shared memory region that is used by the driver and fluxEnigne to transfer data from the instrument. The number of buffers can be specified in the count parameter, but must be at least 5. The size of the shared memory region will be buffer_size_page * count + overhead, where buffer_size_page is the size returned by InstrumentDevice.maxBufferSize() rounded up to the minimal size of a virtual memory mapping (on Windows this will always be 65536 bytes, on other operating systems this will be the page size, which is typically between 4096 bytes and 65536 bytes), and overhead is as comparatively small overhead used for bookkeeping. As the amount of shared memory in the system is limited, the user should never specify an excessively large number of buffers, but numbers ranging from 5 to 100 are typically considered acceptable in their memory consumption, assuming that a buffer will only have a size of at most a couple of MB.
Important: this method may only be called once and the device group has to be disconnected to choose a different number of buffers. It is recommended to use the largest number that may be requried here, because the number of buffers that is actually used can be varied when starting acquisition.
Parameters: count (int) – The number of buffers to allocate
-
startAcquisition(acquisitionParameters)¶ Start acquisition
Starts acquisition on the device. Once data is received from the driver the internal buffer queue will start to fill and data may be retrieved via the InstrumentDevice.retrieveBuffer() method.
Parameters: acquisitionParameters (AcquisitionParameters) – The parameters for starting acquisition, such as the number of buffers to use for this specific acquisition. See the documentation of the structure on the various parameters.
-
status()¶ Get the status of an instrument device
Returns: The status of the instrument device Return type: InstrumentDevice.Status
-
stopAcquisition()¶ Stop acquisition
It is safe to call this method if acquisition is not active, in which case this method will not do anything.
-
class
fluxEngine.BufferScalarType¶ Buffer scalar data type
Buffers that are retrieved from instruments may have a specific scalar type associated with them. This is a superset of the data types supported by processing contexts (represented via numpy types in the Python API), which are only the data types that fluxEngine can use for processing.
However, some drivers may write the transported data directly into the buffer – and sometimes the transported data is of a specific packed type.
There are currently no drivers that return data of a type that is not also a standard scalar type, and the enumeration currently does not contain any types other than those also in the DataType enumeration, this will change in future versions.
See also expandedType().
-
Float32= 10¶ 32bit IEEE 754 single-precision floating point number
-
Float64= 11¶ 64bit IEEE 754 double-precision floating point number
-
Int16= 5¶ 16bit signed integer
-
Int32= 6¶ 32bit signed integer
-
Int64= 7¶ 64bit signed integer
-
Int8= 4¶ 8bit signed integer
-
UInt16= 1¶ 16bit unsigned integer
-
UInt32= 2¶ 32bit unsigned integer
-
UInt64= 3¶ 64bit unsigned integer
-
UInt8= 0¶ 8bit unsigned integer
-
-
class
fluxEngine.BufferInfo(wrapped)¶ Instrument Buffer Info
This structure describes a buffer the user has retrieved from an instrument device during acquisition.
Any buffer that has been successfully retrieved must be returned to the instrument via InstrumentDevice.returnBuffer().
The user should never create an object of this type themselves, they should always use InstrumentDevice.retrieveBuffer() to obtain such an object.
-
copy()¶ Copy the data into a new persistent buffer
As instrument buffers must be returned to the device, in order to keep the data of a buffer around for longer, its data may be copied into a persistent buffer.
Returns: The new persistent buffer that contains a copy of the data Return type: PersistentBufferInfo
-
copyInto(target)¶ Copy the data into an existing persistent buffer
As instrument buffers must be returned to the device, in order to keep the data of a buffer around for longer, its data may be copied into a persistent buffer.
This method copies the data of a persistent buffer into another persistent buffer. The user must ensure that the dimensions and type of the target buffer match the source buffer.
All data in the target will be overwritten.
Parameters: target (PersistentBufferInfo) – The persistent buffer to copy the data into
-
getData(targetType=None)¶ Get the raw data in the buffer
The Python API of fluxEngine doesn’t expose the raw data of the buffer. If data is to be retrieved, it will automatically be copied into a numpy array. If the scalar type of the buffer has a corresponding processing type that fluxEngine supports directly, that type may be used for the numpy array, in which case no conversion will take place. If the data in the buffer is present in a packed format, the data will be converted to a data type that may be used for processing. By default this will be the next larger data type relative to the packed type, but the user may request a different type for the result of the conversion.
Parameters: targetType (numpy.dtype) – The numpy type to convert the data to. If not specified this will be the result of expandedType() applied to the scalar type of the data in the buffer.
Note that converting floating point values into an integer is unlikely to be sensible. For example, when converting a floating point value that lies between 0 and 1 into an integer, each element will then be either 0 or 1, which is unlikely to be useful.
Returns: The raw data in the buffer Return type: numpy.ndarray
-
number()¶ Get the number of the buffer
For cameras this corresponds to the frame number of the recorded frame. This may be used to detect frame drops.
Returns: The buffer number Return type: int
-
-
class
fluxEngine.PersistentBufferInfo(wrapped)¶ Persistent Buffer Info
This structure describes a buffer that was copied into is own allocated memory region from a device buffer.
The user will never create such a buffer directly, but will obtain it via one of the following methods:
- InstrumentDevice.allocatePersistentBuffer()
- BufferInfo.copy()
- PersistentBufferInfo.copy()
- BufferContainer.copyBuffer()
-
copy()¶ Copy the data into a new persistent buffer
Returns: The new persistent buffer that contains a copy of the data Return type: PersistentBufferInfo
-
copyInto(target)¶ Copy the data into an existing persistent buffer
This method copies the data of a persistent buffer into another persistent buffer. The user must ensure that the dimensions and type of the target buffer match the source buffer.
All data in the target will be overwritten.
Parameters: target (PersistentBufferInfo) – The persistent buffer to copy the data into
-
getData(targetType=None)¶ Get the raw data in the buffer
The Python API of fluxEngine doesn’t expose the raw data of the buffer. If data is to be retrieved, it will automatically be copied into a numpy array. If the scalar type of the buffer has a corresponding processing type that fluxEngine supports directly, that type may be used for the numpy array, in which case no conversion will take place. If the data in the buffer is present in a packed format, the data will be converted to a data type that may be used for processing. By default this will be the next larger data type relative to the packed type, but the user may request a different type for the result of the conversion.
Parameters: targetType (numpy.dtype) – The numpy type to convert the data to. If not specified this will be the result of expandedType() applied to the scalar type of the data in the buffer.
Note that converting floating point values into an integer is unlikely to be sensible. For example, when converting a floating point value that lies between 0 and 1 into an integer, each element will then be either 0 or 1, which is unlikely to be useful.
Returns: The raw data in the buffer Return type: numpy.ndarray
-
number()¶ Get the number of the buffer
For cameras this corresponds to the frame number of the recorded frame. This may be used to detect frame drops.
Returns: The buffer number Return type: int
-
class
fluxEngine.InstrumentParameters(whiteReference=None, darkReference=None)¶ Instrument parameters
This structure describes common instrument parameters that may be supplied while creating a processing context for recording instrument data or processing it via a fluxEngine/fluxRuntime model.
Currently this exists to allow the user to supply a previously measured white and dark reference measurement.
This structure allows the user to supply the references in form of either BufferContainer objects or numpy arrays. Note that all references must be of the same type – it is not possible to mix them. If numpy arrays are specified they will first be converted into the correct scalar type.
Parameters: - whiteReference (BufferContainer or numpy.ndarray or None) – The white reference data
- darkReference (BufferContainer or numpy.ndarray or None) – The dark reference data
-
whiteReference¶ The white reference data
Type: BufferContainer or numpy.ndarray or None
-
darkReference¶ The dark reference data
Note that in the absence of a white reference a dark reference is currently ignored. (This may change in later versions of fluxEngine.)
Type: BufferContainer or numpy.ndarray or None
-
class
fluxEngine.HSIRecordingResult(wrapped)¶ HSI Recording result
This structure is the return value of the methods that create processing contexts for recording HSI data from a camera. It contains the resulting processing context, as well as further information describing the recording:
- The wavelengths of the normalized data that is being returned.
- If intensity data is requested, and references where specified during the creation of the processing context, the normalized reference data will also be returned. (Most notably a white reference cube will be present.)
-
wavelengths¶ The list of wavelengths of the recorded data
This contains the wavelengths associated with the last dimension of the data being recorded.
Type: list(float)
-
whiteReference¶ Normalized white reference
If a white reference was supplied during the creation of a recording processing context, and the user has requested intensity data, this will contain the normalized white reference that the user may save in addition to the data they will record.
Type: numpy.ndarray or None
-
darkReference¶ Normalized dark reference
If a dark reference was supplied during the creation of a recording processing context, and the user has requested intensity data, this will contain the normalized dark reference that the user may save in addition to the data they will record.
Type: numpy.ndarray or None