Spinnaker C
4.3.0.189
 
NodeMapInfo_C_QuickSpin.c

NodeMapInfo_C_QuickSpin.c shows how to interact with nodes using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control.

This example demonstrates the retrieval of information from both the transport layer and the camera. Because the focus of this example is node access, which is where QuickSpin and regular Spinnaker differ, this example differs from NodeMapInfo_C quite a bit.

A much wider range of topics is covered in the full Spinnaker examples than in the QuickSpin ones. There are only enough QuickSpin examples to demonstrate node access and to get started with the API; please see full Spinnaker examples for further or specific knowledge on a topic.

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 "stdio.h"
#include "string.h"
// This macro helps with C-strings.
#define MAX_BUFF_LEN 256
// This macro defines the maximum number of characters that will be printed out
// for any information retrieved from a node.
#define MAX_CHARS 35
// This function prints node information if applicable.
void PrintNodeInfo(spinNodeHandle spinNodeHandler)
{
//
// Notice that each node is checked for availability and readability
// prior to value retrieval. Checking for availability and readability
// (or writability when applicable) whenever a node is accessed is
// important in terms of error handling. If a node retrieval error
// occurs but remains unhandled, an exception is thrown.
//
if (spinNodeHandler != NULL)
{
spinError err = SPINNAKER_ERR_SUCCESS;
bool8_t isNodeInfoReadable = False;
err = spinNodeIsReadable(spinNodeHandler, &isNodeInfoReadable);
{
char nodeInfoItem[MAX_BUFF_LEN];
size_t lenNodeInfoItem = MAX_BUFF_LEN;
err = spinNodeToString(spinNodeHandler, nodeInfoItem, &lenNodeInfoItem);
{
printf("%s\n", nodeInfoItem);
return;
}
else
{
printf("Unable to convert node information due to error %d...\n", err);
return;
}
}
}
printf("unavailable\n");
}
// This function prints device information from the transport layer.
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Pre-fetch TL device nodes
//
// *** NOTES ***
// In order to use QuickSpin in C, it is required to manually pre-fetch
// all available nodes into a QuickSpin struct, which then acts as the
// means of accessing its nodes. In order to pre-fetch TL device nodes,
// the quickSpinTLDeviceInit() function and its corresponding
// quickSpinTLDevice object are used.
//
// The main advantage of transport layer nodes is that they do not require
// camera initialization. The main disadvantage is that there is much less
// camera information and interaction that may be performed.
//
quickSpinTLDevice qsD;
err = quickSpinTLDeviceInit(hCamera, &qsD);
{
printf("Unable to pre-fetch TL device nodes. Aborting with error %d...\n\n", err);
return err;
}
//
// Print device information from the transport layer
//
// *** NOTES ***
// In QuickSpin, accessing device information on the transport layer is
// accomplished via a camera's quickSpinTLDevice object. The
// quickSpinTLDevice object houses nodes related to general device
// information such as the three demonstrated below, device access status,
// XML and GUI paths and locations, and GEV information to name a few. The
// quickSpinTLDevice property allows access to nodes that would generally
// be retrieved through the TL device nodemap in full Spinnaker.
//
// Print device serial number
printf("Device serial number: ");
PrintNodeInfo(qsD.DeviceSerialNumber);
// Print device vendor name
printf("Device vendor name: ");
PrintNodeInfo(qsD.DeviceVendorName);
// Print device display name
printf("Device display name: ");
PrintNodeInfo(qsD.DeviceDisplayName);
printf("\n");
return err;
}
// This function prints stream information from the transport layer.
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Pre-fetch TL device nodes
//
// *** NOTES ***
// Separate from TL device, but still on the transport layer, the TL stream
// nodes provide information. TL stream nodes are accessed via the
// quickspinTLStreamInit() function and its corresponding quickSpinTLStream
// object.
//
quickSpinTLStream qsS;
err = quickSpinTLStreamInit(hCamera, &qsS);
{
printf("Unable to pre-fetch TL stream nodes. Aborting with error %d...\n\n", err);
return err;
}
//
// Print stream information from the transport layer
//
// *** NOTES ***
// In QuickSpin, accessing stream information on the transport layer is
// accomplished via a camera's quickSpinTLStream object. The
// quickSpinTLStream object houses nodes related to streaming such as the
// two demonstrated below, buffer information, and GEV packet information
// to name a few. The quickSpinTLStream object allows access to nodes that
// would generally be retrieved through the TL stream nodemap in full
// Spinnaker.
//
// Print stream serial
printf("Stream ID: ");
PrintNodeInfo(qsS.StreamID);
// Print stream type
printf("Stream type: ");
PrintNodeInfo(qsS.StreamType);
printf("\n");
return err;
}
// This function prints information about the interface.
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Pre-fetch TL interface nodes
//
// *** NOTES ***
// The final group of nodes on the transport layer are the interface nodes.
// TL interface nodes are accessed via the quickspinTLInterfaceInit()
// function and its corresponding quickSpinTLInterface object. Of course,
// these nodes are accessed via interfaces instead of cameras.
//
quickSpinTLInterface qsI;
err = quickSpinTLInterfaceInit(hInterface, &qsI);
{
printf("Unable to pre-fetch TL interface nodes. Aborting with error %d...\n\n", err);
return err;
}
//
// Print interface information from the transport layer
//
// *** NOTES ***
// In QuickSpin, accessing interface information is accomplished via an
// interface's quickSpinTLInterface object. The quickSpinTLInterface object
// houses nodes that hold information about the interface such as the three
// demonstrated below, other general interface information, and
// GEV addressing information. The quickSpinTLInterface object allows
// access to nodes that would generally be retrieved through the interface
// nodemap in full Spinnaker.
//
// Print interface display name
printf("Interface display name: ");
PrintNodeInfo(qsI.InterfaceDisplayName);
// Print interface ID
printf("Interface ID: ");
PrintNodeInfo(qsI.InterfaceID);
// Print interface type
printf("Interface type: ");
PrintNodeInfo(qsI.InterfaceType);
//
// Print host adapter information from the transport layer
//
// *** NOTES ***
// Host adapter information is part of the interface information from the
// transport layer. In QuickSpin, accessing the host adapter information is
// also accomplished via the interface's quickSpinTLInterface object. This
// information can help in determining which interface to use for better
// performance as some host adapters may have more significant physical
// limitations.
//
// Interface nodes should also always be checked for availability and
// readability (or writability when applicable). If a node retrieval
// error occurs but remains unhandled, an exception is thrown.
//
// Print host adapter name
printf("Host adapter name: ");
PrintNodeInfo(qsI.HostAdapterName);
// Print host adapter vendor
printf("Host adapter vendor: ");
PrintNodeInfo(qsI.HostAdapterVendor);
// Print host adapter driver version
printf("Host adapter driver version: ");
PrintNodeInfo(qsI.HostAdapterDriverVersion);
printf("\n");
return err;
}
// This function prints device information from the GenICam nodemap.
spinError PrintGenICamInfo(spinCamera hCamera)
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Pre-fetch GenICam nodes
//
// *** NOTES ***
// Unlike other nodes, GenICam nodes are not on the transport layer.
// These nodes are accessed via the quickSpinInit() function and its
// corresponding quickSpin object.
//
// The main advantages of GenICam nodes is that there are a lot more of
// them and that they provide a much deeper level of interaction with a
// camera. The main disadvantage is that they require camera
// initialization.
//
quickSpin qs;
err = quickSpinInit(hCamera, &qs);
{
printf("Unable to pre-fetch TL device nodes. Aborting with error %d...\n\n", err);
return err;
}
//
// Print device information from the camera
//
// *** NOTES ***
// In QuickSpin, accessing most camera information and customizing most
// settings requires access to GenICam nodes, which requires camera
// initialization. Note that QuickSpin initialization and camera
// initialization are two different processes, both of which are required
// to access GenICam nodes through QuickSpin.
//
// Print exposure time
printf("Exposure time: ");
PrintNodeInfo(qs.ExposureTime);
// Print black level
printf("Black level: ");
PrintNodeInfo(qs.BlackLevel);
// Print height
printf("Height: ");
PrintNodeInfo(qs.Height);
printf("\n");
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
//
// *** NOTES ***
// Everything originates from the system. Notice that it is implemented as
// a singleton object, making it impossible to have more than one system.
//
// *** LATER ***
// The system object should be cleared prior to program completion. If not
// released explicitly, it will release itself automatically.
//
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 interfaces from the system
spinInterfaceList hInterfaceList = NULL;
err = spinInterfaceListCreateEmpty(&hInterfaceList);
{
printf("Unable to create interface list. Aborting with error %d...\n\n", err);
return err;
}
err = spinSystemGetInterfaces(hSystem, hInterfaceList);
{
printf("Unable to retrieve interface list. Aborting with error %d...\n\n", err);
return err;
}
// Retrieve number of interfaces
size_t numInterfaces = 0;
err = spinInterfaceListGetSize(hInterfaceList, &numInterfaces);
{
printf("Unable to retrieve number of interfaces. Aborting with error %d...\n\n", err);
return err;
}
printf("Number of interfaces detected: %u\n\n", (unsigned int)numInterfaces);
// 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);
//
// Print information on each interface
//
// *** NOTES ***
// All USB 3 Vision and GigE Vision interfaces should enumerate for
// Spinnaker.
//
printf("\n*** PRINTING INTERFACE INFORMATION ***\n\n");
for (i = 0; i < numInterfaces; i++)
{
// Retrieve interface
spinInterface hInterface = NULL;
err = spinInterfaceListGet(hInterfaceList, i, &hInterface);
{
errReturn = err;
}
// Print TL information
{
errReturn = err;
}
// Release interface
err = spinInterfaceRelease(hInterface);
{
errReturn = err;
}
}
//
// Print general device information on each camera from transport layer
//
// *** NOTES ***
// Transport layer nodes do not require initialization in order to interact
// with them.
//
printf("\n*** PRINTING TRANSPORT LAYER DEVICE INFORMATION ***\n\n");
for (i = 0; i < numCameras; i++)
{
// Retrieve camera
spinCamera hCamera = NULL;
err = spinCameraListGet(hCameraList, i, &hCamera);
{
errReturn = err;
}
// Print TL device information
{
errReturn = err;
}
// Release camera
err = spinCameraRelease(hCamera);
{
errReturn = err;
}
}
//
// Print streaming information on each camera from transport layer
//
// *** NOTES ***
// Again, initialization is not required to print information from the
// transport layer; this is equally true of streaming information.
//
printf("\n*** PRINTING TRANSPORT LAYER STREAM INFORMATION ***\n\n");
for (i = 0; i < numCameras; i++)
{
// Select camera
spinCamera hCamera = NULL;
err = spinCameraListGet(hCameraList, i, &hCamera);
{
errReturn = err;
}
// Print TL stream information
{
errReturn = err;
}
// Release camera
err = spinCameraRelease(hCamera);
{
errReturn = err;
}
}
//
// Print device information on each camera from GenICam nodemap
//
// *** NOTES ***
// GenICam nodes require initialization in order to interact with
// them; as such, this loop initializes the camera, prints some information
// from the GenICam nodemap, and then deinitializes it. If the camera were
// not initialized, node availability would fail.
//
printf("\n*** PRINTING GENICAM INFORMATION ***\n\n");
for (i = 0; i < numCameras; i++)
{
// Select camera
spinCamera hCamera = NULL;
err = spinCameraListGet(hCameraList, i, &hCamera);
{
errReturn = err;
}
// Initialize camera
err = spinCameraInit(hCamera);
{
errReturn = err;
}
// Print GenICam information
err = PrintGenICamInfo(hCamera);
{
errReturn = err;
}
// Deinitialize information
err = spinCameraDeInit(hCamera);
{
errReturn = err;
}
// Release camera
err = spinCameraRelease(hCamera);
{
errReturn = err;
}
}
// 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;
}
// Clear interface list before releasing system
err = spinInterfaceListClear(hInterfaceList);
{
printf("Unable to clean interface list. Aborting with error %d...\n\n", err);
return err;
}
err = spinInterfaceListDestroy(hInterfaceList);
{
printf("Unable to destroy interface 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.
spinInterfaceListGet
SPINNAKERC_API spinInterfaceListGet(spinInterfaceList hInterfaceList, size_t index, spinInterface *phInterface)
Retrieves an interface from an interface list using an index (interfaces retrieved this way must be r...
spinCameraListClear
SPINNAKERC_API spinCameraListClear(spinCameraList hCameraList)
Clears a camera list.
spinInterfaceRelease
SPINNAKERC_API spinInterfaceRelease(spinInterface hInterface)
Releases an interface.
PrintGenICamInfo
spinError PrintGenICamInfo(spinCamera hCamera)
Definition: NodeMapInfo_C_QuickSpin.c:272
PrintTransportLayerStreamInfo
spinError PrintTransportLayerStreamInfo(spinCamera hCamera)
Definition: NodeMapInfo_C_QuickSpin.c:145
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...
spinInterfaceList
void * spinInterfaceList
Handle for interface list functionality.
Definition: SpinnakerDefsC.h:59
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...
spinInterfaceListCreateEmpty
SPINNAKERC_API spinInterfaceListCreateEmpty(spinInterfaceList *phInterfaceList)
Creates an empty interface list (interface lists created this way must be destroyed)
SpinnakerC.h
main
int main()
Definition: NodeMapInfo_C_QuickSpin.c:326
spinInterfaceListGetSize
SPINNAKERC_API spinInterfaceListGetSize(spinInterfaceList hInterfaceList, size_t *pSize)
Retrieves the number of interfaces in an interface list.
spinSystemGetLibraryVersion
SPINNAKERC_API spinSystemGetLibraryVersion(spinSystem hSystem, spinLibraryVersion *hLibraryVersion)
Get current library version of Spinnaker.
spinSystem
void * spinSystem
Handle for system functionality.
Definition: SpinnakerDefsC.h:51
spinCameraInit
SPINNAKERC_API spinCameraInit(spinCamera hCamera)
Initializes a camera, allowing for much more interaction.
MAX_BUFF_LEN
#define MAX_BUFF_LEN
Definition: NodeMapInfo_C_QuickSpin.c:44
False
static const bool8_t False
Definition: SpinnakerDefsC.h:36
spinCameraListDestroy
SPINNAKERC_API spinCameraListDestroy(spinCameraList hCameraList)
Destroys a camera list.
quickSpinTLDeviceInit
SPINNAKERC_API quickSpinTLDeviceInit(spinCamera hCamera, quickSpinTLDevice *pQuickSpinTLDevice)
spinCameraList
void * spinCameraList
Handle for interface functionality.
Definition: SpinnakerDefsC.h:75
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...
spinInterfaceListClear
SPINNAKERC_API spinInterfaceListClear(spinInterfaceList hInterfaceList)
Clears an interface list.
spinCameraListGet
SPINNAKERC_API spinCameraListGet(spinCameraList hCameraList, size_t index, spinCamera *phCamera)
Retrieves a camera from a camera list using an index.
quickSpinInit
SPINNAKERC_API quickSpinInit(spinCamera hCamera, quickSpin *pQuickSpin)
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
quickSpinTLStreamInit
SPINNAKERC_API quickSpinTLStreamInit(spinCamera hCamera, quickSpinTLStream *pQuickSpinTLStream)
spinNodeIsReadable
SPINNAKERC_API spinNodeIsReadable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is readable.
quickSpinTLInterfaceInit
SPINNAKERC_API quickSpinTLInterfaceInit(spinInterface hInterface, quickSpinTLInterface *pQuickSpinTLInterface)
PrintTransportLayerDeviceInfo
spinError PrintTransportLayerDeviceInfo(spinCamera hCamera)
Definition: NodeMapInfo_C_QuickSpin.c:88
spinInterfaceListDestroy
SPINNAKERC_API spinInterfaceListDestroy(spinInterfaceList hInterfaceList)
Destroys an interface list.
PrintNodeInfo
void PrintNodeInfo(spinNodeHandle spinNodeHandler)
Definition: NodeMapInfo_C_QuickSpin.c:51
spinSystemGetInterfaces
SPINNAKERC_API spinSystemGetInterfaces(spinSystem hSystem, spinInterfaceList hInterfaceList)
Retrieves a list of detected (and enumerable) interfaces on the system; interface lists must be creat...
spinInterface
void * spinInterface
Handle for interface functionality.
Definition: SpinnakerDefsC.h:66
spinCameraListGetSize
SPINNAKERC_API spinCameraListGetSize(spinCameraList hCameraList, size_t *pSize)
Retrieves the number of cameras on a camera list.
spinCameraDeInit
SPINNAKERC_API spinCameraDeInit(spinCamera hCamera)
Deinitializes a camera, greatly reducing functionality.
PrintTransportLayerInterfaceInfo
spinError PrintTransportLayerInterfaceInfo(spinInterface hInterface)
Definition: NodeMapInfo_C_QuickSpin.c:192
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.