This example demonstrates setting minimums to offsets, X and Y, and maximums to width and height. It also shows the setting of a new pixel format, which is an enumeration type node.
Following this, we suggest familiarizing yourself with the Exposure_C example if you haven't already. Exposure is another example on camera customization that is shorter and simpler than many of the others. Once comfortable with Exposure_C and ImageFormatControl_C, we suggest checking out any of the longer, more complicated examples related to camera configuration: ChunkData_C, LookupTable_C, Sequencer_C, or Trigger_C.
#include "stdio.h"
#include "string.h"
#define MAX_BUFF_LEN 256
{
}
{
{
printf(
"Unable to retrieve node readability (%s node) with error: %s [%d]\n\n",
nodeName,
err);
}
return pbReadable;
}
{
{
printf(
"Unable to retrieve node writability (%s node) with error: %s [%d]\n\n",
nodeName,
err);
}
return pbWritable;
}
{
printf("Unable to get %s (%s %s retrieval failed).\n\n", node, name, node);
}
{
printf("\n\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n\n");
int64_t pixelFormatMono8 = 0;
{
printf(
"Unable to set pixel format (node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
{
{
printf(
"Unable to set pixel format (enum entry retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
}
if (
IsReadable(hPixelFormatMono8,
"PixelFormatMono8"))
{
{
printf(
"Unable to set pixel format (enum entry int value retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
}
{
{
printf(
"Unable to set pixel format (enum entry setting). Aborting with error: %s [%d]\n\n",
err);
return err;
}
}
else
{
}
printf("Pixel format set to 'mono8'...\n");
int64_t offsetXMin = 0;
{
printf(
"Unable to set offset x. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
{
printf(
"Unable to get offset x. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
else
{
}
{
{
printf(
"Unable to set offset x. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
else
{
}
printf("Offset X set to %d...\n", (int)offsetXMin);
int64_t offsetYMin = 0;
{
printf(
"Unable to set offset Y. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
{
printf(
"Unable to get offset Y. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
else
{
}
{
{
printf(
"Unable to set offset Y. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
else
{
}
printf("Offset Y set to %d...\n", (int)offsetYMin);
int64_t widthToSet = 0;
{
return err;
}
{
{
return err;
}
}
else
{
}
{
{
return err;
}
}
else
{
}
printf("Width set to %d...\n", (int)widthToSet);
int64_t HeightToSet = 0;
{
return err;
}
{
{
return err;
}
}
else
{
}
{
{
return err;
}
}
else
{
}
printf("Height set to %d...\n", (int)HeightToSet);
return err;
}
{
unsigned int i = 0;
printf("\n*** DEVICE INFORMATION ***\n\n");
{
return err;
}
size_t numFeatures = 0;
if (
IsReadable(hDeviceInformation,
"DeviceInformation"))
{
{
printf(
"Unable to retrieve number of nodes. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
}
else
{
}
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);
}
printf("\n");
return err;
}
{
printf("\n*** IMAGE ACQUISITION ***\n\n");
int64_t acquisitionModeContinuous = 0;
{
printf(
"Unable to set acquisition mode to continuous (node retrieval). Aborting with error: %s [%d]\n\n",
err);
return err;
}
if (
IsReadable(hAcquisitionMode,
"AcquisitionMode"))
{
{
printf(
"Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting with error "
"%d...\n\n",
err);
return err;
}
}
else
{
}
if (
IsReadable(hAcquisitionModeContinuous,
"AcquisitionModeContinuous"))
{
{
printf(
"Unable to set acquisition mode to continuous (entry int value retrieval). Aborting with error "
"%d...\n\n",
err);
return err;
}
}
else
{
}
if (
IsWritable(hAcquisitionMode,
"AcquisitionMode"))
{
{
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
{
}
{
printf(
"Unable to begin image acquisition. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("Acquiring images...\n");
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
else
{
if (
IsReadable(hDeviceSerialNumber,
"DeviceSerialNumber"))
{
err =
spinStringGetValue(hDeviceSerialNumber, deviceSerialNumber, &lenDeviceSerialNumber);
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
printf("Device serial number retrieved as %s...\n", deviceSerialNumber);
}
else
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
}
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, "ImageFormatControl-C-%d.jpg", imageCnt);
}
else
{
sprintf(filename, "ImageFormatControl-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 err;
}
{
{
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 err;
}
{
printf(
"Unable to retrieve GenICam nodemap. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
{
return err;
}
{
return err;
}
{
printf(
"Unable to deinitialize camera. Non-fatal error: %s [%d]\n\n",
GetLastErrorMessage(), err);
}
return err;
}
{
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();
}
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);
return err;
}
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);
return err;
}
{
printf(
"Unable to retrieve camera list. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
size_t numCameras = 0;
{
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)
{
{
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 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;
}
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 = err;
}
else
{
{
errReturn = err;
}
}
{
errReturn = err;
}
printf("Camera %d example complete...\n\n", i);
}
{
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 release system instance. Aborting with error: %s [%d]\n\n",
GetLastErrorMessage(), err);
return err;
}
printf("\nDone! Press Enter to exit...\n");
getchar();
return errReturn;
}