rendered paste body__EXPORT uns32 GetPicture(int16 hcam, uns32 exposure_id, unsigned short (*argData)[1400][1400])
{
unsigned long lPVCAMBufferSize;
unsigned short xdimension = 1040;
unsigned short ydimension = 1392;
rgn_type tRegion;
unsigned short* pData = NULL;
uns32 uns32_param = 0;
//if ((ydimension > 0 && xdimension > 0) && (ydimension < 20000 && xdimension < 20000))
{
tRegion.s1 = (unsigned short)1;
tRegion.s2 = (unsigned short)ydimension;
tRegion.sbin = 1;
tRegion.p1 = (unsigned short)1;
tRegion.p2 = (unsigned short)xdimension;
tRegion.pbin = (unsigned short)1;
pl_exp_init_seq();
pl_exp_setup_seq(hcam,1,1,&tRegion, exposure_id, (unsigned long)1.0 ,&lPVCAMBufferSize);
short status = 0;
unsigned short bResult;
unsigned long bytes;
if (!pl_buf_init()) {
AddError("Cam: %i exposure id: %i Unable to free the camera buffer", hcam, exposure_id);
}
if (pData != NULL)
{
delete pData;
}
pData = new unsigned short[lPVCAMBufferSize];
bResult = pl_exp_start_seq(hcam, pData);
if (bResult == FALSE)
{
AfxMessageBox("Start camera running failed");
return 1;
}
while (1)
{
bResult = pl_exp_check_status(hcam, &status, &bytes);
if (bResult == false)
{
AddError("Cam: %i exposure id: %i Error while reading exposure status", hcam, exposure_id);
return 1;
}
else
{
if (status == READOUT_FAILED)
{
AddError("READOUT_FAILED");
return 1;
}
if (status == READOUT_COMPLETE)
{
AddError("Cam: %i exposure id: %i camera readout complete)", hcam, exposure_id);
break;
}
}
}
pl_get_param(hcam, PARAM_EXPOSURE_MODE, ATTR_CURRENT, (void *)&uns32_param);
pl_exp_finish_seq( hCam, pData, 0);
pl_exp_uninit_seq();
}
// Fill the output value
for(int iY = 0;iY <= ydimension;iY++)
{ // Y dimension
for (int iX = 0;iX <= xdimension;iX++)
{ // X dimension
(*argData)[iY][iX] = pData[((iY*xdimension)+iX)];
}
}
return 0;
}
int main(int argc, char* argv[])
{
if (Openlib())
printf("[Ok] Open library.\n");
else
{
printf("[Err] Open library.\n");
goto close;
}
if (Opencam(0))
printf("[Ok] Open Camera.\n");
else
{
printf("[Err] Open Camera.\n");
goto close;
}
//unsigned short pData[1400][1400];
//unsigned short *pData;
//pData = malloc(sizeof(unsigned short)*1400*1400);
if (Init(0))
{
printf("[Ok] Init Camera.\n");
GetPicture(0, 0, &pData);
}
else
{
printf("[Err] Init Camera.\n");
goto close;
}
if (CloseCam(0))
printf("[Ok] Camera closed.\n");
else
printf("[Err] Camera closed.\n");
if (Closelib())
printf("[Ok] Library closed.\n");
else
printf("[Err] Library closed.\n");
close:
PressEnter();
return 0;
}