It can also be helpful to familiarize yourself with the ImageFormatControl_C and Exposure_C examples as these provide a strong introduction to camera customization.
Lookup tables allow for the customization and control of individual pixels. This can be a very powerful and deeply useful tool; however, because use cases are context dependent, this example only explores lookup table configuration.
#include "stdio.h"
#include "string.h"
#define MAX_BUFF_LEN 256
{
}
{
{
printf(
"Unable to retrieve node readability, with error %s [%d]...\n\n",
GetLastErrorMessage(), err);
}
return pbReadable;
}
{
{
printf(
"Unable to retrieve node writabilty, with error %s [%d]...\n\n",
GetLastErrorMessage(), err);
}
return pbWritable;
}
{
printf("Unable to get %s (%s %s retrieval failed).\n\n", node, name, node);
printf("The %s may not be readable or writable on all camera models...\n", node);
printf("Please try a Blackfly S camera.\n\n");
}
{
printf("\n\n*** LOOKUP TABLE CONFIGURATION ***\n\n");
int64_t lutSelectorLUT1 = 0;
{
return -1;
}
{
return -1;
}
{
printf(
"Unable to set lookup table type (enum entry int value retrieval). Aborting with error: %s [%d]\n\n",
err);
return -1;
}
{
return -1;
}
{
printf(
"Unable to set lookup table type (enum entry setting). Aborting with error: %s [%d]\n\n",
err);
return -1;
}
printf("Lookup table type set to LUT1...\n");
int64_t maximumRange = 0;
int64_t increment = 0;
int64_t i = 0;
{
return -1;
}
{
printf(
"Unable to configure lookup table. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
maximumRange++;
printf("\tMaximum range: %d\n", (int)maximumRange);
increment = maximumRange / 512;
printf("\tIncrement: %d\n", (int)increment);
{
return -1;
}
for (i = 0; i < maximumRange; i += increment)
{
{
printf(
"Unable to configure lookup table. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
{
printf(
"Unable to configure lookup table. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
}
printf("All lookup table values set...\n");
{
return -1;
}
{
printf(
"Unable to enable lookup table. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
printf("Lookup table enabled...\n\n");
return 0;
}
{
{
return -1;
}
printf("Lookup tables disabled...\n\n");
return 0;
}
{
unsigned int i = 0;
printf("\n*** DEVICE INFORMATION ***\n\n");
{
return -1;
}
size_t numFeatures = 0;
{
printf(
"Unable to retrieve number of nodes. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
for (i = 0; i < numFeatures; i++)
{
{
continue;
}
{
strcpy(featureName, "Unknown name");
}
{
{
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;
}
{
strcpy(featureValue, "Unknown value");
}
printf("%s: %s\n", featureName, featureValue);
}
return 0;
}
{
printf("\n*** IMAGE ACQUISITION ***\n\n");
int64_t acquisitionModeContinuous = 0;
{
printf(
"Unable to get acquisition mode to continuous (node retrieval). Aborting with error: %s [%d]\n\n",
err);
return -1;
}
{
printf(
"Unable to get acquisition mode to continuous (entry 'continuous' retrieval). Aborting with error "
"%d...\n\n",
err);
return -1;
}
{
printf(
"Unable to set acquisition mode to continuous (entry int value retrieval). Aborting with error %d...\n\n",
err);
return -1;
}
{
printf(
"Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting with error "
"%d...\n\n",
err);
return -1;
}
{
printf(
"Unable to set acquisition mode to continuous (entry int value setting). Aborting with error %d...\n\n",
err);
return -1;
}
printf("Acquisition mode set to continuous...\n");
{
printf(
"Unable to begin image acquisition. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
printf("Acquiring images...\n");
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
else
{
err =
spinStringGetValue(hDeviceSerialNumber, deviceSerialNumber, &lenDeviceSerialNumber);
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
printf("Device serial number retrieved as %s...\n", deviceSerialNumber);
}
printf("\n");
const unsigned int k_numImages = 10;
unsigned int imageCnt = 0;
{
printf(
"Unable to create image processor. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
{
printf(
"Unable to set image processor color processing method. Non-fatal error: %s [%d]\n\n",
err);
}
for (imageCnt = 0; imageCnt < k_numImages; imageCnt++)
{
{
continue;
}
{
printf(
"Unable to determine image completion. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
if (isIncomplete)
{
{
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);
}
}
if (hasFailed)
{
{
}
continue;
}
size_t width = 0;
size_t height = 0;
{
printf(
"Unable to retrieve image width. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
{
printf(
"Unable to retrieve image height. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
printf("Grabbed image %u, width = %u, height = %u\n", imageCnt, (unsigned int)width, (unsigned int)height);
{
}
{
}
if (lenDeviceSerialNumber == 0)
{
sprintf(filename, "LookupTable-C-%d.jpg", imageCnt);
}
else
{
sprintf(filename, "LookupTable-C-%s-%d.jpg", deviceSerialNumber, imageCnt);
}
{
}
else
{
printf("Image saved at %s\n\n", filename);
}
{
}
{
}
}
{
printf(
"Unable to destroy image processor. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
{
}
return 0;
}
{
int result = 0;
{
printf(
"Unable to retrieve TL device nodemap. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
else
{
}
{
printf(
"Unable to initialize camera. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
{
printf(
"Unable to retrieve GenICam nodemap. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return -1;
}
{
return -1;
}
{
return -1;
}
{
return -1;
}
{
printf(
"Unable to deinitialize camera. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
return result;
}
{
int errReturn = 0;
unsigned int i = 0;
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");
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);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
spinLibraryVersion hLibraryVersion;
printf(
"Spinnaker library version: %d.%d.%d.%d\n\n",
hLibraryVersion.major,
hLibraryVersion.minor,
hLibraryVersion.type,
hLibraryVersion.build);
{
printf(
"Unable to create camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
{
printf(
"Unable to retrieve camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
size_t numCameras = 0;
{
printf(
"Unable to retrieve number of cameras. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
printf("Number of cameras detected: %u\n\n", (unsigned int)numCameras);
if (numCameras == 0)
{
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
{
printf(
"Unable to release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
printf("Not enough cameras!\n");
printf("Done! Press Enter to exit...\n");
getchar();
return -1;
}
for (i = 0; i < numCameras; i++)
{
printf("\nRunning example for camera %d...\n", i);
{
printf(
"Unable to retrieve camera from list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
errReturn = -1;
}
else
{
{
errReturn = -1;
}
}
{
errReturn = -1;
printf(
"Unable to release camera instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
continue;
}
printf("Camera %d example complete...\n\n", i);
}
{
printf(
"Unable to clear camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
{
printf(
"Unable to destroy camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
{
printf(
"Unable to release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
printf("\nDone! Press Enter to exit...\n");
getchar();
return -1;
}
printf("\nDone! Press Enter to exit...\n");
getchar();
return errReturn;
}