Spinnaker C
4.3.0.189
 
ImageEvents_C.c

ImageEvents_C.c shows how to acquire images using the image event handler. It relies on information provided in the Enumeration_C, Acquisition_C, and NodeMapInfo_C examples.

It can also be helpful to familiarize yourself with the NodeMapCallback_C example, as nodemap callbacks follow the same general procedure as events, but with a few less steps.

Events generally require a class to be defined as an event handler; however, because C is not an object-oriented language, an event context is created using a function and a struct whereby the function acts as the event method and the struct acts as its properties.

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.
//=============================================================================
// Libraries windows.h or unistd.h included for Sleep()/usleep()
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
#include "windows.h"
#else
#include "unistd.h"
#endif
#include "SpinnakerC.h"
#include "stdio.h"
#include <stdlib.h>
#include "string.h"
// This helper function allows the example to sleep in both Windows and Linux
// systems. Note that Windows sleep takes milliseconds as a parameter while
// Linux systems take microseconds as a parameter.
void SleepyWrapper(int milliseconds)
{
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
Sleep(milliseconds);
#else
usleep(1000 * milliseconds);
#endif
}
// This macro helps with C-strings.
#define MAX_BUFF_LEN 256
// 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);
{
printf(
"Unable to retrieve node readability (%s node) with error: %s [%d]\n\n",
nodeName,
err);
}
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);
{
printf(
"Unable to retrieve node writability (%s node) with error: %s [%d]\n\n",
nodeName,
err);
}
return pbWritable;
}
// This function handles the error prints when a node or entry is unavailable or
// 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 struct represents the properties of what would be an image event handler
// were we working in an object-oriented programming language. The struct is
// created with a pointer and passed into the function, which creates persistent
// data, mimicking the properties of a class.
typedef struct _userData
{
unsigned int numImages;
unsigned int imageCnt;
} userData;
// This function represents what would be the method of an image event handler.
// Together with the struct above, this makes up the image event context.
// Notice that the function signature must match this exactly for the function
// to be accepted when creating the event.
void onImageEvent(spinImage hImage, void* pUserData)
{
spinError err = SPINNAKER_ERR_SUCCESS;
// Convert void pointer back to struct
userData* imageEventInfo = (userData*)pUserData;
// Only retrieve, convert, and save images if number of expected images has
// not been exceeded
if (imageEventInfo->imageCnt < imageEventInfo->numImages)
{
printf("Image event occurred...\n");
// Ensure image completion
bool8_t isIncomplete = False;
err = spinImageIsIncomplete(hImage, &isIncomplete);
{
printf("Unable to determine image completion. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
return;
}
if (isIncomplete)
{
spinImageStatus imageStatus = SPINNAKER_IMAGE_STATUS_NO_ERROR;
err = spinImageGetStatus(hImage, &imageStatus);
{
printf("Unable to retrieve image status. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
else
{
printf("Image incomplete with image status %d...\n", imageStatus);
}
return;
}
// Print image information
size_t width = 0;
size_t height = 0;
err = spinImageGetWidth(hImage, &width);
{
printf("Unable to retrieve image width. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
err = spinImageGetHeight(hImage, &height);
{
printf("Unable to retrieve image height. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
printf(
"Grabbed image %u, width = %u, height = %u\n",
imageEventInfo->imageCnt,
(unsigned int)width,
(unsigned int)height);
// Convert image to mono 8
spinImage hConvertedImage = NULL;
err = spinImageCreateEmpty(&hConvertedImage);
{
printf("Unable to create image. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
//
// Create Image Processor context for post processing images
//
spinImageProcessor hImageProcessor = NULL;
err = spinImageProcessorCreate(&hImageProcessor);
{
printf("Unable to create image processor. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n",
err);
}
err = spinImageProcessorConvert(hImageProcessor, hImage, hConvertedImage, PixelFormat_Mono8);
{
printf("Unable to convert image. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
return;
}
//
// 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: %s [%d]\n\n", GetLastErrorMessage(), err);
}
// Create unique file name
char filename[MAX_BUFF_LEN];
if (imageEventInfo->lenDeviceSerialNumber == 0)
{
sprintf(filename, "ImageEvents-C-%d.jpg", imageEventInfo->imageCnt);
}
else
{
sprintf(
filename,
"ImageEvents-C-%d-%d.jpg",
atoi(imageEventInfo->deviceSerialNumber),
imageEventInfo->imageCnt);
}
// Save image
err = spinImageSave(hConvertedImage, filename, SPINNAKER_IMAGE_FILE_FORMAT_JPEG);
{
printf("Unable to save image. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
else
{
printf("Image saved at %s\n\n", filename);
}
// Destroy converted image
err = spinImageDestroy(hConvertedImage);
{
printf("Unable to destroy image. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
// Increment number of saved images
imageEventInfo->imageCnt++;
}
}
// This function configures image event handlers by creating and registering them
// to a camera.
spinCamera hCam,
spinNodeMapHandle hNodeMapTLDevice,
spinImageEventHandler* imageEventHandler,
userData* imageEventInfo)
{
spinError err = SPINNAKER_ERR_SUCCESS;
printf("\n\n*** IMAGE EVENTS CONFIGURATION ***\n\n");
//
// Prepare user data
//
// *** NOTES ***
// It is important to ensure that all requisite variables are initialized
// appropriately before creating the image event context.
//
// *** LATER ***
// It is a good idea to keep this data in scope in order to avoid memory
// leaks.
//
// Initialize image count to zero and number of images to 10
imageEventInfo->imageCnt = 0;
imageEventInfo->numImages = 10;
// Initialize device serial number for filename
spinNodeHandle hDeviceSerialNumber = NULL;
imageEventInfo->lenDeviceSerialNumber = MAX_BUFF_LEN;
err = spinNodeMapGetNode(hNodeMapTLDevice, "DeviceSerialNumber", &hDeviceSerialNumber);
{
strcpy(imageEventInfo->deviceSerialNumber, "");
imageEventInfo->lenDeviceSerialNumber = 0;
}
else
{
if (IsReadable(hDeviceSerialNumber, "DeviceSerialNumber"))
{
hDeviceSerialNumber, imageEventInfo->deviceSerialNumber, &imageEventInfo->lenDeviceSerialNumber);
{
strcpy(imageEventInfo->deviceSerialNumber, "");
imageEventInfo->lenDeviceSerialNumber = 0;
}
printf("Device serial number retrieved as %s...\n", imageEventInfo->deviceSerialNumber);
}
else
{
PrintRetrieveNodeFailure("node", "DeviceSerialNumber");
strcpy(imageEventInfo->deviceSerialNumber, "");
imageEventInfo->lenDeviceSerialNumber = 0;
}
}
//
// Create image event handler
//
// *** NOTES ***
// The image event handler function has been written to only print convert and save
// images. This demonstrates an alternative method of acquiring images.
//
// *** LATER ***
// In Spinnaker C, every event handler that is created must be destroyed to avoid
// memory leaks.
//
err = spinImageEventHandlerCreate(imageEventHandler, onImageEvent, (void*)imageEventInfo);
{
printf("Unable to create event. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Image event created...\n");
//
// Register image event handler
//
// *** NOTES ***
// Image event handlers are registered to cameras. If there are multiple cameras,
// each camera must have the image event handlers registered to it separately.
// Also, multiple image event handlers may be registered to a single camera.
//
// *** LATER ***
// Image event handlers must be unregistered manually. This must be done prior to
// releasing the system and while the image event handlers are still in scope.
//
err = spinCameraRegisterImageEventHandler(hCam, *imageEventHandler);
{
printf("Unable to register event. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Image event registered...\n\n");
return err;
}
void WaitForImages(userData* imageEventInfo)
{
//
// Wait for images
//
// *** NOTES ***
// In order to passively capture images using image event handlers and
// automatic polling, the main thread sleeps in increments of 200 ms
// until 10 images have been acquired and saved.
//
const int sleepDuration = 200; // in milliseconds
while (imageEventInfo->imageCnt < imageEventInfo->numImages)
{
printf("\t//\n");
printf("\t// Sleeping for %d ms. Grabbing images...\n", sleepDuration);
printf("\t//\n");
SleepyWrapper(sleepDuration);
}
}
// This function resets the example by unregistering the image event handler.
spinError ResetImageEvents(spinCamera hCam, spinImageEventHandler imageEventHandler)
{
spinError err = SPINNAKER_ERR_SUCCESS;
//
// Unregister device event handler
//
// *** NOTES ***
// It is important to unregister all image event handlers from all cameras that
// they are registered to.
//
err = spinCameraUnregisterImageEventHandler(hCam, imageEventHandler);
{
printf("Unable to unregister event. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Image event unregistered...\n");
//
// Destroy event handlers
//
// *** NOTES ***
// Event handlers must be destroyed in order to avoid memory leaks.
//
err = spinImageEventHandlerDestroy(imageEventHandler);
{
printf("Unable to destroy event. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Image event destroyed...\n\n");
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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), 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 acquires and saves 10 images from a device; please see
// Acquisition_C example for more in-depth comments on the acquisition of
// images.
spinError AcquireImages(spinCamera hCam, spinNodeMapHandle hNodeMap, userData* imageEventInfo)
{
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;
err = spinNodeMapGetNode(hNodeMap, "AcquisitionMode", &hAcquisitionMode);
{
printf(
"Unable to set acquisition mode to continuous (node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
if (IsReadable(hAcquisitionMode, "AcquisitionMode"))
{
err = spinEnumerationGetEntryByName(hAcquisitionMode, "Continuous", &hAcquisitionModeContinuous);
{
printf(
"Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting with error "
"%d...\n\n",
err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "AcquistionMode");
}
if (IsReadable(hAcquisitionModeContinuous, "AcquisitionModeContinuous"))
{
err = spinEnumerationEntryGetIntValue(hAcquisitionModeContinuous, &acquisitionModeContinuous);
{
printf(
"Unable to set acquisition mode to continuous (entry int value retrieval). Aborting with error "
"%d...\n\n",
err);
return err;
}
}
else
{
PrintRetrieveNodeFailure("entry", "AcquisitionMode 'Continuous'");
}
// set acquisition mode to continuous
if (IsWritable(hAcquisitionMode, "AcquisitionMode"))
{
err = spinEnumerationSetIntValue(hAcquisitionMode, acquisitionModeContinuous);
{
printf(
"Unable to set acquisition mode to continuous (entry int value setting). Aborting with error %d...\n\n",
err);
return err;
}
printf("Acquisition mode set to continuous...\n");
}
else
{
PrintRetrieveNodeFailure("node", "AcquisitionMode");
}
// Begin acquiring images
{
printf("Unable to begin image acquisition. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("Acquiring images...\n");
// Wait for 10 images to be captured by image events
WaitForImages(imageEventInfo);
// End acquisition
{
printf("Unable to end acquisition. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), err);
}
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: %s [%d]\n\n", GetLastErrorMessage(), err);
}
else
{
err = PrintDeviceInfo(hNodeMapTLDevice);
}
// Initialize camera
err = spinCameraInit(hCam);
{
printf("Unable to initialize camera. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Retrieve GenICam nodemap
spinNodeMapHandle hNodeMap = NULL;
err = spinCameraGetNodeMap(hCam, &hNodeMap);
{
printf("Unable to retrieve GenICam nodemap. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Configure device event handlers
spinImageEventHandler imageEventHandler = NULL;
userData imageEventInfo;
err = ConfigureImageEvents(hCam, hNodeMapTLDevice, &imageEventHandler, &imageEventInfo);
{
return err;
}
// Acquire image handlers
err = AcquireImages(hCam, hNodeMap, &imageEventInfo);
{
return err;
}
// Reset device event handlers
err = ResetImageEvents(hCam, imageEventHandler);
{
return err;
}
// Deinitialize camera
err = spinCameraDeInit(hCam);
{
printf("Unable to deinitialize camera. Non-fatal error: %s [%d]\n\n", GetLastErrorMessage(), 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;
// Since this application saves images in the current folder
// we must ensure that we have permission to write to this folder.
// If we do not have permission, fail right away.
FILE* tempFile;
tempFile = fopen("test.txt", "w+");
if (tempFile == NULL)
{
printf("Failed to create file in current folder. Please check "
"permissions.\n");
printf("Press Enter to exit...\n");
getchar();
return -1;
}
fclose(tempFile);
remove("test.txt");
// 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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
err = spinSystemGetCameras(hSystem, hCameraList);
{
printf("Unable to retrieve camera list. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
err = spinCameraListDestroy(hCameraList);
{
printf("Unable to destroy camera list. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Release system
err = spinSystemReleaseInstance(hSystem);
{
printf("Unable to release system instance. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), 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: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
err = spinCameraListDestroy(hCameraList);
{
printf("Unable to destroy camera list. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
// Release system
err = spinSystemReleaseInstance(hSystem);
{
printf("Unable to release system instance. Aborting with error: %s [%d]\n\n", GetLastErrorMessage(), err);
return err;
}
printf("\nDone! Press Enter to exit...\n");
getchar();
return errReturn;
}
spinCameraRelease
SPINNAKERC_API spinCameraRelease(spinCamera hCamera)
Releases a camera.
RunSingleCamera
spinError RunSingleCamera(spinCamera hCam)
Definition: ImageEvents_C.c:652
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.
ResetImageEvents
spinError ResetImageEvents(spinCamera hCam, spinImageEventHandler imageEventHandler)
Definition: ImageEvents_C.c:418
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.
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.
spinCameraRegisterImageEventHandler
SPINNAKERC_API spinCameraRegisterImageEventHandler(spinCamera hCamera, spinImageEventHandler hImageEventHandler)
Registers an image event handler to a camera.
spinImageEventHandlerCreate
SPINNAKERC_API spinImageEventHandlerCreate(spinImageEventHandler *phImageEventHandler, spinImageEventFunction pFunction, void *pUserData)
Creates an image event handler.
MAX_BUFF_LEN
#define MAX_BUFF_LEN
Definition: ImageEvents_C.c:64
spinCameraBeginAcquisition
SPINNAKERC_API spinCameraBeginAcquisition(spinCamera hCamera)
Has a camera start acquiring images.
_userData::numImages
unsigned int numImages
Definition: ImageEvents_C.c:125
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...
spinImage
void * spinImage
Handle for image functionality.
Definition: SpinnakerDefsC.h:91
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...
spinStringGetValue
SPINNAKERC_API spinStringGetValue(spinNodeHandle hNode, char *pBuf, size_t *pBufLen)
Retrieves the value of a string node as a c-string.
spinNodeMapHandle
void * spinNodeMapHandle
Handle for nodemap functionality.
Definition: SpinnakerGenApiDefsC.h:39
_userData::deviceSerialNumber
char deviceSerialNumber[MAX_BUFF_LEN]
Definition: ImageEvents_C.c:129
SpinnakerC.h
spinEnumerationSetIntValue
SPINNAKERC_API spinEnumerationSetIntValue(spinNodeHandle hEnumNode, int64_t value)
Sets a new entry using its integer value retrieved from a call to spinEnumerationEntryGetIntValue(); ...
spinImageEventHandler
void * spinImageEventHandler
Handle for image event handler functionality.
Definition: SpinnakerDefsC.h:128
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: ImageEvents_C.c:67
PrintRetrieveNodeFailure
void PrintRetrieveNodeFailure(char node[], char name[])
Definition: ImageEvents_C.c:114
spinCategoryGetNumFeatures
SPINNAKERC_API spinCategoryGetNumFeatures(spinNodeHandle hCategoryNode, size_t *pValue)
Retrieves the number of a features (or child nodes) or a category 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...
PrintDeviceInfo
spinError PrintDeviceInfo(spinNodeMapHandle hNodeMap)
Definition: ImageEvents_C.c:459
_userData::imageCnt
unsigned int imageCnt
Definition: ImageEvents_C.c:126
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.
SleepyWrapper
void SleepyWrapper(int milliseconds)
Definition: ImageEvents_C.c:54
SPINNAKER_ERR_ACCESS_DENIED
@ SPINNAKER_ERR_ACCESS_DENIED
Definition: SpinnakerDefsC.h:243
spinSystem
void * spinSystem
Handle for system functionality.
Definition: SpinnakerDefsC.h:51
_userData::lenDeviceSerialNumber
size_t lenDeviceSerialNumber
Definition: ImageEvents_C.c:128
spinImageProcessor
void * spinImageProcessor
Handle for image processor functionality.
Definition: SpinnakerDefsC.h:107
spinCameraInit
SPINNAKERC_API spinCameraInit(spinCamera hCamera)
Initializes a camera, allowing for much more interaction.
AcquireImages
spinError AcquireImages(spinCamera hCam, spinNodeMapHandle hNodeMap, userData *imageEventInfo)
Definition: ImageEvents_C.c:551
False
static const bool8_t False
Definition: SpinnakerDefsC.h:36
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.
UnknownNode
@ UnknownNode
Definition: SpinnakerGenApiDefsC.h:85
WaitForImages
void WaitForImages(userData *imageEventInfo)
Definition: ImageEvents_C.c:395
spinNodeIsWritable
SPINNAKERC_API spinNodeIsWritable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is writable.
spinCameraUnregisterImageEventHandler
SPINNAKERC_API spinCameraUnregisterImageEventHandler(spinCamera hCamera, spinImageEventHandler hImageEventHandler)
Unregisters an image event handler from a camera.
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_FILE_FORMAT_JPEG
@ SPINNAKER_IMAGE_FILE_FORMAT_JPEG
JPEG.
Definition: SpinnakerDefsC.h:355
SPINNAKER_IMAGE_STATUS_NO_ERROR
@ SPINNAKER_IMAGE_STATUS_NO_ERROR
Image is returned from GetNextImage() call without any errors.
Definition: SpinnakerDefsC.h:388
spinCameraListGet
SPINNAKERC_API spinCameraListGet(spinCameraList hCameraList, size_t index, spinCamera *phCamera)
Retrieves a camera from a camera list using an index.
lastErrorMessage
char lastErrorMessage[MAX_BUFF_LEN]
Definition: ImageEvents_C.c:66
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
onImageEvent
void onImageEvent(spinImage hImage, void *pUserData)
Definition: ImageEvents_C.c:136
spinNodeIsReadable
SPINNAKERC_API spinNodeIsReadable(spinNodeHandle hNode, bool8_t *pbResult)
Checks whether a node is readable.
GetLastErrorMessage
char * GetLastErrorMessage()
Definition: ImageEvents_C.c:70
IsWritable
bool8_t IsWritable(spinNodeHandle hNode, char nodeName[])
Definition: ImageEvents_C.c:96
IsReadable
bool8_t IsReadable(spinNodeHandle hNode, char nodeName[])
Definition: ImageEvents_C.c:79
spinEnumerationGetEntryByName
SPINNAKERC_API spinEnumerationGetEntryByName(spinNodeHandle hEnumNode, const char *pName, spinNodeHandle *phEntry)
Retrieves an entry node from an enum node using the entry's symbolic.
spinImageSave
SPINNAKERC_API spinImageSave(spinImage hImage, const char *pFilename, spinImageFileFormat format)
Saves an image using a specified file format (using an enum, spinImageFileFormat)
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.
spinImageEventHandlerDestroy
SPINNAKERC_API spinImageEventHandlerDestroy(spinImageEventHandler hImageEventHandler)
Destroys an image event handler.
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.
ConfigureImageEvents
spinError ConfigureImageEvents(spinCamera hCam, spinNodeMapHandle hNodeMapTLDevice, spinImageEventHandler *imageEventHandler, userData *imageEventInfo)
Definition: ImageEvents_C.c:294
spinCategoryGetFeatureByIndex
SPINNAKERC_API spinCategoryGetFeatureByIndex(spinNodeHandle hCategoryNode, size_t index, spinNodeHandle *phFeature)
Retrieves a node from a category node using an index.
_userData
Definition: ImageEvents_C.c:123
spinImageGetStatus
SPINNAKERC_API spinImageGetStatus(spinImage hImage, spinImageStatus *pStatus)
Retrieves the image status of an image.
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
main
int main()
Definition: ImageEvents_C.c:723