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.
#include <iostream>
#include <sstream>
using namespace Spinnaker;
using namespace Spinnaker::GenApi;
using namespace Spinnaker::GenICam;
using namespace std;
{
int result = 0;
cout << endl << endl << "*** CONFIGURING CUSTOM IMAGE SETTINGS ***" << endl << endl;
try
{
{
cout << "Pixel format set to " << pCam->PixelFormat.GetCurrentEntry()->GetSymbolic() << "..." << endl;
}
else
{
cout << "Pixel format not available..." << endl;
result = -1;
}
{
pCam->OffsetX.SetValue(pCam->OffsetX.GetMin());
cout << "Offset X set to " << pCam->OffsetX.GetValue() << "..." << endl;
}
else
{
cout << "Offset X not available..." << endl;
result = -1;
}
{
pCam->OffsetY.SetValue(pCam->OffsetY.GetMin());
cout << "Offset Y set to " << pCam->OffsetY.GetValue() << "..." << endl;
}
else
{
cout << "Offset Y not available..." << endl;
result = -1;
}
pCam->Width.GetMax() != 0)
{
pCam->Width.SetValue(pCam->Width.GetMax());
cout << "Width set to " << pCam->Width.GetValue() << "..." << endl;
}
else
{
cout << "Width not available..." << endl;
result = -1;
}
pCam->Height.GetMax() != 0)
{
pCam->Height.SetValue(pCam->Height.GetMax());
cout << "Height set to " << pCam->Height.GetValue() << "..." << endl;
}
else
{
cout << "Height not available..." << endl;
result = -1;
}
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << endl << "*** DEVICE INFORMATION ***" << endl << endl;
try
{
INodeMap& nodeMap = pCam->GetTLDeviceNodeMap();
FeatureList_t features;
CCategoryPtr category = nodeMap.GetNode(
"DeviceInformation");
{
category->GetFeatures(features);
FeatureList_t::const_iterator it;
for (it = features.begin(); it != features.end(); ++it)
{
cout << pfeatureNode->GetName() << " : ";
cout << (
IsReadable(pValue) ? pValue->ToString() :
"Node not readable");
cout << endl;
}
}
else
{
cout << "Device control information not readable." << endl;
}
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << endl << "*** IMAGE ACQUISITION ***" << endl << endl;
try
{
{
cout << "Unable to set acquisition mode to continuous. Aborting..." << endl << endl;
return -1;
}
cout << "Acquisition mode set to continuous..." << endl;
pCam->BeginAcquisition();
cout << "Acquiring images..." << endl;
{
deviceSerialNumber = pCam->DeviceSerialNumber.GetValue();
cout << "Device serial number retrieved as " << deviceSerialNumber << "..." << endl;
}
cout << endl;
for (
unsigned int imageCnt = 0; imageCnt <
k_numImages; imageCnt++)
{
try
{
ImagePtr pResultImage = pCam->GetNextImage(1000);
if (pResultImage->IsIncomplete())
{
cout << "Image incomplete with image status " << pResultImage->GetImageStatus() << "..." << endl
<< endl;
}
else
{
cout << "Grabbed image " << imageCnt << ", width = " << pResultImage->GetWidth()
<< ", height = " << pResultImage->GetHeight() << endl;
ostringstream filename;
filename << "ImageFormatControlQS-";
if (deviceSerialNumber != "")
{
filename << deviceSerialNumber.c_str() << "-";
}
filename << imageCnt << ".jpg";
convertedImage->Save(filename.str().c_str());
cout << "Image saved at " << filename.str() << endl;
}
pResultImage->Release();
cout << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
}
pCam->EndAcquisition();
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
try
{
pCam->Init();
pCam->DeInit();
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << "Application build date: " << __DATE__ << " " << __TIME__ << endl << endl;
const LibraryVersion spinnakerLibraryVersion = system->GetLibraryVersion();
cout <<
"Spinnaker library version: " << spinnakerLibraryVersion.
major <<
"." << spinnakerLibraryVersion.
minor
<<
"." << spinnakerLibraryVersion.
type <<
"." << spinnakerLibraryVersion.
build << endl
<< endl;
unsigned int numCameras = camList.
GetSize();
cout << "Number of cameras detected: " << numCameras << endl << endl;
if (numCameras == 0)
{
system->ReleaseInstance();
cout << "Not enough cameras!" << endl;
cout << "Done! Press Enter to exit..." << endl;
getchar();
return -1;
}
for (unsigned int i = 0; i < numCameras; i++)
{
cout << endl << "Running example for camera " << i << "..." << endl;
cout << "Camera " << i << " example complete..." << endl << endl;
}
system->ReleaseInstance();
cout << endl << "Done! Press Enter to exit..." << endl;
getchar();
return result;
}