This example demonstrates customizing offsets X and Y, width and height, and the pixel format. Ensuring custom values fall within an acceptable range is also touched on. Retrieving and setting node values using QuickSpin is the only portion of the example that differs from ImageFormatControl_C.
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.
#include "stdio.h"
#include "string.h"
#define MAX_BUFF_LEN 256
{
{
printf("Unable to retrieve node readability (%s node), with error %d...\n\n", nodeName, err);
}
return pbReadable;
}
{
printf("\n\n*** CONFIGURING CUSTOM IMAGE SETTINGS ***\n\n");
{
printf("Unable to set pixel format. Aborting with error %d...\n", err);
return err;
}
printf("Pixel format set to 'mono8'...\n");
int64_t offsetXMin = 0;
{
printf("Unable to set offset x. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to set offset x. Aborting with error %d...\n\n", err);
return err;
}
printf("Offset X set to %d...\n", (int)offsetXMin);
int64_t offsetYMin = 0;
{
printf("Unable to set offset y. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to set offset y. Aborting with error %d...\n\n", err);
return err;
}
printf("Offset Y set to %d...\n", (int)offsetYMin);
int64_t widthToSet = 0;
{
printf("Unable to set width. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to set width. Aborting with error %d...\n\n", err);
return err;
}
printf("Width set to %d...\n", (int)widthToSet);
int64_t heightToSet = 0;
{
printf("Unable to set height. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to set height. Aborting with error %d...\n\n", err);
return err;
}
printf("Height set to %d...\n\n", (int)heightToSet);
return err;
}
{
unsigned int i = 0;
printf("\n*** DEVICE INFORMATION ***\n\n");
{
printf("Unable to retrieve nodemap. Non-fatal error %d...\n\n", err);
return err;
}
{
printf("Unable to retrieve node. Non-fatal error %d...\n\n", err);
return err;
}
size_t numFeatures = 0;
{
printf("Unable to retrieve number of nodes. Non-fatal error %d...\n\n", err);
return err;
}
for (i = 0; i < numFeatures; i++)
{
{
printf("Unable to retrieve node. Non-fatal error %d...\n\n", err);
continue;
}
{
strcpy(featureName, "Unknown name");
}
{
{
printf("Unable to retrieve node type. Non-fatal error %d...\n\n", 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");
{
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");
{
printf("Unable to begin image acquisition. Aborting with error %d...\n\n", err);
return err;
}
printf("Acquiring images...\n");
err =
spinStringGetValue(qsD.DeviceSerialNumber, deviceSerialNumber, &lenDeviceSerialNumber);
{
strcpy(deviceSerialNumber, "");
lenDeviceSerialNumber = 0;
}
else
{
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 %d...\n\n", err);
}
{
printf("Unable to set image processor color processing method. Non-fatal error %d...\n\n", err);
}
for (imageCnt = 0; imageCnt < k_numImages; imageCnt++)
{
{
printf("Unable to get next image. Non-fatal error %d...\n\n", err);
continue;
}
{
printf("Unable to determine image completion. Non-fatal error %d...\n\n", err);
}
if (isIncomplete)
{
{
printf("Unable to retrieve image status. Non-fatal error %d...\n\n", err);
}
else
{
printf("Image incomplete with image status %d...\n", imageStatus);
}
}
if (hasFailed)
{
{
printf("Unable to release image. Non-fatal error %d...\n\n", err);
}
continue;
}
size_t width = 0;
size_t height = 0;
{
printf("Unable to retrieve image width. Non-fatal error %d...\n", err);
}
{
printf("Unable to retrieve image height. Non-fatal error %d...\n", err);
}
printf("Grabbed image %u, width = %u, height = %u\n", imageCnt, (unsigned int)width, (unsigned int)height);
{
printf("Unable to create image. Non-fatal error %d...\n\n", err);
}
{
printf("Unable to convert image. Non-fatal error %d...\n\n", err);
}
if (lenDeviceSerialNumber == 0)
{
sprintf(filename, "ImageFormatControl-C-%d.jpg", imageCnt);
}
else
{
sprintf(filename, "ImageFormatControl-C-%s-%d.jpg", deviceSerialNumber, imageCnt);
}
{
printf("Unable to save image. Non-fatal error %d...\n", err);
}
else
{
printf("Image saved at %s\n\n", filename);
}
{
printf("Unable to destroy image. Non-fatal error %d...\n", err);
}
{
printf("Unable to release image. Non-fatal error %d...\n\n", err);
}
}
{
printf("Unable to destroy image processor. Non-fatal error %d...\n\n", err);
}
{
printf("Unable to end acquisition. Non-fatal error %d...\n\n", err);
}
return err;
}
{
{
printf("Unable to initialize camera. Aborting with error %d...\n\n", err);
return err;
}
quickSpinTLDevice qsD;
{
printf("Unable to pre-fetch TL device nodes. Aborting with error %d...\n\n", err);
return err;
}
quickSpin qs;
{
printf("Unable to pre-fetch GenICam nodes. Aborting with error %d...\n\n", err);
return err;
}
{
return err;
}
{
return err;
}
{
printf("Unable to deinitialize camera. Non-fatal error %d...\n\n", 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 %d...\n\n", 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 %d...\n\n", err);
return err;
}
{
printf("Unable to retrieve camera list. Aborting with error %d...\n\n", err);
return err;
}
size_t numCameras = 0;
{
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);
if (numCameras == 0)
{
{
printf("Unable to clear camera list. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to destroy camera list. Aborting with error %d...\n\n", err);
return err;
}
{
printf("Unable to release system instance. Aborting with error %d...\n\n", 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 %d...\n\n", 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 %d...\n\n", err);
return err;
}
{
printf("Unable to destroy camera list. Aborting with error %d...\n\n", err);
return err;
}
{
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;
}