Windows example: This minimal example demonstrates how to acquire data from an PI imager and serialize it to disk.
Windows example: This minimal example demonstrates how to acquire data from an PI imager and serialize it to disk. Raw data can be imported to PIConnect.
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <signal.h>
#include "IRDevice.h"
#include "IRImager.h"
#include "IRLogger.h"
#include "IRFileWriter.h"
#include "Timer.h"
using namespace std;
using namespace evo;
bool _keepCapturing = true;
int _serializedImages = 0;
int _chunk = 1;
int main (int argc, char* argv[])
{
if (argc != 2)
{
cout << "usage: " << argv[0] << " <xml configuration file>" << endl;
return -1;
}
char* args = argv[1];
size_t argSize = strlen(args) + 1, converted;
wchar_t* argPath = new wchar_t[argSize];
mbstowcs_s(&converted, argPath, argSize, args, argSize);
if (!IRDeviceParamsReader::readXML(argPath, params))
return -1;
delete[] argPath;
IRDevice* dev = IRDevice::IRCreateDevice(params);
if (dev)
{
if (imager.
init(¶ms, dev->getFrequency(), dev->getWidth(), dev->getHeight(), dev->controlledViaHID()))
{
{
if (dev->startStreaming() == 0)
{
double timestamp;
unsigned char* bufferRaw = new unsigned char[dev->getRawBufferSize()];
IRFileWriter writer(time(NULL), ".", header);
writer.open();
char nmea[GPSBUFFERSIZE];
memset(nmea, 0, GPSBUFFERSIZE * sizeof(*nmea));
int serializedImages = 0;
int chunk = 1;
while (_keepCapturing)
{
if (dev->getFrame(bufferRaw, ×tamp) == IRIMAGER_SUCCESS)
{
if (writer.canDoWriteOperations())
writer.write(timestamp, bufferRaw, chunk, dev->getRawBufferSize(), nmea);
if ((++serializedImages) % 1000 == 0)
{
chunk++;
}
}
}
delete[] bufferRaw;
}
else
{
cout << "Error occurred in starting stream ... aborting. You may need to reconnect the camera." << endl;
}
}
}
else
{
cout << "Error: Image streams not available or wrongly configured. Check connection of camera and config file." << endl;
}
delete dev;
}
return 0;
}
Wrapper for PI driver and image processing library.
Definition: IRImager.h:141
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.
unsigned int getHeight() const
Get image height of thermal channel.
void forceFlagEvent(float time=0.f)
Force shutter flag event manually (close/open cycle)
void process(unsigned char *buffer, void *arg=NULL)
Process raw data.
void initRawdataHeader(RawdataHeader &header) const
Initialize Rawdata header with camera specific parameters.
float getMaxFramerate() const
Get maximum frame rate of device return frame rate (in frames/second)
unsigned int getWidth() const
Get image width of thermal channel.
Structure containing device parameters.
Definition: IRDeviceParams.h:125