A logic block is a collection of combinatorial logic and latches that allows users to create new, custom signals inside the camera. These custom signals can be used by the camera (for example to trigger exposure) or sent out to integrate with external systems.
#include <iostream>
#include <sstream>
using namespace std;
{
cout << endl << endl << "*** CONFIGURING TRIGGER ***" << endl << endl;
int result = 0;
try
{
if (!IsReadable(ptrTriggerMode) ||
!IsWritable(ptrTriggerMode))
{
cout << "Unable to disable trigger mode (node retrieval). Aborting..." << endl;
return -1;
}
CEnumEntryPtr ptrTriggerModeOff = ptrTriggerMode->GetEntryByName(
"Off");
if (!IsReadable(ptrTriggerModeOff))
{
cout << "Unable to disable trigger mode (enum entry retrieval). Aborting..." << endl;
return -1;
}
ptrTriggerMode->SetIntValue(ptrTriggerModeOff->GetValue());
cout << "Trigger mode disabled..." << endl;
if (!IsReadable(ptrTriggerSource) ||
!IsWritable(ptrTriggerSource))
{
cout << "Unable to set trigger mode (node retrieval). Aborting..." << endl;
return -1;
}
CEnumEntryPtr ptrTriggerSourceLogicBlock0 = ptrTriggerSource->GetEntryByName(
"LogicBlock0");
if (!IsReadable(ptrTriggerSourceLogicBlock0))
{
cout << "Unable to set trigger mode (enum entry retrieval). Aborting..." << endl;
return -1;
}
ptrTriggerSource->SetIntValue(ptrTriggerSourceLogicBlock0->GetValue());
cout << "Trigger source set to software..." << endl;
CEnumerationPtr ptrTriggerActivation = nodeMap.GetNode(
"TriggerActivation");
if (!IsReadable(ptrTriggerActivation) ||
!IsWritable(ptrTriggerActivation))
{
cout << "Unable to get or set trigger activation (enum retrieval). Aborting..." << endl;
return -1;
}
CEnumEntryPtr ptrTriggerActivationLH = ptrTriggerActivation->GetEntryByName(
"LevelHigh");
if (!IsReadable(ptrTriggerActivationLH))
{
cout << "Unable to get trigger mode ( entry retrieval). Aborting..." << endl;
return -1;
}
ptrTriggerActivation->SetIntValue(ptrTriggerActivationLH->GetValue());
cout << "Trigger activation set to level high..." << endl;
CEnumEntryPtr ptrTriggerModeOn = ptrTriggerMode->GetEntryByName(
"On");
if (!IsReadable(ptrTriggerModeOn))
{
cout << "Unable to enable trigger mode (enum entry retrieval). Aborting..." << endl;
return -1;
}
ptrTriggerMode->SetIntValue(ptrTriggerModeOn->GetValue());
cout << "Trigger mode turned back on..." << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
cout << endl << endl << "*** CONFIGURING LOGIC BLOCKS ***" << endl << endl;
CEnumerationPtr ptrLogicBlockSelector = nodeMap.GetNode(
"LogicBlockSelector");
if (!IsReadable(ptrLogicBlockSelector) ||
!IsWritable(ptrLogicBlockSelector))
{
cout << "Unable to get or set logic block selector to Logic Block 0 (node retrieval). Non-fatal error..." << endl;
return -1;
}
CEnumEntryPtr ptrLogicBlock0 = ptrLogicBlockSelector->GetEntryByName(
"LogicBlock0");
{
cout << "Unable to get logic block selector to Logic Block 0 (enum entry retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLogicBlockSelector->SetIntValue(ptrLogicBlock0->GetValue());
cout << "Logic Block 0 selected...." << endl;
CEnumerationPtr ptrLBLUTSelector = nodeMap.GetNode(
"LogicBlockLUTSelector");
{
cout << "Unable to get or set LUT logic block selector to Enable (node retrieval). Non-fatal error..." << endl;
return -1;
}
CEnumEntryPtr ptrLBLUTEnable = ptrLBLUTSelector->GetEntryByName(
"Enable");
{
cout << "Unable to get LUT logic block selector to Enable (enum entry retrieval). Non-fatal error..." << endl;
return -1;
}
ptrLBLUTSelector->SetIntValue(ptrLBLUTEnable->GetValue());
cout << "Logic Block LUT set to to Enable..." << endl;
CIntegerPtr ptrLBLUTOutputValueAll = nodeMap.GetNode(
"LogicBlockLUTOutputValueAll");
{
cout << "Unable to set value to LUT logic block output value all (integer retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLBLUTOutputValueAll->SetValue(252);
cout << "Logic Block LUT Output Value All set to to OxFC..." << endl;
CEnumerationPtr ptrLBLUTInputSelector = nodeMap.GetNode(
"LogicBlockLUTInputSelector");
{
cout << "Unable to get or set LUT logic block input selector to Input 0 (node retrieval). Non-fatal error..." << endl;
return -1;
}
CEnumEntryPtr ptrLBLUTInput0 = ptrLBLUTInputSelector->GetEntryByName(
"Input0");
{
cout << "Unable to get LUT logic block selector to Input 0 (enum entry retrieval). Non-fatal error..." << endl;
return -1;
}
ptrLBLUTInputSelector->SetIntValue(ptrLBLUTInput0->GetValue());
cout << "Logic Block LUT Input Selector set to to Input 0 ..." << endl;
CEnumerationPtr ptrLBLUTSource = nodeMap.GetNode(
"LogicBlockLUTInputSource");
{
cout << "Unable to get or set LUT logic block input source to Frame Trigger Wait (node retrieval). Non-fatal error..."
<< endl;
return -1;
}
CEnumEntryPtr ptrLBLUTSourceFTW = ptrLBLUTSource->GetEntryByName(
"FrameTriggerWait");
{
cout << "Unable to get LUT logic block input source to Frame Trigger Wait (enum entry retrieval). Non-fatal "
"error..."
<< endl;
return -1;
}
ptrLBLUTSource->SetIntValue(ptrLBLUTSourceFTW->GetValue());
cout << "Logic Block LUT Input Source set to to Frame Trigger Wait ..." << endl;
CEnumerationPtr ptrLBLUTActivation = nodeMap.GetNode(
"LogicBlockLUTInputActivation");
{
cout << "Unable to get or set LUT logic block input activation to level high (node retrieval). Non-fatal error..."
<< endl;
return -1;
}
CEnumEntryPtr ptrLBLUTActivationLevelHigh = ptrLBLUTActivation->GetEntryByName(
"LevelHigh");
{
cout
<< "Unable to get LUT logic block input activation to level high (enum entry retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLBLUTActivation->SetIntValue(ptrLBLUTActivationLevelHigh->GetValue());
cout << "Logic Block LUT Input Activation set to level high..." << endl;
CEnumEntryPtr ptrLBLUTInput1 = ptrLBLUTInputSelector->GetEntryByName(
"Input1");
{
cout << "Unable to get LUT logic block Input selector to input 1 (enum entry retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLBLUTInputSelector->SetIntValue(ptrLBLUTInput1->GetValue());
cout << "Logic Block LUT Input Selector set to to Input 1 ..." << endl;
CEnumEntryPtr ptrLBLUTSourceUO0 = ptrLBLUTSource->GetEntryByName(
"UserOutput0");
{
cout << "Unable to get LUT logic block input source to User Output 0 (enum entry retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLBLUTSource->SetIntValue(ptrLBLUTSourceUO0->GetValue());
cout << "Logic Block LUT Input Source set to to User Output 0 ..." << endl;
CEnumEntryPtr ptrLBLUTActivationRisingEdge = ptrLBLUTActivation->GetEntryByName(
"RisingEdge");
{
cout << "Unable to get LUT logic block input activation to Rising Edge (enum entry retrieval). Non-fatal "
"error..."
<< endl;
return -1;
}
ptrLBLUTActivation->SetIntValue(ptrLBLUTActivationRisingEdge->GetValue());
cout << "Logic Block LUT Input Activation set to Rising Edge..." << endl;
CEnumEntryPtr ptrLBLUTInput2 = ptrLBLUTInputSelector->GetEntryByName(
"Input2");
{
cout << "Unable to get LUT logic block selector to input 2 (enum entry retrieval). Non-fatal error..." << endl;
return -1;
}
ptrLBLUTInputSelector->SetIntValue(ptrLBLUTInput2->GetValue());
cout << "Logic Block LUT Input Selector set to to Input 2 ..." << endl;
CEnumEntryPtr ptrLBLUTSourceExposureStart = ptrLBLUTSource->GetEntryByName(
"ExposureStart");
{
cout
<< "Unable to get LUT logic block input source to Exposure Start (enum entry retrieval). Non-fatal error..."
<< endl;
return -1;
}
ptrLBLUTSource->SetIntValue(ptrLBLUTSourceExposureStart->GetValue());
cout << "Logic Block LUT Input Source set to to Exposure Start ..." << endl;
ptrLBLUTActivation->SetIntValue(ptrLBLUTActivationRisingEdge->GetValue());
cout << "Logic Block LUT Input Activation set to Rising Edge..." << endl;
CEnumEntryPtr ptrLBLUTValue = ptrLBLUTSelector->GetEntryByName(
"Value");
{
cout << "Unable to get LUT logic block selector to Value (enum entry retrieval). Non-fatal error..." << endl;
return -1;
}
ptrLBLUTSelector->SetIntValue(ptrLBLUTValue->GetValue());
cout << "Logic Block LUT set to to Value..." << endl;
ptrLBLUTOutputValueAll->SetValue(76);
cout << "Logic Block LUT Output Value All set to to Ox4C..." << endl << endl;
return 0;
}
{
int result = 0;
try
{
CEnumerationPtr ptrUserOutputSelector = nodeMap.GetNode(
"UserOutputSelector");
{
cout << "Unable to get or set User Output Selector (enum retrieval). Aborting..." << endl;
return -1;
}
CEnumEntryPtr ptrUserOutput0 = ptrUserOutputSelector->GetEntryByName(
"UserOutput0");
{
cout << "Unable to get User Output Selector (entry retrieval). Aborting..." << endl;
return -1;
}
ptrUserOutputSelector->SetIntValue(ptrUserOutput0->GetValue());
CBooleanPtr ptrUserOutputValue = nodeMap.GetNode(
"UserOutputValue");
{
cout << "Unable to set User Output value (boolean retrieval). Aborting..." << endl;
return -1;
}
ptrUserOutputValue->SetValue(false);
ptrUserOutputValue->SetValue(true);
ptrUserOutputValue->SetValue(false);
ptrUserOutputValue->SetValue(true);
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
try
{
{
cout << "Unable to disable trigger mode (node retrieval). Non-fatal error..." << endl;
return -1;
}
CEnumEntryPtr ptrTriggerModeOff = ptrTriggerMode->GetEntryByName(
"Off");
{
cout << "Unable to disable trigger mode (enum entry retrieval). Non-fatal error..." << endl;
return -1;
}
ptrTriggerMode->SetIntValue(ptrTriggerModeOff->GetValue());
cout << "Trigger mode disabled..." << endl << endl;
}
{
cout <<
"Error: " << e.
what() << endl;
result = -1;
}
return result;
}
{
int result = 0;
try
{
{
cout << "Unable to enable automatic exposure (node retrieval). Non-fatal error..." << endl << endl;
return -1;
}
CEnumEntryPtr ptrExposureAutoContinuous = ptrExposureAuto->GetEntryByName(
"Continuous");
{
cout << "Unable to enable automatic exposure (enum entry retrieval). Non-fatal error..." << endl << endl;
return -1;
}
ptrExposureAuto->SetIntValue(ptrExposureAutoContinuous->GetValue());
cout << "Automatic exposure enabled..." << endl << 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 get or set acquisition mode to continuous (node retrieval). Aborting..." << endl << endl;
return -1;
}
CEnumEntryPtr ptrAcquisitionModeContinuous = ptrAcquisitionMode->GetEntryByName(
"Continuous");
{
cout << "Unable to get 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;
{
cout << "Unable to get or set Exposure Auto (enum retrieval). Aborting...." << endl;
return -1;
}
CEnumEntryPtr ptrExposureAutoEntry = ptrExposureAuto->GetEntryByName(
"Off");
{
cout << "Unable to get Exposure Auto (enum entry Retrieval). Aborting..." << endl;
}
ptrExposureAuto->SetIntValue(ptrExposureAutoEntry->GetValue());
CFloatPtr ptrExposureTime = nodeMap.GetNode(
"ExposureTime");
{
cout << "Unable to set Exposure Time (float retrieaval). Aborting...";
}
ptrExposureTime->SetValue(500000);
pCam->BeginAcquisition();
pCam->EndAcquisition();
pCam->BeginAcquisition();
cout << "Acquiring images..." << endl;
CStringPtr ptrStringSerial = nodeMapTLDevice.GetNode(
"DeviceSerialNumber");
{
deviceSerialNumber = ptrStringSerial->GetValue();
cout << "Device serial number retrieved as " << deviceSerialNumber << "..." << endl;
}
cout << endl;
unsigned int imageCnt = 0;
{
try
{
for (unsigned int imageCntb = 0; imageCntb < 2; imageCntb++)
{
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;
ImagePtr convertedImage = processor.
Convert(pResultImage, PixelFormat_Mono8);
ostringstream filename;
filename << "LogicBlock-";
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;
imageCnt++;
}
}
{
cout <<
"Error: " << e.
what() << endl << endl;
result = -1;
}
}
pCam->EndAcquisition();
}
{
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 == NULL)
{
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;
}
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 ResetTrigger(INodeMap &nodeMap)
Definition BufferHandling.cpp:197
int ResetExposure(INodeMap &nodeMap)
Definition Exposure.cpp:143
int GrabTwoImages(INodeMap &nodeMap, CameraPtr pCam)
Definition LogicBlock.cpp:364
int ConfigureLogicBlock(INodeMap &nodeMap)
Definition LogicBlock.cpp:148
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().
SmartPointer for IFloat interface pointer.
Definition Pointer.h:421
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:658
unsigned int minor
Minor version of the library.
Definition SpinnakerDefs.h:663
unsigned int major
Major version of the library.
Definition SpinnakerDefs.h:660
unsigned int type
Version type of the library.
Definition SpinnakerDefs.h:666
unsigned int build
Build number of the library.
Definition SpinnakerDefs.h:669