XIMEA API Sample With Start Stop Acquisition¶
This is sample of xiAPI with:
- getting number of connected camera (xiGetNumberDevices)
- start and stop acquisition
#include "stdafx.h"
#include "..\include\xiApi.h"
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)",place,res);goto finish;}
int main ()
{
DWORD dwNumberOfDevices = 0;
HANDLE hMV = INVALID_HANDLE_VALUE;
DWORD size = 0;
XI_RETURN stat=XI_OK;
stat = xiGetNumberDevices(&dwNumberOfDevices);
HandleResult(stat,"xiGetNumberDevices");
stat = xiOpenDevice(0, &hMV);
HandleResult(stat,"xiOpenDevice");
printf("Set PRM_EXPOSURE (integer)\n");
int exposure_us = 10000;
stat = xiSetParam(hMV, XI_PRM_EXPOSURE, &exposure_us, sizeof(DWORD), xiTypeInteger);
HandleResult(stat,"xiSetParam exposure");
stat = xiStartAcquisition(hMV);
HandleResult(stat,"xiStartAcquisition");
XI_IMG image;
image.size = sizeof(XI_IMG);
image.bp = NULL;
image.bp_size = 0;
stat = xiGetImage(hMV, 1000, &image);
HandleResult(stat,"xiGetImage");
printf("Got one image (%dx%d) from camera\n", image.width, image.height);
stat = xiStopAcquisition(hMV);
HandleResult(stat,"xiGetImage");
printf("Success\n");
finish:
if (hMV != INVALID_HANDLE_VALUE)
{
xiCloseDevice(hMV);
}
}