This example demonstrates how to prepare, execute, and clean up the camera in regards to using both software and hardware triggers. Retrieving and setting node values using QuickSpin is the only portion of the example that differs from Trigger.
#include <iostream>
#include <sstream>
using namespace std;
{
};
{
int result = 0;
cout << endl << endl << "*** CONFIGURING TRIGGER ***" << endl << endl;
cout << "Note that if the application / user software triggers faster than frame time, the trigger may be dropped "
"/ skipped by the camera."
<< endl
<< "If several frames are needed per trigger, a more reliable alternative for such case, is to use the "
"multi-frame mode."
<< endl
<< endl;
try
{
{
cout << "Software trigger chosen..." << endl;
}
else
{
cout << "Hardware trigger chosen..." << endl;
}
{
cout << "Unable to disable trigger mode. Aborting..." << endl;
return -1;
}
pCam->TriggerMode.SetValue(TriggerMode_Off);
cout << "Trigger mode disabled..." << endl;
{
cout << "Unable to set trigger selector (node retrieval). Aborting..." << endl;
return -1;
}
pCam->TriggerSelector.SetValue(TriggerSelector_FrameStart);
cout << "Trigger selector set to frame start..." << endl;
{
{
cout << "Unable to set trigger mode (node retrieval). Aborting..." << endl;
return -1;
}
pCam->TriggerSource.SetValue(TriggerSource_Software);
cout << "Trigger source set to software..." << endl;
}
else
{
{
cout << "Unable to set trigger mode (node retrieval). Aborting..." << endl;
return -1;
}
pCam->TriggerSource.SetValue(TriggerSource_Line0);
cout << "Trigger source set to hardware..." << endl;
}
{
cout << "Unable to disable trigger mode. Aborting..." << endl;
return -1;
}
pCam->TriggerMode.SetValue(TriggerMode_On);
cout << "Trigger mode turned back on..." << endl << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
try
{
{
cout << "Press the Enter key to initiate software trigger." << endl;
getchar();
{
cout << "Unable to execute trigger..." << endl;
return -1;
}
pCam->TriggerSoftware.Execute();
}
else
{
cout << "Use the hardware to trigger image acquisition." << endl;
}
pResultImage = pCam->GetNextImage(1000);
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
try
{
{
cout << "Unable to disable trigger mode. Aborting..." << endl;
return -1;
}
pCam->TriggerMode.SetValue(TriggerMode_Off);
cout << "Trigger mode disabled..." << endl << endl;
}
{
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;
}
pCam->AcquisitionMode.SetValue(AcquisitionMode_Continuous);
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
{
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;
ImagePtr convertedImage = processor.
Convert(pResultImage, PixelFormat_Mono8);
ostringstream filename;
filename << "TriggerQS-";
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;
}
int AcquireImages(CameraPtr pCam, INodeMap &nodeMap, INodeMap &nodeMapTLDevice)
Definition Acquisition.cpp:199
int main(int, char **)
Definition Acquisition.cpp:527
int RunSingleCamera(CameraPtr pCam)
Definition Acquisition.cpp:479
int PrintDeviceInfo(INodeMap &nodeMap)
Definition Acquisition.cpp:441
const unsigned int k_numImages
Definition AcquisitionMultipleCamerasWriteToFile.cpp:55
int ConfigureTrigger(INodeMap &nodeMap)
Definition BufferHandling.cpp:103
int GrabNextImageByTrigger(INodeMap &nodeMap)
Definition BufferHandling.cpp:170
int ResetTrigger(INodeMap &nodeMap)
Definition BufferHandling.cpp:197
triggerType
Definition Trigger.cpp:49
@ SOFTWARE
Definition Trigger.cpp:50
@ HARDWARE
Definition Trigger.cpp:51
const triggerType chosenTrigger
Definition Trigger.cpp:54
Used to hold a list of camera objects.
Definition CameraList.h:42
void Clear()
Clears the list of cameras and destroys their corresponding reference counted objects.
CameraPtr GetByIndex(unsigned int index) const
Returns a pointer to a camera object at the "index".
unsigned int GetSize() const
Returns the size of the camera list.
A reference tracked pointer to a camera object.
Definition CameraPtr.h:44
The Exception object represents an error that is returned from the library.
Definition Exception.h:51
virtual const char * what() const
virtual override for what().
Encapsulates a GenApi pointer dealing with the dynamic_cast automatically.
Definition Pointer.h:75
Image post processing class for converting a source image to another pixel format.
Definition ImageProcessor.h:159
void SetColorProcessing(ColorProcessingAlgorithm colorAlgorithm)
Sets the color processing algorithm used at the time of the Convert() call, therefore the most recent...
ImagePtr Convert(const ImagePtr &srcImage, PixelFormatEnums destFormat) const
Converts the source image buffer to the specified destination pixel format and returns the result in ...
A reference tracked pointer to an image object.
Definition ImagePtr.h:46
A reference tracked pointer to a system object.
Definition SystemPtr.h:44
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition INode.h:277
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition INode.h:253
interface SPINNAKER_API_ABSTRACT INodeMap
Interface to access the node map.
Definition INodeMap.h:54
Definition Autovector.h:36
Provides easier access to the current version of Spinnaker.
Definition SpinnakerDefs.h:657
unsigned int minor
Minor version of the library.
Definition SpinnakerDefs.h:662
unsigned int major
Major version of the library.
Definition SpinnakerDefs.h:659
unsigned int type
Version type of the library.
Definition SpinnakerDefs.h:665
unsigned int build
Build number of the library.
Definition SpinnakerDefs.h:668