La telecamera usa lo standard GigE ( è fornita di driver che - meno male - funziona)
Vi allego il sorgente che mi ha mandato il costruttore.
#include <stdio.h>
#include <SDK4AcquireApi.h>
#include <SDK4ControlTypes.h>
#include <SDK4H3XRApi.h>
#include <vector>
#include <iostream>
#include <string.h>
using namespace std;
#define _CHECK(f) {SDK4_ERROR err=(f);if(SDK4_ERR_SUCCESS!=err){cerr<< #f <<" failed: "<<err<<endl;goto Exit;}}
int main()
{
bool bOpen=false;
int choice;
static char sModel[256];
int32_t sizeModel=sizeof(sModel);
char sClassId[256];
int32_t sizeClassId=sizeof(sClassId);
vector<string> devnames;
int32_t numDevices=0;
BUFFER_HANDLE hBuffer[5];
uint32_t uPayloadSize=0;
//image parms
int32_t width=0;
int32_t height=0;
ENUM_PIXELFORMAT format=0;
//Stat
int nComplete=0;
int nIncomplete=0;
int nTimedOut=0;
cout << "[SDK4 Acquire SLX CAT] " << endl ;
_CHECK(SDK4InitLib());
_CHECK(SDK4GetNumDevices(&numDevices));
cout << endl << "Select camera device:" << endl << endl;
for(uint32_t i = 0; i < numDevices; i++)
{
char sName[256];
int32_t sizeName=sizeof(sName);
_CHECK(SDK4GetDeviceID(i,sName,&sizeName));
cout << "[" << i+1 << "] " << sName << endl;
devnames.push_back(sName);
}
cout << endl << "[0 to quit] =>";
cin >> choice; if(!choice) goto Exit;
DEV_HANDLE hDev;
DS_HANDLE hDataStream;
_CHECK(SDK4OpenDevice(devnames[choice-1].c_str(),DEVICEACCESS_EXCLUSIVE,&hDev));
//Device
_CHECK(SDK4DevGetClassID(hDev,sClassId,&sizeClassId));
_CHECK(SDK4DevGetModel(hDev,sModel,&sizeModel));
_CHECK(SDK4DevGetDataStream(hDev,&hDataStream));
//DataStream
_CHECK(SDK4DSGetWidth(hDataStream,&width));
_CHECK(SDK4DSGetHeight(hDataStream,&height));
_CHECK(SDK4DSGetPixelFormat(hDataStream,&format));
_CHECK(SDK4DSGetPayloadSize(hDataStream,&uPayloadSize));
cout << endl;
cout << "ClassID = " << sClassId << endl;
cout << "Model = " << sModel << endl;
cout << endl;
cout << "Width = " << dec << width << endl;
cout << "Height = " << dec << height << endl;
cout << "Format = " << hex << format << endl ;
cout << "PayloadSize = " << dec << uPayloadSize << endl<< endl;
for(int i=0;i<5;i++)
{
_CHECK(SDK4DSAllocAndAnnounceBuffer(hDataStream,uPayloadSize,NULL,&hBuffer));
_CHECK(SDK4DSQueueBuffer(hDataStream,hBuffer));
}
_CHECK(SDK4DevStartAcquisition(hDev));
for(int n=0;n<100;n++)
{
BUFFER_HANDLE hTempBuffer;
void* pBuffer;
uint32_t size;
int32_t bComplete;
SDK4_ERROR err=SDK4DSWaitForBuffer(hDataStream,&hTempBuffer,500);
switch(err)
{
case SDK4_ERR_SUCCESS:
_CHECK(SDK4BufferGetPtr(hTempBuffer,&pBuffer));
_CHECK(SDK4BufferGetSize(hTempBuffer,&size));
_CHECK(SDK4BufferIsComplete(hTempBuffer,&bComplete));
if(bComplete)
{
nComplete++;
}
else
{
nIncomplete++;
}
//DoWork ...
//Queue Buffer again
_CHECK(SDK4DSQueueBuffer(hDataStream,hTempBuffer));
break;
case SDK4_ERR_TIMEOUT:
nTimedOut++;
break;
default:
break;
}
}
_CHECK(SDK4DevStopAcquisition(hDev));
std::cout << "Frames acquisiti: Completi="<<nComplete << " Incompleti="<<nIncomplete << " TimedOut="<< nTimedOut << std::endl;
_CHECK(SDK4DSFlushQueue(hDataStream));
for(int i=0;i<5;i++)
{
_CHECK(SDK4DSRevokeBuffer(hDataStream,hBuffer,NULL,NULL));
}
_CHECK(SDK4CloseDevice(hDev));
Exit:
_CHECK(SDK4CloseLib());
return 0;
}