Linux example: This object-oriented example demonstrates how to acquire data from an PI imager and use callback methods of a derived class.
Linux example: This object-oriented example demonstrates how to acquire data from an PI imager and use callback methods of a derived class.
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <pthread.h>
#include <sys/time.h>
#include <signal.h>
#include "IRDevice.h"
#include "IRImager.h"
#include "FramerateCounter.h"
#include "IRLogger.h"
#include "IRImagerHandler.h"
#include "IRImagerGUI.h"
using namespace std;
using namespace evo;
int main (int argc, char* argv[])
{
if(argc!=2)
{
cout << "usage: " << argv[0] << " <xml configuration file>" << endl;
return -1;
}
IRLogger::setVerbosity(IRLOG_ERROR, IRLOG_OFF);
IRDeviceParamsReader::readXML(argv[1], params);
IRDevice* dev = NULL;
dev = IRDevice::IRCreateDevice(params);
if(imager.
init(¶ms, dev->getFrequency(), dev->getWidth(), dev->getHeight(), dev->controlledViaHID()))
{
if(w==0 || h==0)
{
cout << "Error: Image streams not available or wrongly configured. Check connection of camera and config file." << endl;
return -1;
}
cout << "Connected camera, serial: " << dev->getSerial()
cout <<
"Thermal channel: " << w <<
"x" << h <<
"@" << params.
framerate <<
"Hz" << endl;
IRImagerHandler handler(dev, &imager);
if(dev->startStreaming()!=0)
{
cout << "Error occurred in starting stream ... aborting. You may need to reconnect the camera." << endl;
exit(-1);
}
while(gui.isAlive())
{
if(handler.checkForNewFrame())
{
if(gui.wantsThermalChannel())
gui.setThermalImage(handler.getThermalImage(), handler.getThermalWidth(), handler.getThermalHeight());
else
gui.setVisibleImage(handler.getVisibleImage(), handler.getVisibleWidth(), handler.getVisibleHeight());
}
if(gui.popManualFlagEvent())
if(gui.popSerializeEvent())
{
unsigned char* ppm;
unsigned int size;
gui.getSnapshot(ppm, size);
ofstream file("/tmp/snapshot.ppm", std::ios::binary);
file.write((const char*) ppm, size);
delete [] ppm;
}
cout <<
"Framerate: " << fpsStream.
getFps() <<
" fps" << endl;
}
dev->stopStreaming();
}
cout << "Exiting application" << endl;
delete dev;
return 0;
}
Framerate calculation helper.
Definition: FramerateCounter.h:33
bool trigger(double *fps=NULL)
Trigger, i.e., integrate new measurement.
double getFps()
Accessor to current frames per second rate (no triggering is performed)
Wrapper for PI driver and image processing library.
Definition: IRImager.h:141
short getTemprangeDecimal() const
Returns the number of decimal places in thermal data.
bool init(IRDeviceParams *params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0)
Initializing routine, to be called after instantiation.
bool hasBispectralTechnology() const
Check if bispectral technology is available.
unsigned int getHeight() const
Get image height of thermal channel.
void forceFlagEvent(float time=0.f)
Force shutter flag event manually (close/open cycle)
unsigned int getVisibleWidth() const
Get image width of visible channel (if available)
unsigned int getVisibleHeight() const
Get image height of visible channel (if available)
unsigned int getFWRevision() const
Get firmware revision.
unsigned int getHWRevision() const
Get hardware revision.
unsigned int getWidth() const
Get image width of thermal channel.
Structure containing device parameters.
Definition: IRDeviceParams.h:125
float framerate
Definition: IRDeviceParams.h:134