Spinnaker C
4.3.0.189
 
NodeMapCallback_C.c

NodeMapCallback_C.c shows how to use nodemap callbacks. It relies on information provided in the Enumeration_C, Acquisition_C, and NodeMapInfo_C examples. As callbacks are very similar to events, it may be a good idea to explore this example prior to tackling the events examples.

This example focuses on creating, registering, using, and unregistering callbacks. A callback requires a certain function signature, which allows it to be registered to and access a node. Events, while slightly more complex, follow this same pattern.

Once comfortable with NodeMapCallback_C, we suggest checking out any of the events examples: EnumerationEvents_C, ImageEvents_C, or Logging_C.

Please leave us feedback at: https://www.surveymonkey.com/r/TDYMVAPI More source code examples at: https://github.com/Teledyne-MV/Spinnaker-Examples Need help? Check out our forum at: https://teledynevisionsolutions.zendesk.com/hc/en-us/community/topics

//=============================================================================
// Copyright (c) 2025 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of FLIR
// Integrated Imaging Solutions, Inc. ("Confidential Information"). You
// shall not disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with FLIR Integrated Imaging Solutions, Inc. (FLIR).
//
// FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================
#include "SpinnakerC.h"
#include "SpinnakerDefsC.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
// This macro helps with C-strings.
#define MAX_BUFF_LEN 256
// Create dynamic array to hold callback handles
typedef struct
{
size_t size;
size_t capacity;
// Initialize the array
void initArray(callbackArray* arr, size_t initialCapacity)
{
arr->callback = (spinNodeCallbackHandle*)malloc(initialCapacity * sizeof(spinNodeCallbackHandle));
arr->node = (spinNodeHandle*)malloc(initialCapacity * sizeof(spinNodeHandle));
arr->size = 0;
arr->capacity = initialCapacity;
}
// Push an element to the end
void push(callbackArray* arr, spinNodeCallbackHandle callbackHandle, spinNodeHandle nodeHandle)
{
if (arr->size == arr->capacity)
{
arr->capacity *= 2;
arr->node = (spinNodeHandle*)realloc(arr->node, arr->capacity * sizeof(spinNodeHandle));
}
arr->callback[arr->size] = callbackHandle;
arr->node[arr->size] = nodeHandle;
arr->size++;
}
// Pop an element from the end
void pop(callbackArray* arr, spinNodeCallbackHandle* callbackHandle, spinNodeHandle* nodeHandle)
{
if (arr->size == 0)
{
printf("Error: Attempt to pop from an empty array..\n\n");
}
arr->size--;
*callbackHandle = arr->callback[arr->size];
*nodeHandle = arr->node[arr->size];
}
// Get the current size of the array
size_t getSize(callbackArray* arr)
{
return arr->size;
}
// Free the array memory
{
free(arr->callback);
free(arr->node);
arr->callback = NULL;
arr->node = NULL;
arr->size = 0;
arr->capacity = 0;
}
// Helper for getting error messages
{
// Note: lastErrorMessage is shared across multiple threads; a different thread could overwrite the last error
// message before this function is called to grab the latest message
}
// This function helps to check if a node is readable
bool8_t IsReadable(spinNodeHandle hNode, char nodeName[])
{
spinError err = SPINNAKER_ERR_SUCCESS;
bool8_t pbReadable = False;
err = spinNodeIsReadable(hNode, &pbReadable);
{
return False;
}
return pbReadable;
}
// This function helps to check if a node is writable
bool8_t IsWritable(spinNodeHandle hNode, char nodeName[])
{
spinError err = SPINNAKER_ERR_SUCCESS;
bool8_t pbWritable = False;
err = spinNodeIsWritable(hNode, &pbWritable);
{
return False;
}
return pbWritable;
}
// This function handles the error prints when a node or entry is
// not readable/writable on the connected camera
void PrintRetrieveNodeFailure(char node[], char name[])
{
printf("Unable to get %s (%s %s retrieval failed).\n\n", node, name, node);
}
// This is the first of three callback functions. Notice the function signature.
// This callback function will be registered to the height node.
{
spinError err = SPINNAKER_ERR_SUCCESS;
int64_t height = 0;
if (IsReadable(hNode, "Height"))
{
err = spinIntegerGetValue(hNode, &height);
{
printf("Unable to retrieve height. Non-fatal error %d...\n\n", err);
return;
}
}
else
{
PrintRetrieveNodeFailure("node", "Height");
return;
}
printf("Height callback message:\n");
printf("\tLook! Height changed to %d...\n\n", (int)height);
}
// This is the second of three callback functions. Notice that despite different
// names, everything else is exactly the same as the first. This callback
// function will be registered to the gain node.
{
spinError err = SPINNAKER_ERR_SUCCESS;
double gain = 0.0;
if (IsReadable(hNode, "Gain"))
{
err = spinFloatGetValue(hNode, &gain);
{
printf("Unable to retrieve gain. Non-fatal error %d...\n\n", err);
return;
}
}
else
{
PrintRetrieveNodeFailure("node", "Gain");
return;
}
printf("Gain callback message:\n");
printf("\tLook now! Gain changed to %f...\n\n", gain);
}
// This is the third of three callback functions. Notice the function signature.
// This callback function will be registered to the event feature nodes.
{
spinError err = SPINNAKER_ERR_SUCCESS;
spinNodeType nodeType = UnknownNode;
char nodeName[MAX_BUFF_LEN];
size_t lenNodeName = MAX_BUFF_LEN;
// Retrieve node name
err = spinNodeGetName(hNode, nodeName, &lenNodeName);
{
strcpy(nodeName, "Unknown name");
}
if (IsReadable(hNode, nodeName))
{
err = spinNodeGetType(hNode, &nodeType);
{
printf("Unable to retrieve node type. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
return;
}
}
else
{
PrintRetrieveNodeFailure("node", nodeName);
return;
}
if (nodeType == IntegerNode)
{
int64_t featureValue = 0;
err = spinIntegerGetValue(hNode, &featureValue);
printf("\t%s was changed to %lld\n", nodeName, featureValue);
}
else if (nodeType == BooleanNode)
{
bool8_t featureValue = False;
err = spinBooleanGetValue(hNode, &featureValue);
if (featureValue)
{
printf("\t%s was changed to true\n", nodeName);
}
else
{
printf("\t%s was changed to false\n", nodeName);
}
}
else if (nodeType == FloatNode)
{
double featureValue = 0.0;
err = spinFloatGetValue(hNode, &featureValue);
printf("\t%s was changed to %f\n", nodeName, featureValue);
}
else if (nodeType == StringNode)
{
char featureValue[MAX_BUFF_LEN];
size_t lenFeatureValue = MAX_BUFF_LEN;
err = spinStringGetValue(hNode, featureValue, &lenFeatureValue);
printf("\t%s was changed to %s\n", nodeName, featureValue);
}
else
{
printf("\t%s with node type %d was updated\n", nodeName, nodeType);
}
}
// This function prepares the example by disabling automatic gain, creating two
// callbacks, and registering them to their respective nodes.
spinNodeMapHandle hNodeMap, callbackArray* handleArray)
{
spinError err = SPINNAKER_ERR_SUCCESS;
printf("\n\n*** CONFIGURING CALLBACKS ***\n\n");
//
// Turn off automatic gain
//
// *** NOTES ***
// Automatic gain prevents the manual configuration of gain and needs to
// be turned off for this example.
//
// *** LATER ***
// Automatic gain is turned off at the end of the example in order to
// restore the camera to its default state.
//
spinNodeHandle hGainAuto = NULL;
spinNodeHandle hGainAutoOff = NULL;
int64_t gainAutoOff = 0;
err = spinNodeMapGetNode(hNodeMap, "GainAuto", &hGainAuto);
{
printf("Unable to disable automatic gain (node retrieval). Aborting with error %d...\n\n", err);
return err;
}
if (IsReadable(hGainAuto, "GainAuto"))
{
err = spinEnumerationGetEntryByName(hGainAuto, "Off", &hGainAutoOff);
{
printf("Unable to disable automatic gain (enum entry retrieval). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "GainAuto");
}
if (IsReadable(hGainAutoOff, "GainAutoOff"))
{
err = spinEnumerationEntryGetIntValue(hGainAutoOff, &gainAutoOff);
{
printf(
"Unable to disable automatic gain (enum entry int value retrieval). Aborting with error %d...\n\n",
err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "GainAuto 'Off'");
}
if (IsWritable(hGainAuto, "GainAuto"))
{
err = spinEnumerationSetIntValue(hGainAuto, gainAutoOff);
{
printf("Unable to disable automatic gain (enum entry setting). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "GainAuto");
}
printf("Automatic gain disabled...\n");
//
// Register callback to height node
//
// *** NOTES ***
// Callbacks need to be registered to nodes, which should be writable
// if the callback is to ever be triggered. Notice that callback
// registration a handle - this handle is important at the end of the
// example for deregistration.
//
// *** LATER ***
// Each callback needs to be unregistered individually before releasing
// the system or an exception will be thrown.
//
spinNodeHandle hHeight = NULL;
err = spinNodeMapGetNode(hNodeMap, "Height", &hHeight);
{
printf("Unable to register height callback (node retrieval). Aborting with error %d...\n\n", err);
return err;
}
spinNodeCallbackHandle callbackHeight = NULL;
err = spinNodeRegisterCallback(hHeight, onHeightNodeUpdate, &callbackHeight);
{
printf("Unable to register height callback (callback registration). Aborting with error %d...\n\n", err);
return err;
}
push(handleArray, callbackHeight, hHeight);
printf("Height callback registered...\n");
//
// Register callback to gain node
//
// *** NOTES ***
// Depending on the specific goal of the function, it can be important
// to notice the node type that a callback is registered to. Notice in
// the callback functions above that the callback registered to height
// casts its node as an integer whereas the callback registered to gain
// casts as a float.
//
// *** LATER ***
// Each callback needs to be unregistered individually before releasing
// the system or an exception will be thrown.
//
spinNodeHandle hGain = NULL;
err = spinNodeMapGetNode(hNodeMap, "Gain", &hGain);
{
printf("Unable to register gain callback (callback registration). Aborting with error %d...\n\n", err);
return err;
}
spinNodeCallbackHandle callbackGain = NULL;
err = spinNodeRegisterCallback(hGain, onGainNodeUpdate, &callbackGain);
{
printf("Unable to register gain callback (callback registration). Aborting with error %d...\n\n", err);
return err;
}
push(handleArray, callbackGain, hGain);
printf("Gain callback registered...\n\n");
return err;
}
spinError GetNumEvents(spinNodeMapHandle hNodeMap, size_t* numEvents)
{
spinError err = SPINNAKER_ERR_SUCCESS;
spinNodeHandle hEventSelector = NULL;
size_t numEntries = 0;
// Retrieve selector node
err = spinNodeMapGetNode(hNodeMap, "EventSelector", &hEventSelector);
{
printf(
"Unable to retrieve event selector entries. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Retrieve number of entries, check if readable
if (IsReadable(hEventSelector, "EventSelector"))
{
err = spinEnumerationGetNumEntries(hEventSelector, &numEntries);
{
printf(
"Unable to retrieve number of entries. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
}
else
{
printf("Unable to read number of entries. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
*numEvents = numEntries;
return err;
}
// This function prepares the example by disabling automatic gain, creating two
// callbacks, and registering them to their respective nodes.
spinNodeMapHandle hNodeMap, callbackArray* handleArray)
{
spinError err = SPINNAKER_ERR_SUCCESS;
spinNodeHandle hEventSelector = NULL;
size_t numEntries = 0;
printf("\n\n*** CONFIGURING EVENT CALLBACKS ***\n\n");
// Retrieve selector node
err = spinNodeMapGetNode(hNodeMap, "EventSelector", &hEventSelector);
{
printf("Unable to retrieve event selector entries. Skipping...\n\n");
}
// Retrieve number of entries, check if readable
if (IsReadable(hEventSelector, "EventSelector"))
{
err = spinEnumerationGetNumEntries(hEventSelector, &numEntries);
{
printf("Unable to retrieve event selector entries. Skipping...\n\n");
}
}
else
{
printf("Unable to retrieve event selector entries. Skipping...\n\n");
}
for (unsigned int i = 0; i < numEntries; i++)
{
// Retrieve entry node
spinNodeHandle hEntry = NULL;
err = spinEnumerationGetEntryByIndex(hEventSelector, i, &hEntry);
// Go to next node if problem occurs
{
continue;
}
// Retrieve entry name
char entryName[MAX_BUFF_LEN];
size_t lenEntryName = MAX_BUFF_LEN;
if (IsReadable(hEntry, "EventEntry"))
{
err = spinNodeGetDisplayName(hEntry, entryName, &lenEntryName);
{
printf("\t%s: unable to retrieve event entry by display name (error %d)...\n", entryName, err);
}
}
else
{
continue;
}
// Retrieve enum entry integer value
int64_t value = 0;
err = spinEnumerationEntryGetIntValue(hEntry, &value);
{
printf("\t%s: unable to get event entry value (error %d)...\n", entryName, err);
continue;
}
// Set integer value
if (IsWritable(hEventSelector, "EventSelector"))
{
err = spinEnumerationSetIntValue(hEventSelector, value);
{
printf("\t%s: unable to set event entry value (error %d)...\n", entryName, err);
continue;
}
}
else
{
printf("\t%s: unable to set event entry value (error %d)...\n", entryName, err);
continue;
}
// Retrieve event notification node (an enumeration node)
spinNodeHandle hEventNotification = NULL;
err = spinNodeMapGetNode(hNodeMap, "EventNotification", &hEventNotification);
{
printf("\t%s: unable to get entry from nodemap (error %d)...\n", entryName, err);
continue;
}
spinNodeHandle hEventNotificationOn = NULL;
int64_t eventNotificationOn = 0;
if (IsReadable(hEventNotification, "EventNotification"))
{
err = spinEnumerationGetEntryByName(hEventNotification, "On", &hEventNotificationOn);
{
printf(
"Unable to set event notification to On (entry 'On' retrieval). Aborting with error "
"%d...\n\n",
err);
continue;
}
}
else
{
printf("Unable to read event notification mode. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
if (IsReadable(hEventNotificationOn, "EventNotificationOn"))
{
err = spinEnumerationEntryGetIntValue(hEventNotificationOn, &eventNotificationOn);
{
printf(
"Unable to set event notification to On (entry int value retrieval). Aborting with error "
"%d...\n\n",
err);
continue;
}
}
else
{
printf(
"Unable to read event notification On. Aborting with error: %s [%d]\n\n",
err);
continue;
}
// Set event notification to On
if (IsWritable(hEventNotification, "EventNotification"))
{
err = spinEnumerationSetIntValue(hEventNotification, eventNotificationOn);
{
printf(
"Unable to set event notification to On (entry int value setting). Aborting with error "
"%d...\n\n",
err);
continue;
}
printf("\t%s: enabled...\n", entryName);
}
else
{
printf("Unable to write to event notification. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
// Register Event Data callbacks
char entrySymbolic[MAX_BUFF_LEN];
char eventDataCategoryName[MAX_BUFF_LEN];
size_t entrySymbolicLength = MAX_BUFF_LEN;
err = spinEnumerationEntryGetSymbolic(hEntry, entrySymbolic, &entrySymbolicLength);
{
return err;
}
sprintf(eventDataCategoryName, "Event%sData", entrySymbolic);
spinNodeHandle hDataCategory = NULL;
size_t numFeatures;
err = spinNodeMapGetNode(hNodeMap, eventDataCategoryName, &hDataCategory);
{
printf("\t%s: unable to get entry from nodemap (error %d)...\n", eventDataCategoryName, err);
continue;
}
if (!IsReadable(hDataCategory, eventDataCategoryName))
{
printf("Unable to retrieve %s. Aborting...\n\n", eventDataCategoryName);
continue;
}
err = spinCategoryGetNumFeatures(hDataCategory, &numFeatures);
{
printf("Unable to retrieve number of nodes (error %d)...\n\n", err);
return err;
}
for (unsigned int j = 0; j < numFeatures; j++)
{
spinNodeHandle hFeatureNode = NULL;
spinNodeType featureType = UnknownNode;
char featureName[MAX_BUFF_LEN];
size_t lenFeatureName = MAX_BUFF_LEN;
// Retrieve node
if (IsReadable(hDataCategory, eventDataCategoryName))
{
err = spinCategoryGetFeatureByIndex(hDataCategory, j, &hFeatureNode);
{
printf("Unable to retrieve node (error %d)...\n\n", err);
continue;
}
}
else
{
printf("Unable to retrieve node (error %d)...\n\n", err);
continue;
}
// Retrieve node name
err = spinNodeGetName(hFeatureNode, featureName, &lenFeatureName);
{
strcpy(featureName, "Unknown name");
}
//
// Register callback to event data node
//
// *** LATER ***
// Each callback needs to be unregistered individually before releasing
// the system or an exception will be thrown.
//
spinNodeCallbackHandle tmpNodeCallbackHandle;
err = spinNodeRegisterCallback(hFeatureNode, onEventNodeUpdate, &tmpNodeCallbackHandle);
{
printf(
"Unable to register %s callback (callback registration). Aborting with error %d...\n\n",
featureName,
err);
continue;
}
push(handleArray, tmpNodeCallbackHandle, hFeatureNode);
printf("\t\t%s callback registered...\n", featureName);
}
}
return err;
}
// This function demonstrates the triggering of the nodemap callbacks. First it
// changes height, which executes the callback registered to the height node, and
// then it changes gain, which executes the callback registered to the gain node.
{
spinError err = SPINNAKER_ERR_SUCCESS;
printf("\n*** CHANGING HEIGHT & GAIN ***\n\n");
//
// Change height to trigger height callback
//
// *** NOTES ***
// Notice that changing the height only triggers the callback function
// registered to the height node.
//
spinNodeHandle hHeight = NULL;
int64_t heightToSet = 0;
int64_t heightMax = 0;
err = spinNodeMapGetNode(hNodeMap, "Height", &hHeight);
{
printf("Unable to change height (node retrieval). Aborting with error %d...\n\n", err);
return err;
}
if (IsReadable(hHeight, "Height"))
{
err = spinIntegerGetMax(hHeight, &heightMax);
{
printf("Unable to change height (max retrieval). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "Height");
}
heightToSet = heightMax;
printf("Regular function message:\n");
printf("\tHeight about to be set to %d...\n\n", (int)heightToSet);
if (IsWritable(hHeight, "Height"))
{
err = spinIntegerSetValue(hHeight, heightToSet);
{
printf("Unable to change height (value setting). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "Height");
}
//
// Change gain to trigger gain callback
//
// *** NOTES ***
// The same is true of changing the gain node; changing a node will
// only ever trigger the callback function (or functions) currently
// registered to it.
//
spinNodeHandle hGain = NULL;
double gainToSet = 0.0;
double gainMax = 0.0;
err = spinNodeMapGetNode(hNodeMap, "Gain", &hGain);
{
printf("Unable to register gain callback (callback registration). Aborting with error %d...\n\n", err);
return err;
}
if (IsReadable(hGain, "Gain"))
{
err = spinFloatGetMax(hGain, &gainMax);
{
printf("Unable to change gain (max retrieval). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "Gain");
}
gainToSet = gainMax / 2.0;
printf("Regular function message:\n");
printf("\tGain about to be set to %f...\n\n", gainToSet);
if (IsWritable(hGain, "Gain"))
{
err = spinFloatSetValue(hGain, gainToSet);
{
printf("Unable to change gain (value setting). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "Gain");
}
return err;
}
// This function cleans up the example by deregistering the callbacks
spinError ResetCallbacks(callbackArray* handleArray)
{
spinError err = SPINNAKER_ERR_SUCCESS;
spinNodeCallbackHandle hCallback = NULL;
spinNodeHandle hNode = NULL;
char nodeName[MAX_BUFF_LEN];
size_t lenNodeName = MAX_BUFF_LEN;
while (handleArray->size > 0)
{
pop(handleArray, &hCallback, &hNode);
//
// Deregister node callback
//
// *** NOTES ***
// It is important to deregister each callback function from each node
// that it is registered to.
//
err = spinNodeDeregisterCallback(hNode, hCallback);
{
printf(
"Unable to deregister callback (callback deregistration). Aborting with error %d...\n\n", err);
return err;
}
// Retrieve node name
lenNodeName = MAX_BUFF_LEN;
err = spinNodeGetName(hNode, nodeName, &lenNodeName);
{
strcpy(nodeName, "Unknown name");
}
printf("\t\t%s callback deregistered...\n", nodeName);
}
return err;
}
// This function cleans up the example by resetting event notifications
spinError ResetEvents(
{
spinError err = SPINNAKER_ERR_SUCCESS;
spinNodeHandle hEventSelector = NULL;
size_t numEntries = 0;
printf("\n\n*** RESETTING EVENT CALLBACKS ***\n\n");
// Retrieve selector node
err = spinNodeMapGetNode(hNodeMap, "EventSelector", &hEventSelector);
{
printf("Unable to retrieve event selector entries. Skipping...\n\n");
}
// Retrieve number of entries, check if readable
if (IsReadable(hEventSelector, "EventSelector"))
{
err = spinEnumerationGetNumEntries(hEventSelector, &numEntries);
{
printf("Unable to retrieve number of entries. Skipping...\n\n");
}
}
else
{
printf("Unable to read number of entries. Skipping...\n\n");
}
for (unsigned int i = 0; i < numEntries; i++)
{
// Retrieve entry node
spinNodeHandle hEntry = NULL;
err = spinEnumerationGetEntryByIndex(hEventSelector, i, &hEntry);
// Go to next node if problem occurs
{
continue;
}
// Retrieve entry name
char entryName[MAX_BUFF_LEN];
size_t lenEntryName = MAX_BUFF_LEN;
if (IsReadable(hEntry, "EventEntry"))
{
err = spinNodeGetDisplayName(hEntry, entryName, &lenEntryName);
{
printf("\t%s: unable to retrieve event entry by display name (error %d)...\n", entryName, err);
}
}
else
{
continue;
}
// Retrieve enum entry integer value
int64_t value = 0;
err = spinEnumerationEntryGetIntValue(hEntry, &value);
{
printf("\t%s: unable to get event entry value (error %d)...\n", entryName, err);
continue;
}
// Set integer value
if (IsWritable(hEventSelector, "EventSelector"))
{
err = spinEnumerationSetIntValue(hEventSelector, value);
{
printf("\t%s: unable to set event entry value (error %d)...\n", entryName, err);
continue;
}
}
else
{
printf("\t%s: unable to set event entry value (error %d)...\n", entryName, err);
continue;
}
// Retrieve event notification node (an enumeration node)
spinNodeHandle hEventNotification = NULL;
err = spinNodeMapGetNode(hNodeMap, "EventNotification", &hEventNotification);
{
printf("\t%s: unable to get entry from nodemap (error %d)...\n", entryName, err);
continue;
}
spinNodeHandle hEventNotificationOff = NULL;
int64_t eventNotificationOn = 0;
if (IsReadable(hEventNotification, "EventNotification"))
{
err = spinEnumerationGetEntryByName(hEventNotification, "Off", &hEventNotificationOff);
{
printf(
"Unable to set event notification to Off (entry 'Off' retrieval). Aborting with error "
"%d...\n\n",
err);
continue;
}
}
else
{
printf(
"Unable to read event notification mode. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
if (IsReadable(hEventNotificationOff, "EventNotificationOff"))
{
err = spinEnumerationEntryGetIntValue(hEventNotificationOff, &eventNotificationOn);
{
printf(
"Unable to set event notification to Off (entry int value retrieval). Aborting with error "
"%d...\n\n",
err);
continue;
}
}
else
{
printf(
"Unable to read event notification Off. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
// Set event notification to Off
if (IsWritable(hEventNotification, "EventNotification"))
{
err = spinEnumerationSetIntValue(hEventNotification, eventNotificationOn);
{
printf(
"Unable to set event notification to Off (entry int value setting). Aborting with error "
"%d...\n\n",
err);
continue;
}
printf("\t%s: disabled...\n", entryName);
}
else
{
printf(
"Unable to write to event notification. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
}
return err;
}
// This function cleans up the example by turning auto gain back on
spinError ResetAutoGain(spinNodeMapHandle hNodeMap)
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Turn automatic gain back on
//
// *** NOTES ***
// Automatic gain is turned on in order to return the camera to its
// default state.
//
spinNodeHandle hGainAuto = NULL;
spinNodeHandle hGainAutoContinuous = NULL;
int64_t gainAutoContinuous = 0;
err = spinNodeMapGetNode(hNodeMap, "GainAuto", &hGainAuto);
{
printf("Unable to disable automatic gain (node retrieval). Aborting with error %d...\n\n", err);
return err;
}
if (IsReadable(hGainAuto, "GainAuto"))
{
err = spinEnumerationGetEntryByName(hGainAuto, "Continuous", &hGainAutoContinuous);
{
printf("Unable to enable automatic gain (enum entry retrieval). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "GainAuto");
}
if (IsReadable(hGainAutoContinuous, "GainAutoContinuous"))
{
err = spinEnumerationEntryGetIntValue(hGainAutoContinuous, &gainAutoContinuous);
{
printf(
"Unable to enable automatic gain (enum entry int value retrieval). Aborting with error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "GainAuto 'Continuous'");
}
if (IsWritable(hGainAuto, "GainAuto"))
{
err = spinEnumerationSetIntValue(hGainAuto, gainAutoContinuous);
{
printf("Unable to enable automatic gain (enum entry setting). Aborting with error %d...\n\n", err);
return err;
}
printf("Automatic gain turned back on...\n\n");
}
else
{
PrintRetrieveNodeFailure("node", "GainAuto");
}
return err;
}
// This function acquires 10 images from a device to trigger acquisition related
// nodemap events; please see Acquisition example for more in-depth comments on
// acquiring images.
spinError AcquireImages(spinCamera hCam, spinNodeMapHandle hNodeMap, spinNodeMapHandle hNodeMapTLDevice)
{
spinError err = SPINNAKER_ERR_SUCCESS;
printf("\n*** IMAGE ACQUISITION ***\n\n");
// Set acquisition mode to continuous
spinNodeHandle hAcquisitionMode = NULL;
spinNodeHandle hAcquisitionModeContinuous = NULL;
int64_t acquisitionModeContinuous = 0;
// Retrieve enumeration node from nodemap
err = spinNodeMapGetNode(hNodeMap, "AcquisitionMode", &hAcquisitionMode);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Retrieve entry node from enumeration node
if (IsReadable(hAcquisitionMode, "AcquisitionMode"))
{
err = spinEnumerationGetEntryByName(hAcquisitionMode, "Continuous", &hAcquisitionModeContinuous);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "AcquisitionMode");
}
// Retrieve integer from entry node
if (IsReadable(hAcquisitionModeContinuous, "AcquisitionModeContinuous"))
{
err = spinEnumerationEntryGetIntValue(hAcquisitionModeContinuous, &acquisitionModeContinuous);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "AcquisitionMode 'Continuous'");
}
// Set integer as new value of enumeration node
if (IsWritable(hAcquisitionMode, "AcquisitionMode"))
{
err = spinEnumerationSetIntValue(hAcquisitionMode, acquisitionModeContinuous);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "AcquisitionMode");
}
printf("Acquisition mode set to continuous...\n");
// Begin acquiring images
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Acquiring images...\n");
// Retrieve device serial number for filename
spinNodeHandle hDeviceSerialNumber = NULL;
char deviceSerialNumber[MAX_BUFF_LEN];
size_t lenDeviceSerialNumber = MAX_BUFF_LEN;
err = spinNodeMapGetNode(hNodeMapTLDevice, "DeviceSerialNumber", &hDeviceSerialNumber);
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
else
{
if (IsReadable(hDeviceSerialNumber, "DeviceSerialNumber"))
{
err = spinStringGetValue(hDeviceSerialNumber, deviceSerialNumber, &lenDeviceSerialNumber);
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
}
else
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
PrintRetrieveNodeFailure("node", "DeviceSerialNumber");
}
printf("Device serial number retrieved as %s...\n", deviceSerialNumber);
}
printf("\n");
// Retrieve, convert, and save images
const unsigned int k_numImages = 10;
unsigned int imageCnt = 0;
//
// Create Image Processor context for post processing images
//
spinImageProcessor hImageProcessor = NULL;
err = spinImageProcessorCreate(&hImageProcessor);
{
printf("Unable to create image processor. Non-fatal error %d...\n\n", err);
}
//
// Set default image processor color processing method
//
// *** NOTES ***
// By default, if no specific color processing algorithm is set, the image
// processor will default to NEAREST_NEIGHBOR method.
//
{
printf("Unable to set image processor color processing method. Non-fatal error %d...\n\n", err);
}
for (imageCnt = 0; imageCnt < k_numImages; imageCnt++)
{
// Retrieve next received image
spinImage hResultImage = NULL;
err = spinCameraGetNextImageEx(hCam, 1000, &hResultImage);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
continue;
}
// Ensure image completion
bool8_t isIncomplete = False;
bool8_t hasFailed = False;
err = spinImageIsIncomplete(hResultImage, &isIncomplete);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
hasFailed = True;
}
// Check image for completion
if (isIncomplete)
{
spinImageStatus imageStatus = SPINNAKER_IMAGE_STATUS_NO_ERROR;
err = spinImageGetStatus(hResultImage, &imageStatus);
{
printf("Unable to retrieve image status. Non-fatal error %d...\n\n", imageStatus);
}
else
{
printf("Image incomplete with image status %d...\n", imageStatus);
}
hasFailed = True;
}
// Release incomplete or failed image
if (hasFailed)
{
err = spinImageRelease(hResultImage);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
continue;
}
//
// Print image information; height and width recorded in pixels
//
// *** NOTES ***
// Images have quite a bit of available metadata including things such
// as CRC, image status, and offset values, to name a few.
//
size_t width = 0;
size_t height = 0;
printf("Grabbed image %d, ", imageCnt);
// Retrieve image width
err = spinImageGetWidth(hResultImage, &width);
{
printf("width = unknown, ");
}
else
{
printf("width = %u, ", (unsigned int)width);
}
// Retrieve image height
err = spinImageGetHeight(hResultImage, &height);
{
printf("height = unknown\n");
}
else
{
printf("height = %u\n", (unsigned int)height);
}
//
// Convert image to mono 8
//
// *** NOTES ***
// Images not gotten from a camera directly must be created and
// destroyed. This includes any image copies, conversions, or
// otherwise. Basically, if the image was gotten, it should be
// released, if it was created, it needs to be destroyed.
//
// Images can be converted between pixel formats by using the
// appropriate enumeration value. Unlike the original image, the
// converted one does not need to be released as it does not affect the
// camera buffer.
//
// Optionally, the color processing algorithm can also be set using
// the alternate spinImageConvertEx() function.
//
// *** LATER ***
// The converted image was created, so it must be destroyed to avoid
// memory leaks.
//
spinImage hConvertedImage = NULL;
err = spinImageCreateEmpty(&hConvertedImage);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
hasFailed = True;
}
err = spinImageProcessorConvert(hImageProcessor, hResultImage, hConvertedImage, PixelFormat_Mono8);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
hasFailed = True;
}
//
// Destroy converted image
//
// *** NOTES ***
// Images that are created must be destroyed in order to avoid memory
// leaks.
//
err = spinImageDestroy(hConvertedImage);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
//
// Release image from camera
//
// *** NOTES ***
// Images retrieved directly from the camera (i.e. non-converted
// images) need to be released in order to keep from filling the
// buffer.
//
err = spinImageRelease(hResultImage);
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
}
//
// Destroy Image Processor context
//
// *** NOTES ***
// Image processor context needs to be destroyed after all image processing
// are complete to avoid memory leaks.
//
err = spinImageProcessorDestroy(hImageProcessor);
{
printf("Unable to destroy image processor. Non-fatal error %d...\n\n", err);
}
//
// End acquisition
//
// *** NOTES ***
// Ending acquisition appropriately helps ensure that devices clean up
// properly and do not need to be power-cycled to maintain integrity.
//
{
printf("Error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
return err;
}
// This function prints the device information of the camera from the transport
// layer; please see NodeMapInfo_C example for more in-depth comments on
// printing device information from the nodemap.
{
spinError err = SPINNAKER_ERR_SUCCESS;
unsigned int i = 0;
printf("\n*** DEVICE INFORMATION ***\n\n");
// Retrieve device information category node
spinNodeHandle hDeviceInformation = NULL;
err = spinNodeMapGetNode(hNodeMap, "DeviceInformation", &hDeviceInformation);
{
printf("Unable to retrieve node. Non-fatal error %d...\n\n", err);
return err;
}
// Retrieve number of nodes within device information node
size_t numFeatures = 0;
if (IsReadable(hDeviceInformation, "DeviceInformation"))
{
err = spinCategoryGetNumFeatures(hDeviceInformation, &numFeatures);
{
printf("Unable to retrieve number of nodes. Non-fatal error %d...\n\n", err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("node", "DeviceInformation");
}
// Iterate through nodes and print information
for (i = 0; i < numFeatures; i++)
{
spinNodeHandle hFeatureNode = NULL;
err = spinCategoryGetFeatureByIndex(hDeviceInformation, i, &hFeatureNode);
{
printf("Unable to retrieve node. Non-fatal error %d...\n\n", err);
continue;
}
spinNodeType featureType = UnknownNode;
// get feature node name
char featureName[MAX_BUFF_LEN];
size_t lenFeatureName = MAX_BUFF_LEN;
err = spinNodeGetName(hFeatureNode, featureName, &lenFeatureName);
{
strcpy(featureName, "Unknown name");
}
if (IsReadable(hFeatureNode, featureName))
{
err = spinNodeGetType(hFeatureNode, &featureType);
{
printf("Unable to retrieve node type. Non-fatal error %d...\n\n", err);
continue;
}
}
else
{
printf("%s: Node not readable\n", featureName);
continue;
}
char featureValue[MAX_BUFF_LEN];
size_t lenFeatureValue = MAX_BUFF_LEN;
err = spinNodeToString(hFeatureNode, featureValue, &lenFeatureValue);
{
strcpy(featureValue, "Unknown value");
}
printf("%s: %s\n", featureName, featureValue);
}
printf("\n");
return err;
}
// This function acts as the body of the example; please see NodeMapInfo_C
// example for more in-depth comments on setting up cameras.
spinError RunSingleCamera(spinCamera hCam)
{
spinError err = SPINNAKER_ERR_SUCCESS;
// Retrieve TL device nodemap and print device information
spinNodeMapHandle hNodeMapTLDevice = NULL;
err = spinCameraGetTLDeviceNodeMap(hCam, &hNodeMapTLDevice);
{
printf("Unable to retrieve TL device nodemap (non-fatal error %d)...\n\n", err);
}
else
{
err = PrintDeviceInfo(hNodeMapTLDevice);
}
// Retrieve TL stream nodemap
spinNodeMapHandle hNodeMapTLStream = NULL;
err = spinCameraGetTLStreamNodeMap(hCam, &hNodeMapTLStream);
{
printf("Unable to retrieve TL stream nodemap (non-fatal error %d)...\n\n", err);
}
// Initialize camera
err = spinCameraInit(hCam);
{
printf("Unable to initialize camera. Aborting with error %d...\n\n", err);
return err;
}
// Retrieve GenICam nodemap
spinNodeMapHandle hNodeMap = NULL;
err = spinCameraGetNodeMap(hCam, &hNodeMap);
{
printf("Unable to retrieve GenICam nodemap. Aborting with error %d...\n\n", err);
return err;
}
// Configure callbacks
callbackArray callbackHandleArray;
initArray(&callbackHandleArray, 1);
err = ConfigureCallbacks(hNodeMap, &callbackHandleArray);
{
return err;
}
// Configure event callbacks on remote device
err = ConfigureEventCallbacks(hNodeMap, &callbackHandleArray);
{
return err;
}
// Configure event callbacks on local device
err = ConfigureEventCallbacks(hNodeMapTLDevice, &callbackHandleArray);
{
return err;
}
// Configure event callbacks on local stream
err = ConfigureEventCallbacks(hNodeMapTLStream, &callbackHandleArray);
{
return err;
}
// Change height and gain to trigger callbacks
err = ChangeHeightAndGain(hNodeMap);
{
return err;
}
// Acquire images
err = AcquireImages(hCam, hNodeMap, hNodeMapTLDevice);
{
return err;
}
// Reset callbacks
err = ResetCallbacks(&callbackHandleArray);
{
return err;
}
freeArray(&callbackHandleArray);
// Reset auto gain
err = ResetAutoGain(hNodeMap);
{
return err;
}
// Reset events on remote device
err = ResetEvents(hNodeMap);
{
return err;
}
// Reset events on local device
err = ResetEvents(hNodeMapTLDevice);
{
return err;
}
// Reset events on local stream
err = ResetEvents(hNodeMapTLStream);
{
return err;
}
// Deinitialize camera
err = spinCameraDeInit(hCam);
{
printf("Unable to deinitialize camera. Non-fatal error %d...\n\n", err);
return err;
}
return err;
}
// Example entry point; please see Enumeration_C example for more in-depth
// comments on preparing and cleaning up the system.
int main(/*int argc, char** argv*/)
{
spinError errReturn = SPINNAKER_ERR_SUCCESS;
spinError err = SPINNAKER_ERR_SUCCESS;
unsigned int i = 0;
// Print application build information
printf("Application build date: %s %s \n\n", __DATE__, __TIME__);
// Retrieve singleton reference to system object
spinSystem hSystem = NULL;
err = spinSystemGetInstance(&hSystem);
{
printf("Unable to retrieve system instance. Aborting with error %d...\n\n", err);
return err;
}
// Print out current library version
spinLibraryVersion hLibraryVersion;
spinSystemGetLibraryVersion(hSystem, &hLibraryVersion);
printf(
"Spinnaker library version: %d.%d.%d.%d\n\n",
hLibraryVersion.major,
hLibraryVersion.minor,
hLibraryVersion.type,
hLibraryVersion.build);
// Retrieve list of cameras from the system
spinCameraList hCameraList = NULL;
err = spinCameraListCreateEmpty(&hCameraList);
{
printf("Unable to create camera list. Aborting with error %d...\n\n", err);
return err;
}
err = spinSystemGetCameras(hSystem, hCameraList);
{
printf("Unable to retrieve camera list. Aborting with error %d...\n\n", err);
return err;
}
// Retrieve number of cameras
size_t numCameras = 0;
err = spinCameraListGetSize(hCameraList, &numCameras);
{
printf("Unable to retrieve number of cameras. Aborting with error %d...\n\n", err);
return err;
}
printf("Number of cameras detected: %u\n\n", (unsigned int)numCameras);
// Finish if there are no cameras
if (numCameras == 0)
{
// Clear and destroy camera list before releasing system
err = spinCameraListClear(hCameraList);
{
printf("Unable to clear camera list. Aborting with error %d...\n\n", err);
return err;
}
err = spinCameraListDestroy(hCameraList);
{
printf("Unable to destroy camera list. Aborting with error %d...\n\n", err);
return err;
}
// Release system
err = spinSystemReleaseInstance(hSystem);
{
printf("Unable to release system instance. Aborting with error %d...\n\n", err);
return err;
}
printf("Not enough cameras!\n");
printf("Done! Press Enter to exit...\n");
getchar();
return -1;
}
// Run example on each camera
for (i = 0; i < numCameras; i++)
{
printf("\nRunning example for camera %d...\n", i);
// Select camera
spinCamera hCamera = NULL;
err = spinCameraListGet(hCameraList, i, &hCamera);
{
printf("Unable to retrieve camera from list. Aborting with error %d...\n\n", err);
errReturn = err;
}
else
{
// Run example
err = RunSingleCamera(hCamera);
{
errReturn = err;
}
}
// Release camera
err = spinCameraRelease(hCamera);
{
errReturn = err;
}
printf("Camera %d example complete...\n\n", i);
}
// Clear and destroy camera list before releasing system
err = spinCameraListClear(hCameraList);
{
printf("Unable to clear camera list. Aborting with error %d...\n\n", err);
return err;
}
err = spinCameraListDestroy(hCameraList);
{
printf("Unable to destroy camera list. Aborting with error %d...\n\n", err);
return err;
}
// Release system
err = spinSystemReleaseInstance(hSystem);
{
printf("Unable to release system instance. Aborting with error %d...\n\n", err);
return err;
}
printf("\nDone! Press Enter to exit...\n");
getchar();
return errReturn;
}
spinCameraRelease
SPINNAKERC_API spinCameraRelease(spinCamera hCamera)
Releases a camera.
callbackArray::size
size_t size
Definition: NodeMapCallback_C.c:53
push
void push(callbackArray *arr, spinNodeCallbackHandle callbackHandle, spinNodeHandle nodeHandle)
Definition: NodeMapCallback_C.c:67
PrintRetrieveNodeFailure
void PrintRetrieveNodeFailure(char node[], char name[])
Definition: NodeMapCallback_C.c:152
AcquireImages
spinError AcquireImages(spinCamera hCam, spinNodeMapHandle hNodeMap, spinNodeMapHandle hNodeMapTLDevice)
Definition: NodeMapCallback_C.c:1140
spinCameraGetNodeMap
SPINNAKERC_API spinCameraGetNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the GenICam nodemap from a camera.
spinImageGetWidth
SPINNAKERC_API spinImageGetWidth(spinImage hImage, size_t *pWidth)
Retrieves the width of an image.
spinBooleanGetValue
SPINNAKERC_API spinBooleanGetValue(spinNodeHandle hNode, bool8_t *pbValue)
Retrieves the value of a boolean node; boolean values are represented by 'True' (which equals '0') an...
onEventNodeUpdate
void onEventNodeUpdate(spinNodeHandle hNode)
Definition: NodeMapCallback_C.c:211
SPINNAKER_COLOR_PROCESSING_ALGORITHM_HQ_LINEAR
@ SPINNAKER_COLOR_PROCESSING_ALGORITHM_HQ_LINEAR
Well-balanced speed and quality.
Definition: SpinnakerDefsC.h:322
spinCameraListClear
SPINNAKERC_API spinCameraListClear(spinCameraList hCameraList)
Clears a camera list.
RunSingleCamera
spinError RunSingleCamera(spinCamera hCam)
Definition: NodeMapCallback_C.c:1552
spinImageIsIncomplete
SPINNAKERC_API spinImageIsIncomplete(spinImage hImage, bool8_t *pbIsIncomplete)
Checks whether an image is incomplete.
spinCameraEndAcquisition
SPINNAKERC_API spinCameraEndAcquisition(spinCamera hCamera)
Has a camera stop acquiring images.
spinFloatSetValue
SPINNAKERC_API spinFloatSetValue(spinNodeHandle hNode, double value)
Sets the value of a float node.
callbackArray::callback
spinNodeCallbackHandle * callback
Definition: NodeMapCallback_C.c:51
BooleanNode
@ BooleanNode
Definition: SpinnakerGenApiDefsC.h:76
spinCameraBeginAcquisition
SPINNAKERC_API spinCameraBeginAcquisition(spinCamera hCamera)
Has a camera start acquiring images.
spinEnumerationGetEntryByIndex
SPINNAKERC_API spinEnumerationGetEntryByIndex(spinNodeHandle hEnumNode, size_t index, spinNodeHandle *phEntry)
Retrieves an entry node from an enum node using an index.
spinImageCreateEmpty
SPINNAKERC_API spinImageCreateEmpty(spinImage *phImage)
Creates an empty image; images created this way must be destroyed.
spinSystemReleaseInstance
SPINNAKERC_API spinSystemReleaseInstance(spinSystem hSystem)
Releases the system; make sure handle is cleaned up properly by setting it to NULL after system is re...
GetLastErrorMessage
char * GetLastErrorMessage()
Definition: NodeMapCallback_C.c:116
ConfigureEventCallbacks
spinError ConfigureEventCallbacks(spinNodeMapHandle hNodeMap, callbackArray *handleArray)
Definition: NodeMapCallback_C.c:476
spinNodeDeregisterCallback
SPINNAKERC_API spinNodeDeregisterCallback(spinNodeHandle hNode, spinNodeCallbackHandle hCb)
Unregisters a callback from a node.
spinImage
void * spinImage
Handle for image functionality.
Definition: SpinnakerDefsC.h:91
spinFloatGetMax
SPINNAKERC_API spinFloatGetMax(spinNodeHandle hNode, double *pValue)
Retrieves the maximum value of a float node; all potential values must be lesser than or equal to the...
spinErrorGetLastMessage
SPINNAKERC_API spinErrorGetLastMessage(char *pBuf, size_t *pBufLen)
Retrieves the error message of the last error.
spinSystemGetCameras
SPINNAKERC_API spinSystemGetCameras(spinSystem hSystem, spinCameraList hCameraList)
Retrieves a list of detected (and enumerable) cameras on the system; camera lists must be created and...
lastErrorMessage
char lastErrorMessage[MAX_BUFF_LEN]
Definition: NodeMapCallback_C.c:112
spinStringGetValue
SPINNAKERC_API spinStringGetValue(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the value of a string node as a c-string.
StringNode
@ StringNode
Definition: SpinnakerGenApiDefsC.h:79
spinNodeMapHandle
void * spinNodeMapHandle
Handle for nodemap functionality.
Definition: SpinnakerGenApiDefsC.h:39
ConfigureCallbacks
spinError ConfigureCallbacks(spinNodeMapHandle hNodeMap, callbackArray *handleArray)
Definition: NodeMapCallback_C.c:288
spinNodeCallbackHandle
void * spinNodeCallbackHandle
Handle for callback functionality.
Definition: SpinnakerGenApiDefsC.h:52
SpinnakerC.h
ChangeHeightAndGain
spinError ChangeHeightAndGain(spinNodeMapHandle hNodeMap)
Definition: NodeMapCallback_C.c:736
spinEnumerationSetIntValue
SPINNAKERC_API spinEnumerationSetIntValue(spinNodeHandle hEnumNode, int64_t value)
Sets a new entry using its integer value retrieved from a call to spinEnumerationEntryGetIntValue(); ...
spinNodeGetType
SPINNAKERC_API spinNodeGetType(spinNodeHandle hNode, spinNodeType *pType)
Retrieves the type of a node (as an enum, spinNodeType)
spinNodeGetName
SPINNAKERC_API spinNodeGetName(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the name of a node (no whitespace)
lenLastErrorMessage
size_t lenLastErrorMessage
Definition: NodeMapCallback_C.c:113
spinIntegerGetValue
SPINNAKERC_API spinIntegerGetValue(spinNodeHandle hNode, int64_t *pValue)
Retrieves the value of an integer node.
getSize
size_t getSize(callbackArray *arr)
Definition: NodeMapCallback_C.c:95
spinCategoryGetNumFeatures
SPINNAKERC_API spinCategoryGetNumFeatures(spinNodeHandle hCategoryNode, size_t *pValue)
Retrieves the number of a features (or child nodes) or a category node.
spinFloatGetValue
SPINNAKERC_API spinFloatGetValue(spinNodeHandle hNode, double *pValue)
Retrieves the value of a float node.
spinEnumerationEntryGetIntValue
SPINNAKERC_API spinEnumerationEntryGetIntValue(spinNodeHandle hNode, int64_t *pValue)
Retrieves the integer value of an entry node; note that enumeration entry int and enum values are dif...
IsReadable
bool8_t IsReadable(spinNodeHandle hNode, char nodeName[])
Definition: NodeMapCallback_C.c:125
spinImageGetHeight
SPINNAKERC_API spinImageGetHeight(spinImage hImage, size_t *pHeight)
Retrieves the height of an image.
spinImageDestroy
SPINNAKERC_API spinImageDestroy(spinImage hImage)
Destroys an image.
spinSystemGetLibraryVersion
SPINNAKERC_API spinSystemGetLibraryVersion(spinSystem hSystem, spinLibraryVersion *hLibraryVersion)
Get current library version of Spinnaker.
SPINNAKER_ERR_ACCESS_DENIED
@ SPINNAKER_ERR_ACCESS_DENIED
Definition: SpinnakerDefsC.h:243
ResetAutoGain
spinError ResetAutoGain(spinNodeMapHandle hNodeMap)
Definition: NodeMapCallback_C.c:1064
initArray
void initArray(callbackArray *arr, size_t initialCapacity)
Definition: NodeMapCallback_C.c:58
spinSystem
void * spinSystem
Handle for system functionality.
Definition: SpinnakerDefsC.h:51
pop
void pop(callbackArray *arr, spinNodeCallbackHandle *callbackHandle, spinNodeHandle *nodeHandle)
Definition: NodeMapCallback_C.c:82
IsWritable
bool8_t IsWritable(spinNodeHandle hNode, char nodeName[])
Definition: NodeMapCallback_C.c:138
spinImageProcessor
void * spinImageProcessor
Handle for image processor functionality.
Definition: SpinnakerDefsC.h:107
spinNodeGetDisplayName
SPINNAKERC_API spinNodeGetDisplayName(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the display name of a node (whitespace possible)
spinCameraInit
SPINNAKERC_API spinCameraInit(spinCamera hCamera)
Initializes a camera, allowing for much more interaction.
False
static const bool8_t False
Definition: SpinnakerDefsC.h:36
spinIntegerSetValue
SPINNAKERC_API spinIntegerSetValue(spinNodeHandle hNode, int64_t value)
Sets the value of an integer node.
spinIntegerGetMax
SPINNAKERC_API spinIntegerGetMax(spinNodeHandle hNode, int64_t *pValue)
Retrieves the maximum value of an integer node; all potential values must be lesser than or equal to ...
spinCameraGetTLStreamNodeMap
SPINNAKERC_API spinCameraGetTLStreamNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the transport layer stream nodemap from a camera.
spinImageProcessorConvert
SPINNAKERC_API spinImageProcessorConvert(spinImageProcessor hImageProcessor, spinImage hSrcImage, spinImage hDestImage, spinPixelFormatEnums destFormat)
Converts the source image buffer to the specified destination pixel format and stores the result in t...
spinImageProcessorSetColorProcessing
SPINNAKERC_API spinImageProcessorSetColorProcessing(spinImageProcessor hImageProcessor, spinColorProcessingAlgorithm colorAlgorithm)
Sets the color processing algorithm used at the time of the spinImageProcessorConvert() call,...
spinCameraListDestroy
SPINNAKERC_API spinCameraListDestroy(spinCameraList hCameraList)
Destroys a camera list.
GetNumEvents
spinError GetNumEvents(spinNodeMapHandle hNodeMap, size_t *numEvents)
Definition: NodeMapCallback_C.c:436
callbackArray::capacity
size_t capacity
Definition: NodeMapCallback_C.c:54
main
int main()
Definition: NodeMapCallback_C.c:1691
UnknownNode
@ UnknownNode
Definition: SpinnakerGenApiDefsC.h:85
spinEnumerationEntryGetSymbolic
SPINNAKERC_API spinEnumerationEntryGetSymbolic(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the symbolic of an entry node as a c-string.
spinNodeIsWritable
SPINNAKERC_API spinNodeIsWritable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is writable.
callbackArray::node
spinNodeHandle * node
Definition: NodeMapCallback_C.c:52
spinCameraList
void * spinCameraList
Handle for interface functionality.
Definition: SpinnakerDefsC.h:75
spinImageProcessorDestroy
SPINNAKERC_API spinImageProcessorDestroy(spinImageProcessor hImageProcessor)
Destroys a image list.
spinSystemGetInstance
SPINNAKERC_API spinSystemGetInstance(spinSystem *phSystem)
Retrieves an instance of the system object; the system is a singleton, so there will only ever be one...
SPINNAKER_IMAGE_STATUS_NO_ERROR
@ SPINNAKER_IMAGE_STATUS_NO_ERROR
Image is returned from GetNextImage() call without any errors.
Definition: SpinnakerDefsC.h:388
onGainNodeUpdate
void onGainNodeUpdate(spinNodeHandle hNode)
Definition: NodeMapCallback_C.c:185
spinCameraGetNextImageEx
SPINNAKERC_API spinCameraGetNextImageEx(spinCamera hCamera, uint64_t grabTimeout, spinImage *phImage)
Retrieves an image from a camera; manually set the timeout in milliseconds.
spinCameraListGet
SPINNAKERC_API spinCameraListGet(spinCameraList hCameraList, size_t index, spinCamera *phCamera)
Retrieves a camera from a camera list using an index.
bool8_t
uint8_t bool8_t
Definition: SpinnakerDefsC.h:35
spinCamera
void * spinCamera
Handle for camera functionality.
Definition: SpinnakerDefsC.h:82
spinNodeHandle
void * spinNodeHandle
Handle for node functionality.
Definition: SpinnakerGenApiDefsC.h:45
spinNodeIsReadable
SPINNAKERC_API spinNodeIsReadable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is readable.
ResetEvents
spinError ResetEvents(spinNodeMapHandle hNodeMap)
Definition: NodeMapCallback_C.c:894
MAX_BUFF_LEN
#define MAX_BUFF_LEN
Definition: NodeMapCallback_C.c:46
FloatNode
@ FloatNode
Definition: SpinnakerGenApiDefsC.h:77
freeArray
void freeArray(callbackArray *arr)
Definition: NodeMapCallback_C.c:101
SpinnakerDefsC.h
spinNodeRegisterCallback
SPINNAKERC_API spinNodeRegisterCallback(spinNodeHandle hNode, spinNodeCallbackFunction pCbFunction, spinNodeCallbackHandle *phCb)
Registers a callback to a node.
spinEnumerationGetEntryByName
SPINNAKERC_API spinEnumerationGetEntryByName(spinNodeHandle hEnumNode, const char *pName, spinNodeHandle *phEntry)
Retrieves an entry node from an enum node using the entry's symbolic.
spinNodeMapGetNode
SPINNAKERC_API spinNodeMapGetNode(spinNodeMapHandle hNodeMap, const char *pName, spinNodeHandle *phNode)
Retrieves a node from the nodemap by name.
spinCameraListGetSize
SPINNAKERC_API spinCameraListGetSize(spinCameraList hCameraList, size_t *pSize)
Retrieves the number of cameras on a camera list.
onHeightNodeUpdate
void onHeightNodeUpdate(spinNodeHandle hNode)
Definition: NodeMapCallback_C.c:159
spinCameraDeInit
SPINNAKERC_API spinCameraDeInit(spinCamera hCamera)
Deinitializes a camera, greatly reducing functionality.
spinCameraGetTLDeviceNodeMap
SPINNAKERC_API spinCameraGetTLDeviceNodeMap(spinCamera hCamera, spinNodeMapHandle *phNodeMap)
Retrieves the transport layer device nodemap from a camera.
spinImageProcessorCreate
SPINNAKERC_API spinImageProcessorCreate(spinImageProcessor *phImageProcessor)
Creates an image processor.
ResetCallbacks
spinError ResetCallbacks(callbackArray *handleArray)
Definition: NodeMapCallback_C.c:851
PrintDeviceInfo
spinError PrintDeviceInfo(spinNodeMapHandle hNodeMap)
Definition: NodeMapCallback_C.c:1461
spinEnumerationGetNumEntries
SPINNAKERC_API spinEnumerationGetNumEntries(spinNodeHandle hEnumNode, size_t *pValue)
Retrieves the number of entries of an enum node.
IntegerNode
@ IntegerNode
Definition: SpinnakerGenApiDefsC.h:75
True
static const bool8_t True
Definition: SpinnakerDefsC.h:37
spinCategoryGetFeatureByIndex
SPINNAKERC_API spinCategoryGetFeatureByIndex(spinNodeHandle hCategoryNode, size_t index, spinNodeHandle *phFeature)
Retrieves a node from a category node using an index.
spinImageRelease
SPINNAKERC_API spinImageRelease(spinImage hImage)
Releases an image.
spinImageGetStatus
SPINNAKERC_API spinImageGetStatus(spinImage hImage, spinImageStatus *pStatus)
Retrieves the image status of an image.
callbackArray
Definition: NodeMapCallback_C.c:49
SPINNAKER_ERR_SUCCESS
@ SPINNAKER_ERR_SUCCESS
An error code of 0 means that the function has run without error.
Definition: SpinnakerDefsC.h:233
spinCameraListCreateEmpty
SPINNAKERC_API spinCameraListCreateEmpty(spinCameraList *phCameraList)
Creates an empty camera list (camera lists created this way must be destroyed)
spinNodeToString
SPINNAKERC_API spinNodeToString(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the value of any node type as a c-string.
PixelFormat_Mono8
@ PixelFormat_Mono8
Definition: CameraDefsC.h:732