The following sections list the code samples that are part of the pylon SDK.
The pylon samples can be found under <SDK ROOT>\Samples. There is a GNU make file available for each sample.
Include Files Used by Samples
The following include files are used by the samples shown below.
CameraEventPrinter.h
#ifndef INCLUDED_CAMERAEVENTPRINTER_H_4683453
#define INCLUDED_CAMERAEVENTPRINTER_H_4683453
#include <iostream>
{
class CInstantCamera;
class CCameraEventPrinter : public CCameraEventHandler
{
public:
virtual void OnCameraEvent( CInstantCamera& camera, intptr_t userProvidedId,
GenApi::INode* pNode)
{
std::cout << "OnCameraEvent event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
std::cout << "User provided ID: " << userProvidedId << std::endl;
std::cout <<
"Event data node name: " << pNode->
GetName() << std::endl;
CParameter value( pNode );
if ( value.IsValid() )
{
std::cout << "Event node data: " << value.ToString() << std::endl;
}
std::cout << std::endl;
}
};
}
#endif
ConfigurationEventPrinter.h
#ifndef INCLUDED_CONFIGURATIONEVENTPRINTER_H_663006
#define INCLUDED_CONFIGURATIONEVENTPRINTER_H_663006
#include <iostream>
{
class CInstantCamera;
class CConfigurationEventPrinter : public CConfigurationEventHandler
{
public:
void OnAttach( CInstantCamera& )
{
std::cout << "OnAttach event" << std::endl;
}
void OnAttached( CInstantCamera& camera)
{
std::cout << "OnAttached event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnOpen( CInstantCamera& camera)
{
std::cout << "OnOpen event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnOpened( CInstantCamera& camera)
{
std::cout << "OnOpened event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnGrabStart( CInstantCamera& camera)
{
std::cout << "OnGrabStart event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnGrabStarted( CInstantCamera& camera)
{
std::cout << "OnGrabStarted event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnGrabStop( CInstantCamera& camera)
{
std::cout << "OnGrabStop event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnGrabStopped( CInstantCamera& camera)
{
std::cout << "OnGrabStopped event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnClose( CInstantCamera& camera)
{
std::cout << "OnClose event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnClosed( CInstantCamera& camera)
{
std::cout << "OnClosed event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnDestroy( CInstantCamera& camera)
{
std::cout << "OnDestroy event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnDestroyed( CInstantCamera& )
{
std::cout << "OnDestroyed event" << std::endl;
}
void OnDetach( CInstantCamera& camera)
{
std::cout << "OnDetach event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnDetached( CInstantCamera& camera)
{
std::cout << "OnDetached event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
void OnGrabError( CInstantCamera& camera, const char* errorMessage)
{
std::cout << "OnGrabError event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
std::cout << "Error Message: " << errorMessage << std::endl;
}
void OnCameraDeviceRemoved( CInstantCamera& camera)
{
std::cout << "OnCameraDeviceRemoved event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
}
};
}
#endif
ImageEventPrinter.h
#ifndef INCLUDED_IMAGEEVENTPRINTER_H_7884943
#define INCLUDED_IMAGEEVENTPRINTER_H_7884943
#include <iostream>
{
class CInstantCamera;
class CImageEventPrinter : public CImageEventHandler
{
public:
virtual void OnImagesSkipped( CInstantCamera& camera, size_t countOfSkippedImages)
{
std::cout << "OnImagesSkipped event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
std::cout << countOfSkippedImages << " images have been skipped." << std::endl;
std::cout << std::endl;
}
virtual void OnImageGrabbed( CInstantCamera& camera, const CGrabResultPtr& ptrGrabResult)
{
std::cout << "OnImageGrabbed event for device " << camera.GetDeviceInfo().GetModelName() << std::endl;
if (ptrGrabResult->GrabSucceeded())
{
std::cout << "SizeX: " << ptrGrabResult->GetWidth() << std::endl;
std::cout << "SizeY: " << ptrGrabResult->GetHeight() << std::endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->GetBuffer();
std::cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << std::endl;
std::cout << std::endl;
}
else
{
std::cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription() << std::endl;
}
}
};
}
#endif
PixelFormatAndAoiConfiguration.h
#ifndef INCLUDED_PIXELFORMATANDAOICONFIGURATION_H_00104928
#define INCLUDED_PIXELFORMATANDAOICONFIGURATION_H_00104928
{
class CInstantCamera;
}
{
public:
{
try
{
offsetX.TrySetToMinimum();
offsetY.TrySetToMinimum();
width.SetToMaximum();
height.SetToMaximum();
}
{
throw RUNTIME_EXCEPTION(
"Could not apply configuration. const GenericException caught in OnOpened method msg=%hs", e.
what());
}
}
};
#endif
SampleImageCreator.h
#ifndef INCLUDED_SAMPLEIMAGECREATOR_H_2792867
#define INCLUDED_SAMPLEIMAGECREATOR_H_2792867
namespace SampleImageCreator
{
{
{
{0, 28, 50}, {0, 42, 75}, {0, 56, 100}, {0, 70, 125}, {0, 84, 150},
{0, 50, 0}, {0, 100, 0}, {0, 150, 0}, {0, 200, 0}, {0, 250, 0},
{50, 0, 0}, {100, 0, 0}, {150, 0, 0}, {200, 0, 0}, {250, 0, 0}
};
uint32_t numColors = sizeof( palette) / sizeof( palette[0]);
const double cX = -0.735;
const double cY = 0.11;
const double cMaxX = 1.6;
const double cMinX = -1.6;
const double cMaxY = 1;
const double cMinY = -1;
const uint32_t cMaxIterations = 50;
for ( uint32_t pixelY = 0; pixelY < height; ++pixelY )
{
for ( uint32_t pixelX = 0; pixelX < width; ++pixelX, ++pCurrentPixel )
{
long double x = ((cMaxX-cMinX) / width) * pixelX + cMinX;
long double y = cMaxY - pixelY * ((cMaxY-cMinY) / height);
long double xd = 0;
long double yd = 0;
uint32_t i = 0;
for(; i < cMaxIterations; ++i)
{
xd = x * x - y * y + cX;
yd = 2 *x * y + cY;
x = xd;
y = yd;
if ( (x * x + y * y) > 4 )
{
break;
}
}
if ( i >= cMaxIterations)
{
*pCurrentPixel = palette[0];
}
else
{
*pCurrentPixel = palette[ i % numColors ];
}
}
}
if ( juliaFractal.GetPixelType() != pixelType)
{
}
return juliaFractal;
}
{
{
{0, 28, 50}, {0, 42, 75}, {0, 56, 100}, {0, 70, 125}, {0, 84, 150},
{0, 50, 0}, {0, 100, 0}, {0, 150, 0}, {0, 200, 0}, {0, 250, 0},
{50, 0, 0}, {100, 0, 0}, {150, 0, 0}, {200, 0, 0}, {250, 0, 0}
};
uint32_t numColors = sizeof( palette) / sizeof( palette[0]);
const double cMaxX = 1.0;
const double cMinX = -2.0;
const double cMaxY = 1.2;
const double cMinY = -1.2;
const uint32_t cMaxIterations = 50;
for ( uint32_t pixelY = 0; pixelY < height; ++pixelY )
{
for ( uint32_t pixelX = 0; pixelX < width; ++pixelX, ++pCurrentPixel )
{
long double xStart = ((cMaxX-cMinX) / width) * pixelX + cMinX;
long double yStart = cMaxY - pixelY * ((cMaxY-cMinY) / height);
long double x = xStart;
long double y = yStart;
long double xd =0;
long double yd =0;
uint32_t i = 0;
for(; i < cMaxIterations; ++i)
{
xd = x * x - y * y + xStart;
yd = 2 *x * y + yStart;
x = xd;
y = yd;
if ( (x * x + y * y) > 4 )
{
break;
}
}
if ( i >= cMaxIterations)
{
*pCurrentPixel = palette[0];
}
else
{
*pCurrentPixel = palette[ i % numColors ];
}
}
}
if ( mandelbrotFractal.GetPixelType() != pixelType)
{
}
return mandelbrotFractal;
}
}
#endif
DeviceRemovalHandling
#include "../include/ConfigurationEventPrinter.h"
using namespace std;
{
public:
{
cout << endl << endl;
cout << "CSampleConfigurationEventHandler::OnCameraDeviceRemoved called." << std::endl;
}
};
static const uint32_t c_loopCounterInitialValue = 60 * 4;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
int loopCount = 0;
cout << endl;
loopCount = c_loopCounterInitialValue;
cout << endl << "Please disconnect the device (timeout " << loopCount / 4 << "s) " << endl;
try
{
while ( loopCount > 0)
{
if (--loopCount % 4 == 0)
{
cout << ".";
cout.flush();
}
width.SetValue( width.GetMax() - (width.GetInc() * (loopCount % 2)));
}
}
{
{
cout << endl;
cout << "The camera has been removed from the computer." << endl;
cout << "The camera device removal triggered an expected exception:" << endl
}
else
{
throw;
}
}
cout << endl << "Timeout expired" << endl;
loopCount = c_loopCounterInitialValue;
cout << endl << "Please connect the same device to the computer again (timeout " << loopCount / 4 << "s) " << endl;
filter.push_back( info);
for ( ; loopCount > 0; --loopCount)
{
if ( loopCount % 4 == 0)
{
cout << ".";
cout.flush();
}
{
cout << endl << endl;
break;
}
}
{
cout << endl;
cout << endl;
}
else
{
cout << endl << "Timeout expired." << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
{
cout <<
"SizeX: " << ptrGrabResult->
GetWidth() << endl;
cout <<
"SizeY: " << ptrGrabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
}
else
{
}
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_CameraEvents
#include "../include/ConfigurationEventPrinter.h"
#include "../include/CameraEventPrinter.h"
using namespace std;
enum MyEvents
{
eMyExposureEndEvent = 100,
eMyEventOverrunEvent = 200
};
static const uint32_t c_countOfImagesToGrab = 5;
{
public:
{
std::cout << std::endl;
switch ( userProvidedId )
{
case eMyExposureEndEvent:
{
}
else
{
}
break;
case eMyEventOverrunEvent:
break;
}
}
};
{
public:
{
cout << "CSampleImageEventHandler::OnImageGrabbed called." << std::endl;
cout << std::endl;
cout << std::endl;
}
};
int main(int argc, char* argv[])
{
int exitCode = 0;
CSampleCameraEventHandler* pHandler1 = new CSampleCameraEventHandler;
CCameraEventPrinter* pHandler2 = new CCameraEventPrinter;
try
{
{
}
else
{
}
{
}
{
}
{
{
}
}
{
{
}
}
{
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
delete pHandler1;
delete pHandler2;
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_ChunkImage
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
{
public:
{
if (chunkTimestamp.IsReadable())
cout <<
"OnImageGrabbed: TimeStamp (Result) accessed via node map: " << chunkTimestamp.
GetValue() << endl;
cout <<
"OnImageGrabbed: TimeStamp (Result) accessed via result member: " << ptrGrabResult->
ChunkTimestamp.
GetValue() << endl;
}
};
static const uint32_t c_countOfImagesToGrab = 5;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
}
{
}
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
cout <<
"GrabSucceeded: " << ptrGrabResult->
GrabSucceeded() << endl;
cout <<
"SizeX: " << ptrGrabResult->
GetWidth() << endl;
cout <<
"SizeY: " << ptrGrabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl;
{
}
{
}
{
}
{
}
cout << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_MultiCast
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
#include "../include/ConfigurationEventPrinter.h"
#include "../include/ImageEventPrinter.h"
#if defined(PYLON_WIN_BUILD)
#include <conio.h>
#elif defined(PYLON_UNIX_BUILD)
# include <stdio.h>
# include <termios.h>
# include <unistd.h>
# include <fcntl.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100;
bool KeyPressed(void)
{
#if defined(PYLON_WIN_BUILD)
return _kbhit() != 0;
#elif defined(PYLON_UNIX_BUILD)
struct termios savedTermios;
int savedFL;
struct termios termios;
int ch;
tcgetattr(STDIN_FILENO, &savedTermios);
savedFL = fcntl(STDIN_FILENO, F_GETFL, 0);
termios = savedTermios;
termios.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &termios);
fcntl(STDIN_FILENO, F_SETFL, savedFL | O_NONBLOCK);
ch = getchar();
fcntl(STDIN_FILENO, F_SETFL, savedFL);
tcsetattr(STDIN_FILENO, TCSANOW, &savedTermios);
if (ch != EOF)
{
ungetc(ch, stdin);
}
return ch != EOF;
#endif
}
int main(int argc, char* argv[])
{
int exitCode = 0;
bool monitorMode = false;
{
char key;
cout << "Start multicast sample in (c)ontrol or in (m)onitor mode? (c/m) ";
do
cin.get(key);
while ( (key != 'c') && (key != 'm') && (key != 'C') && (key != 'M'));
monitorMode = (key == 'm') || (key == 'M');
}
while(KeyPressed())
{ getchar(); }
try
{
if ( monitorMode)
{
}
if ( monitorMode)
{
{
} else
{
cerr << endl << "Failed to open stream grabber (monitor mode): The acquisition is not yet started by the controlling application." << endl;
cerr << endl << "Start the controlling application before starting the monitor application" << endl;
}
}
else
{
}
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cin.ignore(cin.rdbuf()->in_avail());
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_MultipleCameras
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 10;
static const size_t c_maxCamerasToUse = 2;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
}
for ( size_t i = 0; i < cameras.GetSize(); ++i)
{
cameras[ i ].Attach( tlFactory.
CreateDevice( devices[ i ]));
cout << "Using device " << cameras[ i ].GetDeviceInfo().GetModelName() << endl;
}
cameras.StartGrabbing();
for( uint32_t i = 0; i < c_countOfImagesToGrab && cameras.IsGrabbing(); ++i)
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(cameraContextValue, ptrGrabResult);
#endif
cout << "Camera " << cameraContextValue << ": " << cameras[ cameraContextValue ].GetDeviceInfo().GetModelName() << endl;
cout <<
"GrabSucceeded: " << ptrGrabResult->
GrabSucceeded() << endl;
cout <<
"SizeX: " << ptrGrabResult->
GetWidth() << endl;
cout <<
"SizeY: " << ptrGrabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_Strategies
#include "../include/ConfigurationEventPrinter.h"
#include "../include/ImageEventPrinter.h"
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
cout << "Grab using the GrabStrategy_OneByOne default strategy:" << endl << endl;
for ( int i = 0; i < 3; ++i)
{
{
}
}
{
cout << endl << "Grab results wait in the output queue." << endl << endl;
}
int nBuffersInQueue = 0;
{
nBuffersInQueue++;
}
cout << "Retrieved " << nBuffersInQueue << " grab results from output queue." << endl << endl;
cout << endl << "Grab using strategy GrabStrategy_LatestImageOnly:" << endl << endl;
for ( int i = 0; i < 3; ++i)
{
{
}
}
{
cout << endl << "A grab result waits in the output queue." << endl << endl;
}
nBuffersInQueue = 0;
{
nBuffersInQueue++;
}
cout << "Retrieved " << nBuffersInQueue << " grab result from output queue." << endl << endl;
cout << endl << "Grab using strategy GrabStrategy_LatestImages:" << endl << endl;
for ( int i = 0; i < 3; ++i)
{
{
}
}
{
cout << endl << "Grab results wait in the output queue." << endl << endl;
}
nBuffersInQueue = 0;
{
{
}
nBuffersInQueue++;
}
cout << "Retrieved " << nBuffersInQueue << " grab results from output queue." << endl << endl;
{
cout << endl << "Grab using the GrabStrategy_UpcomingImage strategy:" << endl << endl;
{
cout << "No grab result waits in the output queue." << endl << endl;
}
}
}
else
{
cout << endl;
cout << "This sample can only be used with cameras that can be queried whether they are ready to accept the next frame trigger.";
cout << endl;
cout << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_UsingActionCommand
#include <time.h>
#include <stdlib.h>
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
#include <pylon/gige/BaslerGigEDeviceInfo.h>
using namespace std;
static const uint32_t c_maxCamerasToUse = 2;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
CTlFactory& tlFactory = CTlFactory::GetInstance();
if (pTL == NULL)
{
}
{
}
usableDeviceInfos.push_back(allDeviceInfos[0]);
const String_t subnet(allDeviceInfos[0].GetSubnetAddress());
for (size_t i = 1; i < allDeviceInfos.size() && usableDeviceInfos.size() < c_maxCamerasToUse; ++i)
{
if (subnet == allDeviceInfos[i].GetSubnetAddress())
{
usableDeviceInfos.push_back(allDeviceInfos[i]);
}
else
{
cerr << "Camera will not be used because it is in a different subnet "
<< subnet << "!" << endl;
}
}
srand((unsigned)time(NULL));
const uint32_t DeviceKey = rand();
const uint32_t GroupKey = 0x112233;
for (size_t i = 0; i < cameras.GetSize(); ++i)
{
cameras[i].Attach(tlFactory.
CreateDevice(usableDeviceInfos[i]));
cameras[i].SetCameraContext(i);
const CBaslerGigEDeviceInfo& di = cameras[i].GetDeviceInfo();
cout << "Using camera " << i << ": " << di.GetModelName() << " (" << di.GetIpAddress() << ")" << endl;
}
cameras.Open();
cout << endl << "Issuing an action command." << endl;
cameras.StartGrabbing();
const int DefaultTimeout_ms = 5000;
for (size_t i = 0; i < usableDeviceInfos.size() && cameras.IsGrabbing(); ++i)
{
{
#ifdef PYLON_WIN_BUILD
if (cameraIndex <= 31)
Pylon::DisplayImage(cameraIndex, ptrGrabResult);
#endif
cout << "Camera " << cameraIndex << ": " << cameras[cameraIndex].GetDeviceInfo().GetModelName() <<
" (" << cameras[cameraIndex].GetDeviceInfo().GetIpAddress() << ")" << endl;
cout <<
"GrabSucceeded: " << ptrGrabResult->
GrabSucceeded() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;
}
else
{
}
}
cameras.StopGrabbing();
cameras.Close();
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while (cin.get() != '\n');
return exitCode;
}
Grab_UsingBufferFactory
#ifdef PYLON_WIN_BUILD
#include <pylon/PylonGUI.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 5;
{
public:
MyBufferFactory()
: m_lastBufferContext(1000)
{
}
virtual ~MyBufferFactory()
{
}
virtual void AllocateBuffer( size_t bufferSize, void** pCreatedBuffer, intptr_t& bufferContext)
{
try
{
*pCreatedBuffer = new uint8_t[bufferSize];
bufferContext = ++m_lastBufferContext;
cout << "Created buffer " << bufferContext << ", " << *pCreatedBuffer << endl;
}
catch (const std::exception&)
{
if (*pCreatedBuffer != NULL)
{
uint8_t* p = reinterpret_cast<uint8_t*>(pCreatedBuffer);
delete[] p;
*pCreatedBuffer = NULL;
}
throw;
}
}
virtual void FreeBuffer( void* pCreatedBuffer, intptr_t bufferContext)
{
uint8_t* p = reinterpret_cast<uint8_t*>(pCreatedBuffer);
delete [] p;
cout << "Freed buffer " << bufferContext << ", " << pCreatedBuffer << endl;
}
virtual void DestroyBufferFactory()
{
delete this;
}
protected:
unsigned long m_lastBufferContext;
};
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
MyBufferFactory myFactory;
{
{
cout <<
"SizeX: " << ptrGrabResult->
GetWidth() << endl;
cout <<
"SizeY: " << ptrGrabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "First value of pixel data: " << (uint32_t) pImageBuffer[0] << endl << endl;
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
}
else
{
}
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_UsingExposureEndEvent
#include "../include/ConfigurationEventPrinter.h"
#include <iomanip>
#ifdef PYLON_UNIX_BUILD
# include <sys/time.h>
#endif
using namespace std;
enum MyEvents
{
eMyExposureEndEvent,
eMyFrameStartOvertrigger,
eMyImageReceivedEvent,
eMyMoveEvent,
eMyNoEvent
};
const char* MyEventNames[] =
{
"ExposureEndEvent ",
"FrameStartOvertrigger",
"ImageReceived ",
"Move ",
"NoEvent "
};
struct LogItem
{
LogItem()
: eventType( eMyNoEvent)
, frameNumber(0)
{
}
LogItem( MyEvents event, uint16_t frameNr)
: eventType(event)
, frameNumber(frameNr)
{
#if defined(PYLON_WIN_BUILD)
QueryPerformanceCounter(&time);
#elif defined(PYLON_UNIX_BUILD)
struct timeval tv;
gettimeofday(&tv, NULL);
time = static_cast<unsigned long long>(tv.tv_sec) * 1000L + static_cast<unsigned long long>(tv.tv_usec) / 1000LL;
#endif
}
#if defined(PYLON_WIN_BUILD)
LARGE_INTEGER time;
#elif defined(PYLON_UNIX_BUILD)
unsigned long long time;
#endif
MyEvents eventType;
uint16_t frameNumber;
};
void PrintLog( const std::vector<LogItem>& aLog)
{
#if defined(PYLON_WIN_BUILD)
LARGE_INTEGER timerFrequency;
QueryPerformanceFrequency(&timerFrequency);
#endif
cout << std::endl << "Warning, the printed time values can be wrong on older computer hardware." << std::endl << std::endl;
cout << "Time [ms] " << "Event " << "FrameNumber" << std::endl;
cout << "------------ " << "--------------------- " << "-----------" << std::endl;
size_t logSize = aLog.size();
for ( size_t i = 0; i < logSize; ++i)
{
double time_ms = 0;
if ( i)
{
#if defined(PYLON_WIN_BUILD)
__int64 oldTicks = ((__int64)aLog[i-1].time.HighPart << 32) + (__int64)aLog[i-1].time.LowPart;
__int64 newTicks = ((__int64)aLog[i].time.HighPart << 32) + (__int64)aLog[i].time.LowPart;
long double timeDifference = (long double) (newTicks - oldTicks);
long double ticksPerSecond = (long double) (((__int64)timerFrequency.HighPart << 32) + (__int64)timerFrequency.LowPart);
time_ms = (timeDifference / ticksPerSecond) * 1000;
#elif defined(PYLON_UNIX_BUILD)
time_ms = aLog[i].time - aLog[i-1].time;
#endif
}
cout << setw(12) << fixed << setprecision(4) << time_ms <<" "<< MyEventNames[ aLog[i].eventType ] <<" "<< aLog[i].frameNumber << std::endl;
}
}
static const uint32_t c_countOfImagesToGrab = 50;
{
public:
CEventHandler()
{
m_log.reserve( c_countOfImagesToGrab * 3);
}
void Initialize(int value , bool isGigE)
{
m_nextExpectedFrameNumberImage = value;
m_nextExpectedFrameNumberExposureEnd = value;
m_nextFrameNumberForMove = value;
m_isGigE = isGigE;
}
{
if ( userProvidedId == eMyExposureEndEvent)
{
uint16_t frameNumber;
{
}
else
{
}
m_log.push_back( LogItem( eMyExposureEndEvent, frameNumber));
if ( GetIncrementedFrameNumber( frameNumber) != m_nextExpectedFrameNumberExposureEnd)
{
if ( frameNumber == m_nextFrameNumberForMove)
{
MoveImagedItemOrSensorHead();
}
if ( frameNumber != m_nextExpectedFrameNumberExposureEnd)
{
throw RUNTIME_EXCEPTION(
"An Exposure End event has been lost. Expected frame number is %d but got frame number %d.", m_nextExpectedFrameNumberExposureEnd, frameNumber);
}
IncrementFrameNumber( m_nextExpectedFrameNumberExposureEnd);
}
}
else if ( userProvidedId == eMyFrameStartOvertrigger)
{
m_log.push_back( LogItem( eMyFrameStartOvertrigger, 0));
}
else
{
PYLON_ASSERT2(false, "The sample has been modified and a new event has been registered. Add handler code above.");
}
}
{
uint16_t frameNumber = (uint16_t)ptrGrabResult->
GetBlockID();
m_log.push_back( LogItem( eMyImageReceivedEvent, frameNumber));
if ( frameNumber == m_nextFrameNumberForMove)
{
MoveImagedItemOrSensorHead();
}
if ( frameNumber != m_nextExpectedFrameNumberImage)
{
throw RUNTIME_EXCEPTION(
"An image has been lost. Expected frame number is %d but got frame number %d.", m_nextExpectedFrameNumberImage, frameNumber);
}
IncrementFrameNumber( m_nextExpectedFrameNumberImage);
}
void MoveImagedItemOrSensorHead()
{
m_log.push_back( LogItem( eMyMoveEvent, m_nextFrameNumberForMove));
IncrementFrameNumber( m_nextFrameNumberForMove);
}
void PrintLog()
{
::PrintLog( m_log);
}
private:
void IncrementFrameNumber( uint16_t& frameNumber)
{
frameNumber = GetIncrementedFrameNumber( frameNumber);
}
uint16_t GetIncrementedFrameNumber( uint16_t frameNumber)
{
++frameNumber;
if (m_isGigE)
{
if (frameNumber == 0)
{
++frameNumber;
}
}
return frameNumber;
}
uint16_t m_nextExpectedFrameNumberImage;
uint16_t m_nextExpectedFrameNumberExposureEnd;
uint16_t m_nextFrameNumberForMove;
bool m_isGigE;
std::vector<LogItem> m_log;
};
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
CEventHandler eventHandler;
{
eventHandler.Initialize( 1, true );
}
else
{
eventHandler.Initialize( 0, false );
}
{
}
else
{
}
{
}
{
{
}
}
{
{
}
}
{
{
}
}
{
}
{
}
{
}
{
}
eventHandler.PrintLog();
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while (cin.get() != '\n');
return exitCode;
}
Grab_UsingGrabLoopThread
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
#include "../include/ConfigurationEventPrinter.h"
#include "../include/ImageEventPrinter.h"
using namespace std;
{
public:
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
cout << "CSampleImageEventHandler::OnImageGrabbed called." << std::endl;
cout << std::endl;
cout << std::endl;
}
};
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
cerr << endl << "Enter \"t\" to trigger the camera or \"e\" to exit and press enter? (t/e)" << endl << endl;
char key;
do
{
cin.get(key);
if ( (key == 't' || key == 'T'))
{
{
}
}
}
while ( (key != 'e') && (key != 'E'));
}
else
{
cout << endl;
cout << "This sample can only be used with cameras that can be queried whether they are ready to accept the next frame trigger.";
cout << endl;
cout << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
cin.ignore(cin.rdbuf()->in_avail());
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Grab_UsingSequencer
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 10;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
{
int64_t curSet = initialSet;
{
}
curSet += incSet;
curSet += incSet;
}
else
{
}
{
{
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, grabResult);
#endif
cout <<
"SizeX: " << grabResult->
GetWidth() << endl;
cout <<
"SizeY: " << grabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *)grabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t)pImageBuffer[0] << endl << endl;
}
else
{
}
}
cerr << endl << "Press enter to continue." << endl << endl;
}
{
}
else
{
}
}
else
{
cout << "The sequencer feature is not available for this camera." << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while (cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_AutoFunctions
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
{
AutoGainOnce(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoGainContinuous(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoExposureOnce(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoExposureContinuous(camera);
}
else
{
AutoGainOnce(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoGainContinuous(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoExposureOnce(camera);
cerr << endl << "Press Enter to continue." << endl;
while (cin.get() != '\n');
AutoExposureContinuous(camera);
}
if (IsColorCamera(camera))
{
cerr << endl << "Press Enter to continue." << endl;
while( cin.get() != '\n');
{
}
else
{
}
AutoWhiteBalance(camera);
}
}
else
{
cerr << "Only area scan cameras support auto functions." << endl;
}
}
{
cerr << "A timeout has occurred." << endl
cerr << "Please make sure you remove the cap from the camera lens before running this sample." << endl;
exitCode = 0;
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
{
{
cout << "The camera does not support Gain Auto." << endl << endl;
return;
}
{
}
{
}
{
cout << "Trying 'GainAuto = Once'." << endl;
cout <<
"Initial Gain = " << camera.
Gain.
GetValue() << endl;
}
else
{
cout << "Trying 'GainAuto = Once'." << endl;
}
int n = 0;
{
camera.
GrabOne( 5000, ptrGrabResult);
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
++n;
if (n > 100)
{
}
}
cout << "GainAuto went back to 'Off' after " << n << " frames." << endl;
{
cout <<
"Final Gain = " << camera.
Gain.
GetValue() << endl << endl;
}
else
{
}
}
{
{
cout << "The camera does not support Gain Auto." << endl << endl;
return;
}
{
}
{
}
{
cout << "Trying 'GainAuto = Continuous'." << endl;
cout <<
"Initial Gain = " << camera.
Gain.
GetValue() << endl;
}
else
{
cout << "Trying 'GainAuto = Continuous'." << endl;
}
for (int n = 0; n < 20; n++)
{
camera.
GrabOne( 5000, ptrGrabResult);
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
}
{
cout <<
"Final Gain = " << camera.
Gain.
GetValue() << endl << endl;
}
else
{
}
}
{
{
cout << "The camera does not support Exposure Auto." << endl << endl;
return;
}
{
}
{
}
{
cout << "Trying 'ExposureAuto = Once'." << endl;
cout << "Initial exposure time = ";
}
else
{
cout << "Trying 'ExposureAuto = Once'." << endl;
cout << "Initial exposure time = ";
}
int n = 0;
{
camera.
GrabOne( 5000, ptrGrabResult);
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
++n;
if (n > 100)
{
}
}
cout << "ExposureAuto went back to 'Off' after " << n << " frames." << endl;
cout << "Final exposure time = ";
{
}
else
{
}
}
{
{
cout << "The camera does not support Exposure Auto." << endl << endl;
return;
}
{
}
{
}
{
cout << "ExposureAuto 'GainAuto = Continuous'." << endl;
cout << "Initial exposure time = ";
}
else
{
cout << "ExposureAuto 'GainAuto = Continuous'." << endl;
cout << "Initial exposure time = ";
}
for (int n = 0; n < 20; n++)
{
camera.
GrabOne( 5000, ptrGrabResult);
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
}
cout << "Final exposure time = ";
{
}
else
{
}
}
{
{
cout << "The camera does not support Balance White Auto." << endl << endl;
return;
}
{
}
{
}
cout << "Trying 'BalanceWhiteAuto = Once'." << endl;
cout << "Initial balance ratio: ";
{
}
else
{
}
int n = 0;
{
camera.
GrabOne( 5000, ptrGrabResult);
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
++n;
if (n > 100)
{
}
}
cout << "BalanceWhiteAuto went back to 'Off' after ";
cout << n << " frames." << endl;
cout << "Final balance ratio: ";
{
}
else
{
}
}
{
bool result = false;
for (size_t i = 0; i < settableValues.size(); i++)
{
if (settableValues[i].find(
GenICam::gcstring(
"Bayer")) != GenICam::gcstring::_npos())
{
result = true;
break;
}
}
return result;
}
ParametrizeCamera_Configurations
#include "../include/ImageEventPrinter.h"
#include "../include/ConfigurationEventPrinter.h"
#include "../include/PixelFormatAndAoiConfiguration.h"
using namespace std;
static const uint32_t c_countOfImagesToGrab = 3;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
cout << "Grab using continuous acquisition:" << endl << endl;
{
}
cout << "Grab using software trigger mode:" << endl << endl;
{
}
cout << "Grab using single frame acquisition:" << endl << endl;
camera.
GrabOne( 5000, ptrGrabResult);
camera.
GrabOne( 5000, ptrGrabResult);
camera.
GrabOne( 5000, ptrGrabResult);
camera.
GrabOne( 5000, ptrGrabResult);
cout << "Grab using multiple configuration objects:" << endl << endl;
CConfigurationEventPrinter* pEventPrinterObject = new CConfigurationEventPrinter;
cout << endl << "Grab, configuration events are printed:" << endl << endl;
camera.
GrabOne( 5000, ptrGrabResult);
delete pEventPrinterObject;
pEventPrinterObject = NULL;
cout << endl << "Grab, configuration events are not printed:" << endl << endl;
camera.
GrabOne( 5000, ptrGrabResult);
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_GenericParameterAccess
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
cout << "Camera Device Information" << endl
<< "=========================" << endl;
cout << "Vendor : "
cout << "Model : "
cout << "Firmware version : "
cout << "Camera Device Settings" << endl
<< "======================" << endl;
offsetX.TrySetToMinimum();
offsetY.TrySetToMinimum();
cout << "OffsetX : " << offsetX.GetValue() << endl;
cout << "OffsetY : " << offsetY.GetValue() << endl;
cout << "Width : " << width.GetValue() << endl;
cout << "Height : " << height.GetValue() << endl;
String_t oldPixelFormat = pixelFormat.GetValue();
cout << "Old PixelFormat : " << oldPixelFormat << endl;
if (pixelFormat.CanSetValue("Mono8"))
{
pixelFormat.SetValue( "Mono8");
cout << "New PixelFormat : " << pixelFormat.GetValue() << endl;
}
gainAuto.TrySetValue("Off");
{
gain.SetValuePercentOfRange(50.0);
cout << "Gain (50%) : " << gain.GetValue() << " (Min: " << gain.GetMin() << "; Max: " << gain.GetMax() << ")" << endl;
}
else
{
gainRaw.SetValuePercentOfRange(50.0);
cout << "Gain (50%) : " << gainRaw.GetValue() << " (Min: " << gainRaw.GetMin() << "; Max: " << gainRaw.GetMax() << "; Inc: " << gainRaw.GetInc() << ")" << endl;
}
pixelFormat.SetValue(oldPixelFormat);
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_LoadAndSave
using namespace std;
const char Filename[] = "NodeMap.pfs";
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
cout << "Saving camera's node map to file..."<< endl;
cout << "Reading file back to camera's node map..."<< endl;
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_LookupTable
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
cout << "Opening camera...";
cout << "done" << endl;
cout << "Writing LUT....";
int inc;
if ( nValues == 4096 )
inc = 8;
else if ( nValues == 1024 )
inc = 2;
else
{
}
for ( int i = 0; i < nValues; i += inc )
{
}
cout << "done" << endl;
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_NativeParameterAccess
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
cout << "Camera Device Information" << endl
<< "=========================" << endl;
cout << "Vendor : "
cout << "Model : "
cout << "Firmware version : "
cout << "Camera Device Settings" << endl
<< "======================" << endl;
cout <<
"Old PixelFormat : " << camera.
PixelFormat.
ToString() <<
" (" << oldPixelFormat <<
")" << endl;
{
}
{
}
else
{
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
ParametrizeCamera_Shading
#define _CRT_SECURE_NO_WARNINGS
#include <float.h>
#include <errno.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
using namespace std;
const char *pLocalFilename);
const char *pCameraFilename,
const char *pLocalFilename);
static const char LocalFilename[] = "ShadingData.bin";
#define USE_SHADING_SET_1 // Define which shading set we are going to use.
#if defined (USE_SHADING_SET_1)
static const char CameraFilename[] = "UserGainShading1";
#elif defined (USE_SHADING_SET_2)
static const char CameraFilename[] = "UserGainShading2";
#else
#error No shading set defined!
#endif
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
CreateShadingData( camera, LocalFilename);
UploadFile( camera, CameraFilename, LocalFilename);
CheckShadingData( camera);
}
else
{
cerr << "Only line scan cameras support gain shading." << endl;
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
uint32_t Width,
uint32_t Height,
uint32_t NumCoeffs,
double *Intensities)
{
for (uint32_t x = 0; x < NumCoeffs; x++)
{
Intensities[x] = 0.0;
}
cout << "Grab frame for averaging." << endl;
camera.
GrabOne( 5000, ptrGrabResult);
uint8_t *Buffer =
static_cast<uint8_t*
>( ptrGrabResult->
GetBuffer());
if (NumCoeffs == 3 * Width)
{
for (uint32_t x = 0; x < Width; x++)
{
for (uint32_t y = 0; y < Height; y++)
{
uint32_t idx = 3 * (y * Width + x);
Intensities[x] += Buffer[idx];
Intensities[x + Width] += Buffer[idx + 1];
Intensities[x + 2 * Width] += Buffer[idx + 2];
}
}
}
else
{
for (uint32_t x = 0; x < Width; x++)
{
for (uint32_t y = 0; y < Height; y++)
{
Intensities[x] += Buffer[y * Width + x];
}
}
}
double scale = 1.0 / double(Height);
for (uint32_t x = 0; x < NumCoeffs; x++)
{
Intensities[x] *= scale;
}
}
void CalculateCoeffs( uint32_t Width,
uint32_t Height,
uint32_t NumCoeffs,
double * pDblCoeff )
{
if (NumCoeffs == 3 * Width)
{
double MinR = DBL_MAX;
double MinG = DBL_MAX;
double MinB = DBL_MAX;
double MaxR = -DBL_MAX;
double MaxG = -DBL_MAX;
double MaxB = -DBL_MAX;
for (uint32_t x = 0; x < Width; x++)
{
if (pDblCoeff[x] < MinR)
{
MinR = pDblCoeff[x];
}
if (pDblCoeff[x] > MaxR)
{
MaxR = pDblCoeff[x];
}
if (pDblCoeff[x + Width] < MinG)
{
MinG = pDblCoeff[x + Width];
}
if (pDblCoeff[x + Width] > MaxG)
{
MaxG = pDblCoeff[x + Width];
}
if (pDblCoeff[x + 2 * Width] < MinB)
{
MinB = pDblCoeff[x + 2 * Width];
}
if (pDblCoeff[x + 2 * Width] > MaxB)
{
MaxB = pDblCoeff[x + 2 * Width];
}
}
cout << "MaxR = " << (MaxR / MinR) << " * MinR" << endl;
cout << "MaxG = " << (MaxG / MinG) << " * MinG" << endl;
cout << "MaxB = " << (MaxB / MinB) << " * MinB" << endl;
for (uint32_t x = 0; x < Width; x++)
{
pDblCoeff[x] = MaxR / pDblCoeff[x];
pDblCoeff[x + Width] = MaxG / pDblCoeff[x + Width];
pDblCoeff[x + 2 * Width] = MaxB / pDblCoeff[x + 2 * Width];
}
}
else
{
double Min = DBL_MAX;
double Max = -DBL_MAX;
for (uint32_t x = 0; x < Width; x++)
{
if (pDblCoeff[x] < Min)
{
Min = pDblCoeff[x];
}
if (pDblCoeff[x] > Max)
{
Max = pDblCoeff[x];
}
}
cout << "Max = " << (Max / Min) << " * Min" << endl;
for (uint32_t x = 0; x < Width; x++)
{
pDblCoeff[x] = Max / pDblCoeff[x];
}
}
}
{
int32_t BytesPerPixel = 1;
if (SupportsRGB(camera))
{
BytesPerPixel = 3;
}
else
{
}
uint32_t NumCoeffs = BytesPerPixel * Width;
double *pDblCoeff = new double[NumCoeffs];
AverageLines(camera, Width, Height, NumCoeffs, pDblCoeff);
CalculateCoeffs(Width, Height, NumCoeffs, pDblCoeff);
uint32_t *pCoeffs = new uint32_t[NumCoeffs];
for (uint32_t x = 0; x < NumCoeffs; x++)
{
uint32_t coeff = uint32_t(pDblCoeff[x] * (1 << 16));
if (coeff > 0x0003FFFF)
{
static bool PrintMessage = true;
if (PrintMessage)
{
PrintMessage = false;
cout << "Gain shading had to be clipped." << endl;
}
coeff = 0x0003FFFF;
}
pCoeffs[x] = coeff;
}
delete[] pDblCoeff;
FILE *fp = fopen(pLocalFilename, "wb");
if (fp == NULL )
{
}
struct ShadingHeader_t
{
unsigned char version;
unsigned char type;
unsigned char sensorType;
unsigned char lineType;
unsigned short width;
unsigned short reserved;
};
static const unsigned char ShadingVersion_1 = 0x5a;
static const unsigned char ShadingType_Gain = 0xc3;
static const unsigned char ShadingSensorType_Line = 0x02;
static const unsigned char ShadingLineType_Single = 0x01;
static const unsigned char ShadingLineType_Tri = 0x03;
ShadingHeader_t h;
h.version = ShadingVersion_1;
h.type = ShadingType_Gain;
h.sensorType = ShadingSensorType_Line;
h.lineType = BytesPerPixel == 3 ? ShadingLineType_Tri : ShadingLineType_Single;
h.width = uint16_t(Width);
h.reserved = 0;
fwrite(&h, sizeof(h), 1, fp);
fwrite(pCoeffs, sizeof(uint32_t), NumCoeffs, fp);
fclose(fp);
delete[] pCoeffs;
}
const char *pCameraFilename,
const char *pLocalFilename)
{
FILE *fp = fopen(pLocalFilename, "rb");
if ( fp == NULL )
{
}
fseek(fp, 0, SEEK_END);
size_t Size = ftell(fp);
rewind(fp);
if (Size == 0)
{
fclose(fp);
return;
}
char *pBuf = new char[Size];
size_t read = fread(pBuf, 1, Size, fp);
fclose(fp);
if (read != Size)
{
}
GenApi::ODevFileStream stream( &camera.
GetNodeMap(), pCameraFilename);
stream.write(pBuf, streamsize(Size));
stream.close();
delete[] pBuf;
}
{
int32_t BytesPerPixel = 1;
if (SupportsRGB(camera))
{
BytesPerPixel = 3;
}
uint32_t NumCoeffs = BytesPerPixel * Width;
double *pDblCoeff = new double[NumCoeffs];
AverageLines( camera,
Width,
Height,
NumCoeffs,
pDblCoeff);
cout << endl << "After applying shading correction:" << endl;
CalculateCoeffs(Width, Height, NumCoeffs, pDblCoeff);
delete[] pDblCoeff;
}
{
bool Result = false;
for (size_t i = 0; i < Entries.size(); i++)
{
{
{
Result = true;
break;
}
}
}
return Result;
}
ParametrizeCamera_UserSets
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
}
else
{
}
cout << "Loading default settings" << endl;
cout << "Turning off Gain Auto and Exposure Auto." << endl;
{
}
else
{
}
cout << "Saving currently active settings to user set 1." << endl;
cout << endl << "Loading default settings." << endl;
cout << "Default settings" << endl;
cout << "================" << endl;
{
}
else
{
}
cout << endl << "Loading user set 1 settings." << endl;
cout << "User set 1 settings" << endl;
cout << "===================" << endl;
{
}
else
{
}
{
}
else
{
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Utility_GrabVideo
This sample is part of the pylon sample solution that can be found under <SDK ROOT>\Development\Samples\C++.
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100;
static const int64_t c_maxImageDataBytesThreshold = 50 * 1024 * 1024;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
std::cout << "VideoWriter is not supported at the moment. Please install the pylon Supplementary Package for MPEG-4 which is available on the Basler website." << endl;
return 1;
}
const int cFramesPerSecond = 20;
const uint32_t cQuality = 90;
EPixelType pixelType = pixelTypeMapper.GetPylonPixelTypeFromNodeValue(pixelFormat.GetIntValue());
(uint32_t) width.GetValue(),
(uint32_t) height.GetValue(),
pixelType,
cFramesPerSecond,
cQuality );
videoWriter.
Open(
"_TestVideo.mp4" );
cout << "Please wait. Images are being grabbed." << endl;
{
cout <<
"SizeX: " << ptrGrabResult->
GetWidth() << endl;
cout <<
"SizeY: " << ptrGrabResult->
GetHeight() << endl;
const uint8_t *pImageBuffer = (uint8_t *) ptrGrabResult->
GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, ptrGrabResult);
#endif
videoWriter.
Add( ptrGrabResult);
<< std::endl;
{
std::cout << "The image data size limit has been reached." << endl;
break;
}
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Utility_Image
#include <iomanip>
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
#include "../include/SampleImageCreator.h"
using namespace std;
void PrintImageProperties(
IImage& image)
{
cout
<< endl;
}
void ShowImage(
IImage& image,
const char* message = NULL)
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, image);
#endif
if ( message)
{
cout << endl << message << " ";
}
std::ios state(NULL);
state.copyfmt(cout);
const uint8_t* pBytes =
reinterpret_cast<const uint8_t*
>(image.
GetBuffer());
cout << endl << "First six bytes of the image: " << endl;
for (unsigned int i = 0; i < 6; ++i)
{
cout << "0x" << hex << setfill('0') << setw(2) << unsigned(pBytes[i]) << " ";
}
cout << endl;
cout.copyfmt(state);
cerr << "Press enter to continue." << endl;
while( cin.get() != '\n');
}
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
const uint32_t cWidth = 640;
const uint32_t cHeight = 480;
const uint32_t cPadding = 10;
const uint8_t cSampleGrayValue = 160;
{
cout << "The properties of the newly created image." << endl;
PrintImageProperties( imageMono8);
uint32_t width = imageMono8.GetWidth();
uint32_t height = imageMono8.GetHeight();
uint8_t* buffer = static_cast<uint8_t*>( imageMono8.GetBuffer());
uint8_t* p = buffer;
for (uint32_t y = 0; y < height; ++y)
{
for (uint32_t x = 0; x < width; ++x, ++p)
{
*p = (uint8_t)((x + y) % 256);
}
}
ShowImage( imageMono8, "Created image.");
cout << endl << "After assignment multiple images reference the same data." << endl;
PrintImageProperties( imageMono8);
PrintImageProperties( sameImageMono8A);
PrintImageProperties( sameImageMono8B);
cout << endl << "The properties of a full copy of the test image." << endl;
PrintImageProperties( copiedImage);
cout << endl << "Assigned to image object after releasing the image data." << endl;
PrintImageProperties( sameImageMono8B);
cout << endl << "A newly created image object." << endl;
PrintImageProperties( reusedImage);
cout << "After resetting the image properties. A new Buffer is allocated." << endl;
PrintImageProperties( reusedImage);
cout << "After resetting the image properties to a smaller image. The buffer is reused." << endl;
PrintImageProperties( reusedImage);
cout << "After resetting the image properties to a larger image." << endl << "A new Buffer is allocated." << endl;
PrintImageProperties( reusedImage);
cout << endl << "After resetting the image properties while the image data is referenced by another image. A new Buffer is allocated." << endl;
PrintImageProperties( sameImageMono8A);
cout << endl << "After resetting the image properties with additional padding." << endl;
PrintImageProperties( sameImageMono8A);
}
{
vector<uint8_t> buffer( (cWidth + cPadding) * cHeight, cSampleGrayValue);
size_t bufferSize = buffer.size() * sizeof( buffer[ 0 ]);
cout << endl << "The properties of an image with an attached user buffer." << endl;
PrintImageProperties( imageA);
cout << "After resetting the image properties to a smaller image. The buffer is reused." << endl;
PrintImageProperties( imageA);
try
{
cout << "Try calling the Reset method when the user buffer is too small for the new image." << endl;
}
{
}
cout << endl << "The properties of an image after a full copy of a user buffer." << endl;
PrintImageProperties( imageB);
}
{
cout << endl << "Waiting for an image to be grabbed." << endl;
try
{
Camera.GrabOne( 1000, ptrGrabResult);
}
{
cerr << "Could not grab an image: " << endl
}
{
cout << endl << "The properties of the grabbed image." << endl;
PrintImageProperties( ptrGrabResult);
ShowImage( ptrGrabResult, "Grabbed image.");
cout << endl << "The properties of an image with an attached grab result." << endl;
PrintImageProperties( image);
uint32_t width = ptrGrabResult->
GetWidth();
uint32_t height = ptrGrabResult->
GetHeight();
cout << "After the grab result has been released." << endl;
PrintImageProperties( image);
image.
Reset( pixelType, width / 2, height);
cout << endl << "After resetting the image properties while a grab result is referenced. A new Buffer is allocated." << endl;
PrintImageProperties( image);
}
}
{
#ifdef PYLON_WIN_BUILD
imageSaved.
Save( ImageFileFormat_Bmp,
"JuliaFractal.bmp");
#endif
#ifdef PYLON_WIN_BUILD
imageLoaded.
Load(
"JuliaFractal.bmp");
cout << endl << "The properties of the loaded sample image." << endl;
PrintImageProperties( imageLoaded);
ShowImage( imageLoaded, "The loaded sample image is shown.");
#endif
}
{
cout << endl << "The properties of the sample image." << endl;
PrintImageProperties( sampleImage);
uint32_t topLeftX = cWidth / 4;
uint32_t topLeftY = cHeight /2;
uint32_t width = cWidth / 4;
uint32_t height = cHeight / 4;
aoi = sampleImage.
GetAoi( topLeftX, topLeftY, width, height);
cout << "After creating an AOI." << endl;
PrintImageProperties( aoi);
ShowImage( aoi, "AOI of the sample image.");
cout << "The properties of a full copy of the AOI image." << endl;
PrintImageProperties( copiedAoi);
topLeftX = width / 4;
topLeftY = height / 4;
width = width / 2;
height = height / 2;
aoiFromAoi = aoi.
GetAoi( topLeftX, topLeftY, width, height);
cout << "After creating an AOI of an AOI." << endl;
PrintImageProperties( aoiFromAoi);
ShowImage( aoiFromAoi, "AOI of the AOI of the sample image.");
cout << "After reusing the buffer of the sample image." << endl;
PrintImageProperties( aoiFromAoi);
}
{
imageRGB8planar = SampleImageCreator::CreateMandelbrotFractal(
PixelType_RGB8planar, cWidth, cHeight);
ShowImage( imageRGB8planar, "Sample image.");
ShowImage( redPlane, "Red plane of the sample image.");
ShowImage( greenPlane, "Green plane of the sample image.");
ShowImage( bluePlane, "Blue plane of the sample image.");
ShowImage( imageRGB8planar, "Sample image with red set to zero.");
}
{
#ifdef PYLON_WIN_BUILD
CPylonBitmapImage bitmapImage;
bitmapImage.CopyImage( sampleImage);
cout << endl << "The properties of the bitmap image." << endl;
PrintImageProperties( bitmapImage);
ShowImage( bitmapImage, "The sample image is shown.");
CPylonBitmapImage sameBitmapImageA( bitmapImage);
CPylonBitmapImage sameBitmapImageB = bitmapImage;
cout << endl << "After assignment multiple images reference the same data." << endl;
PrintImageProperties( bitmapImage);
PrintImageProperties( sameBitmapImageA);
PrintImageProperties( sameBitmapImageB);
sameBitmapImageB.Release();
cout << endl << "Assigned to image object after releasing the image data." << endl;
PrintImageProperties( sameBitmapImageB);
converter.
Convert( bitmapImage, sampleImage);
cout << endl << "The properties of the converted bitmap image." << endl;
PrintImageProperties( bitmapImage);
ShowImage( bitmapImage, "The to monochrome converted sample image is shown.");
cout << endl << "The properties of the reused bitmap image with equal properties." << endl;
PrintImageProperties( bitmapImage);
cout << endl << "The properties of the newly allocated bitmap image with different properties." << endl;
PrintImageProperties( bitmapImage);
HBITMAP bitmap = bitmapImage;
bitmap = bitmapImage.Detach();
cout << endl << "The image object after detaching the image data." << endl;
PrintImageProperties( bitmapImage);
::DeleteObject( bitmap);
#endif
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Utility_ImageDecompressor
#include <iomanip>
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
using namespace std;
void ShowImage(
IImage& image,
const char* message = NULL)
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, image);
#endif
if ( message)
{
cout << endl << message << " ";
}
std::ios state(NULL);
state.copyfmt(cout);
const uint8_t* pBytes =
reinterpret_cast<const uint8_t*
>(image.
GetBuffer());
cout << endl << "First six bytes of the image: " << endl;
for (unsigned int i = 0; i < 6; ++i)
{
cout << "0x" << hex << setfill('0') << setw(2) << unsigned(pBytes[i]) << " ";
}
cout << endl;
cout.copyfmt(state);
cerr << endl << "Press enter to continue." << endl;
while (cin.get() != '\n');
}
{
string status;
{
status = "Ok";
break;
status = "Buffer overflow";
break;
status = "Error";
break;
}
cout << endl << "Compression info:" << endl;
cout <<
"hasCompressedImage :" << (info.
hasCompressedImage ==
true ?
"Yes" :
"No") << endl;
cout << "compressionStatus :" << status << endl;
cout <<
"lossy :" << (info.
lossy ==
true ?
"Yes" :
"No") << endl;
cout <<
"width :" << info.
width << endl;
cout <<
"height :" << info.
height << endl;
}
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
{
cout << "Old compression mode: " << oldCompressionMode << endl;
{
}
cout << "Old compression rate option: " << oldCompressionRateOption << endl;
{
}
if (camera.
GrabOne( 1000, ptrGrabResult ))
{
{
if (decompressor.GetCompressionInfo( info, ptrGrabResult ))
{
printCompressionInfo( info );
{
{
cout << endl <<
"Transferred payload \t:" << ptrGrabResult->
GetPayloadSize() << endl;
decompressor.DecompressImage( targetImage, ptrGrabResult );
ShowImage( targetImage, "Decompressed image." );
}
else
{
cout << "There was an error while the camera was compressing the image." << endl;
}
}
else
{
ShowImage( ptrGrabResult, "Grabbed image." );
}
}
else
{
ShowImage( ptrGrabResult, "Grabbed image." );
}
}
else
{
}
}
else
{
cout << "Error: Could not grab an image." << endl;
}
{
cout << endl << "--- Switching to Fix Ratio compression ---" << endl << endl << endl;
{
}
decompressor.SetCompressionDescriptor( nodemap );
if (camera.
GrabOne( 1000, ptrGrabResult ))
{
{
if (decompressor.GetCompressionInfo( info, ptrGrabResult ))
{
printCompressionInfo( info );
{
{
cout << endl <<
"Transferred payload \t:" << ptrGrabResult->
GetPayloadSize() << endl;
decompressor.DecompressImage( targetImage, ptrGrabResult );
ShowImage( targetImage, "Decompressed image." );
}
else
{
cout << "There was an error while the camera was compressing the image." << endl;
}
}
else
{
ShowImage( ptrGrabResult, "Grabbed image." );
}
}
else
{
ShowImage( ptrGrabResult, "Grabbed image." );
}
}
else
{
}
}
else
{
cout << "Error: Could not grab an image." << endl;
}
}
}
else
{
cout << "This camera does not support compression." << endl;
}
}
{
cerr << "Could not grab an image: " << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while (cin.get() != '\n');
return exitCode;
}
Utility_ImageFormatConverter
#include <iomanip>
#ifdef PYLON_WIN_BUILD
# include <pylon/PylonGUI.h>
#endif
#include "../include/SampleImageCreator.h"
using namespace std;
void ShowImage(
IImage& image,
const char* message = NULL)
{
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(1, image);
#endif
if ( message)
{
cout << endl << message << " ";
}
std::ios state(NULL);
state.copyfmt(cout);
const uint8_t* pBytes =
reinterpret_cast<const uint8_t*
>(image.
GetBuffer());
cout << endl << "First six bytes of the image: " << endl;
for (unsigned int i = 0; i < 6; ++i)
{
cout << "0x" << hex << setfill('0') << setw(2) << unsigned(pBytes[i]) << " ";
}
cout << endl;
cout.copyfmt(state);
cerr << "Press Enter to continue." << endl;
while( cin.get() != '\n');
}
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
const uint32_t cWidth = 640;
const uint32_t cHeight = 480;
{
ShowImage( imageRGB8packed, "Source image.");
converter.
Convert( targetImage, imageRGB8packed);
ShowImage( targetImage, "Converted image.");
}
{
cout << endl << "Waiting for an image to be grabbed." << endl;
try
{
if ( Camera.GrabOne( 1000, ptrGrabResult))
{
{
ShowImage( ptrGrabResult, "Grabbed image.");
}
else
{
ShowImage( ptrGrabResult, "Grabbed image.");
converter.
Convert( targetImage, ptrGrabResult);
ShowImage( targetImage, "Converted image.");
}
}
}
{
cerr << "Could not grab an image: " << endl
}
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Utility_ImageLoadAndSave
#include "../include/SampleImageCreator.h"
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
const uint32_t cWidth = 640;
const uint32_t cHeight = 480;
{
<< " be saved without conversion as tiff." << endl;
#ifdef PYLON_WIN_BUILD
imageRGB16packed.
Save( ImageFileFormat_Bmp,
"MandelbrotFractal.bmp");
<< " be saved without conversion as bmp." << endl;
#endif
uint32_t width = imageRGB16packed.
GetWidth();
uint32_t height = imageRGB16packed.
GetHeight();
"MandelbrotFractal.png",
buffer,
bufferSize,
pixelType,
width,
height,
paddingX,
orientation);
}
{
<< "RGB16packed." << endl;
#ifdef PYLON_WIN_BUILD
imageBGR8packedFromBmp.
Load(
"MandelbrotFractal.bmp");
<< "BGR8packed." << endl;
#endif
}
#ifdef PYLON_WIN_BUILD
{
}
#endif
{
cout << endl << "Waiting for an image to be grabbed." << endl;
try
{
if ( Camera.GrabOne( 1000, ptrGrabResult))
{
}
}
{
cerr << "Could not grab an image: " << endl
}
}
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
Utility_IpConfig
This sample is part of the pylon sample solution that can be found under <SDK ROOT>\Development\Samples\C++.
#include <algorithm>
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
if (pTl == NULL)
{
cerr << "Error: No GigE transport layer installed." << endl;
cerr << " Please install GigE support as it is required for this sample." << endl;
return 1;
}
if(argc < 3)
{
cout << "Usage: Utility_IpConfig <MAC> <IP> [MASK] [GATEWAY]" << endl;
cout << " <MAC> is the MAC address without separators, e.g., 0030531596CF" << endl;
cout << " <IP> is one of the following:" << endl;
cout << " - AUTO to use Auto-IP (LLA)." << endl;
cout << " - DHCP to use DHCP." << endl;
cout << " - Everything else is interpreted as a new IP address in dotted notation, e.g., 192.168.1.1" << endl;
cout << " [MASK] is the network mask in dotted notation. This is optional. 255.255.255.0 is used as default." << endl;
cout << " [GATEWAY] is the gateway address in dotted notation. This is optional. 0.0.0.0 is used as default." << endl;
cout << "Please note that this is a sample and no sanity checks are made." << endl;
cout << endl;
cout << left << setfill(' ');
cout << endl;
cout.width(32+14+17+17+15+8);
cout << "Available Devices";
cout.width(15);
cout << " supports " << endl;
cout.width(32);
cout << "Friendly Name";
cout.width(14);
cout << "MAC";
cout.width(17);
cout << "IP Address";
cout.width(17);
cout << "Subnet Mask";
cout.width(15);
cout << "Gateway";
cout.width(8);
cout << "Mode";
cout.width(4);
cout << "IP?";
cout.width(6);
cout << "DHCP?";
cout.width(5);
cout << "LLA?";
cout << endl;
for (DeviceInfoList_t::const_iterator it = lstDevices.begin(); it != lstDevices.end(); ++it )
{
if ( it->IsPersistentIpActive() )
{
activeMode = "Static";
}
else if ( it->IsDhcpActive() )
{
activeMode = "DHCP";
}
else
{
activeMode = "AutoIP";
}
cout.width(32);
cout << it->GetFriendlyName();
cout.width(14);
cout << it->GetMacAddress();
cout.width(17);
cout << it->GetIpAddress();
cout.width(17);
cout << it->GetSubnetMask();
cout.width(15);
cout << it->GetDefaultGateway();
cout.width(8);
cout << activeMode;
cout.width(4);
cout << it->IsPersistentIpSupported();
cout.width(6);
cout << it->IsDhcpSupported();
cout.width(5);
cout << it->IsAutoIpSupported();
cout << endl;
}
exitCode = 1;
}
else
{
if(argc >= 4)
{
subnetMask = argv[3];
}
if(argc >= 5)
{
defaultGateway = argv[4];
}
bool isAuto = (strcmp(argv[2], "AUTO") == 0);
bool isDhcp = (strcmp(argv[2], "DHCP") == 0);
bool isStatic = !isAuto && !isDhcp;
for (DeviceInfoList_t::const_iterator it = lstDevices.begin(); it != lstDevices.end(); ++it )
{
if(macAddress == it->GetMacAddress())
{
userDefinedName = it->GetUserDefinedName();
}
}
ipAddress, subnetMask, defaultGateway, userDefinedName);
if(setOk)
{
cout << "Successfully changed IP configuration via broadcast for device " << macAddress << " to " << ipAddress << endl;
}
else
{
cout << "Failed to change IP configuration via broadcast for device " << macAddress << endl;
cout << "This is not an error. The device may not support broadcast IP configuration." << endl;
}
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
return exitCode;
}
Utility_InstantInterface
This sample is part of the pylon sample solution that can be found under <SDK ROOT>\Development\Samples\C++.
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int exitCode = 0;
try
{
instantInterface.Open();
cout << "Interface opened." << endl;
cout << "Switching power OFF." << endl;
instantInterface.CxpPoCxpStatus.SetValue("Off");
cout << "Switching power ON." << endl;
instantInterface.CxpPoCxpStatus.SetValue("Auto");
cout << "Updating device list." << endl;
instantInterface.DeviceUpdateList.Execute();
double current = instantInterface.CxpPort0Current();
double voltage = instantInterface.CxpPort0Voltage();
double power = instantInterface.CxpPort0Power();
cout << fixed;
cout.precision(2);
cout << "Port 0 :" << endl;
cout << "Current " << current << " mA" << endl;
cout << "Voltage " << voltage << " V" << endl;
cout << "Power " << power << " W" << endl << endl;
instantInterface.Close();
}
{
cerr << "An exception occurred." << endl
exitCode = 1;
}
cerr << endl << "Press enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}