It can also be helpful to familiarize yourself with the ImageFormatControl and Exposure examples. As they are somewhat shorter and simpler, either provides a strong introduction to camera customization.
Chunk data provides information on various traits of an image. This includes identifiers such as frame ID, properties such as black level, and more. This information can be acquired from either the nodemap or the image itself.
It may be preferable to grab chunk data from each individual image, as it can be hard to verify whether data is coming from the correct image when using the nodemap. This is because chunk data retrieved from the nodemap is only valid for the current image; when GetNextImage() is called, chunk data will be updated to that of the new current image.
#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 CHUNK DATA ***" << endl << endl;
try
{
CBooleanPtr ptrChunkModeActive = nodeMap.GetNode(
"ChunkModeActive");
{
cout << "Unable to activate chunk mode. Aborting..." << endl << endl;
return -1;
}
ptrChunkModeActive->SetValue(true);
cout << "Chunk mode activated..." << endl;
{
cout << "Unable to retrieve chunk selector. Aborting..." << endl << endl;
return -1;
}
ptrChunkSelector->GetEntries(entries);
cout << "Enabling entries..." << endl;
for (size_t i = 0; i < entries.size(); i++)
{
{
continue;
}
ptrChunkSelector->SetIntValue(ptrChunkSelectorEntry->GetValue());
cout << "\t" << ptrChunkSelectorEntry->GetSymbolic() << ": ";
CBooleanPtr ptrChunkEnable = nodeMap.GetNode(
"ChunkEnable");
{
cout << "not available" << endl;
result = -1;
}
else if (ptrChunkEnable->GetValue())
{
cout << "enabled" << endl;
}
{
ptrChunkEnable->SetValue(true);
cout << "enabled" << endl;
}
else
{
cout << "not writable" << endl;
result = -1;
}
}
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << "Printing chunk data from image..." << endl;
try
{
ChunkData chunkData = pImage->GetChunkData();
std::cout << "\tExposure time: " << exposureTime << endl;
cout << "\tFrame ID: " << frameID << endl;
cout << "\tGain: " << gain << endl;
cout << "\tHeight: " << height << endl;
cout << "\tOffset X: " << offsetX << endl;
cout << "\tOffset Y: " << offsetY << endl;
cout << "\tSequencer set active: " << sequencerSetActive << endl;
cout << "\tTimestamp: " << timestamp << endl;
cout << "\tWidth: " << width << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << "Printing chunk data from nodemap..." << endl;
try
{
CCategoryPtr ptrChunkDataControl = nodeMap.GetNode(
"ChunkDataControl");
{
cout << "Unable to retrieve chunk data control. Aborting..." << endl << endl;
return -1;
}
FeatureList_t features;
ptrChunkDataControl->GetFeatures(features);
FeatureList_t::const_iterator it;
for (it = features.begin(); it != features.end(); ++it)
{
{
cout << "node not readable" << endl;
result = result | -1;
continue;
}
else if (pFeature->GetPrincipalInterfaceType() ==
intfIBoolean)
{
cout << "\t" << pFeature->GetDisplayName() << ": ";
bool value = pBool->GetValue();
cout << (value ? "true" : "false") << endl;
}
else
{
cout << pValue->ToString() << endl;
}
}
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
cout << endl << "*** DEVICE INFORMATION ***" << endl << endl;
try
{
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 << endl << "*** IMAGE ACQUISITION ***" << endl << endl;
try
{
{
cout << "Unable to set acquisition mode to continuous (node retrieval). Aborting..." << endl << endl;
return -1;
}
CEnumEntryPtr ptrAcquisitionModeContinuous = ptrAcquisitionMode->GetEntryByName(
"Continuous");
{
cout << "Unable to set acquisition mode to continuous (entry 'continuous' retrieval). Aborting..." << endl
<< endl;
return -1;
}
int64_t acquisitionModeContinuous = ptrAcquisitionModeContinuous->GetValue();
ptrAcquisitionMode->SetIntValue(acquisitionModeContinuous);
cout << "Acquisition mode set to continuous..." << endl;
pCam->BeginAcquisition();
cout << "Acquiring images..." << endl;
CStringPtr ptrStringSerial = nodeMapTLDevice.GetNode(
"DeviceSerialNumber");
{
deviceSerialNumber = ptrStringSerial->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 << "ChunkData-";
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
{
{
cout << "Unable to retrieve chunk selector. Aborting..." << endl << endl;
return -1;
}
ptrChunkSelector->GetEntries(entries);
cout << "Disabling entries..." << endl;
for (size_t i = 0; i < entries.size(); i++)
{
{
continue;
}
ptrChunkSelector->SetIntValue(ptrChunkSelectorEntry->GetValue());
cout << "\t" << ptrChunkSelectorEntry->GetSymbolic() << ": ";
CBooleanPtr ptrChunkEnable = nodeMap.GetNode(
"ChunkEnable");
{
cout << "not available" << endl;
result = -1;
}
else if (!ptrChunkEnable->GetValue())
{
cout << "disabled" << endl;
}
{
ptrChunkEnable->SetValue(false);
cout << "disabled" << endl;
}
else
{
cout << "not writable" << endl;
}
}
cout << endl;
CBooleanPtr ptrChunkModeActive = nodeMap.GetNode(
"ChunkModeActive");
{
cout << "Unable to deactivate chunk mode. Aborting..." << endl << endl;
return -1;
}
ptrChunkModeActive->SetValue(false);
cout << "Chunk mode deactivated..." << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
int err = 0;
try
{
INodeMap& nodeMapTLDevice = pCam->GetTLDeviceNodeMap();
pCam->Init();
if (err < 0)
{
return err;
}
if (err < 0)
{
return err;
}
pCam->DeInit();
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
FILE* tempFile = fopen("test.txt", "w+");
if (tempFile == nullptr)
{
cout << "Failed to create file in current folder. Please check "
"permissions."
<< endl;
cout << "Press Enter to exit..." << endl;
getchar();
return -1;
}
fclose(tempFile);
remove("test.txt");
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;
}