This example introduces the preparation, use, and cleanup of the system object, interface and camera lists, interfaces, and cameras. It also touches on retrieving both nodes from nodemaps and information from nodes.
Once comfortable with enumeration, we suggest checking out either the Acquisition_C or NodeMapInfo_C examples. Acquisition_C demonstrates using a camera to acquire images while NodeMapInfo_C explores retrieving information from various node types.
#include "stdio.h"
#include "string.h"
#define MAX_BUFF_LEN 256
{
}
{
unsigned int i = 0;
{
printf(
"Unable to retrieve interface nodemap. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
err =
spinNodeMapGetNode(hNodeMapInterface,
"InterfaceDisplayName", &hInterfaceDisplayName);
{
printf(
"Unable to retrieve node (interface display name). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to check node readability (interface display name). Aborting with error: %s [%d]\n\n",
err);
return err;
}
if (interfaceDisplayNameIsReadable)
{
err =
spinStringGetValue(hInterfaceDisplayName, interfaceDisplayName, &lenInterfaceDisplayName);
{
printf(
"Unable to retrieve value (interface display name). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
strcpy(interfaceDisplayName, "Interface display name not readable");
}
printf("%s\n", interfaceDisplayName);
size_t numCameras = 0;
{
printf(
"Unable to create camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve number of cameras. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
if (numCameras == 0)
{
printf("\tNo devices detected.\n\n");
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
return err;
}
for (i = 0; i < numCameras; i++)
{
{
printf(
"Unable to retrieve camera. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve TL device nodemap. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve device information (vendor name node). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to check node readability (vendor name node). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to retrieve device information (model name node). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
printf(
"Unable to check node readability (model name node). Aborting with error: %s [%d]\n\n",
err);
return err;
}
if (deviceVendorNameIsReadable)
{
{
printf(
"Unable to retrieve device information (vendor name value). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
strcpy(deviceVendorName, "Not readable");
}
if (deviceModelNameIsReadable)
{
{
printf(
"Unable to retrieve device information (model name value). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
strcpy(deviceModelName, "Not readable");
}
printf("\tDevice %d %s %s\n\n", i, deviceVendorName, deviceModelName);
{
printf(
"Unable to release camera. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
return err;
}
{
unsigned int i = 0;
printf("Application build date: %s %s \n\n", __DATE__, __TIME__);
{
printf(
"Unable to retrieve system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
spinLibraryVersion hLibraryVersion;
printf(
"Spinnaker library version: %d.%d.%d.%d\n\n",
hLibraryVersion.major,
hLibraryVersion.minor,
hLibraryVersion.type,
hLibraryVersion.build);
size_t numInterfaces = 0;
{
printf(
"Unable to create empty interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf("Unable to retrieve number of interfaces. Aborting with err %d...\n\n", err);
return err;
}
printf("Number of interfaces detected: %u\n\n", (unsigned int)numInterfaces);
size_t numCameras = 0;
{
printf(
"Unable to create camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to retrieve camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
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);
if (numCameras == 0 || numInterfaces == 0)
{
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to clear interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("\nNot enough cameras/interfaces!\n");
printf("Done! Press Enter to exit...\n");
getchar();
return -1;
}
printf("\n*** QUERYING INTERFACES ***\n\n");
for (i = 0; i < numInterfaces; i++)
{
{
printf("Unable to retrieve interface from list (error %d)...\n", err);
errReturn = err;
continue;
}
{
errReturn = err;
}
{
errReturn = err;
}
}
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to clear interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
printf(
"Unable to destroy interface list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
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;
}