// this is simple offline processing example application // it captures images from camera (using xiAPI) and process them using xiProcAPI #ifdef WIN32 #include "xiApi.h" #else #include #endif #include #include #include using namespace std; #define throw_line(message) {char err[500]="";sprintf(err,"Fatal error: %s in:" __FILE__ "line:%d\n",message,__LINE__);throw err;} #define XI_CARE(func) {XI_RETURN ret=func;char msg[200]="";if (XI_OK!=ret) {sprintf(msg,"Error on " #func " - expected XI_OK. Result:%d\n",ret);throw_line(msg);};} #define THROW_IF_ZERO(val) {if (!val) throw_line("Value "#val"is zero");} void TestOfflineProcessing_UsingAPI_WithCamera() { cout << "TestOfflineProcessing_UsingAPI_WithCamera V3\n"; // images buffer #define MAX_IMAGES 10 unsigned char* src_data[MAX_IMAGES]; XI_IMG image; memset(&image,0,sizeof(image)); image.size = sizeof(XI_IMG); // get images from camera to RAM buffers cout << "Capturing images from camera\n"; HANDLE camh = NULL; DWORD dwNumberOfDevices = 0; XI_CARE(xiGetNumberDevices(&dwNumberOfDevices)); THROW_IF_ZERO(dwNumberOfDevices); XI_CARE(xiOpenDevice(0, &camh)) XI_CARE(xiSetParamInt(camh, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW8)); XI_CARE(xiSetParamInt(camh, XI_PRM_BUFFER_POLICY, XI_BP_SAFE)); // set the same parameters like when camera processing is running online // these parameters will be part of API context list XI_CARE(xiSetParamInt(camh, XI_PRM_EXPOSURE, 10000)); XI_CARE(xiSetParamFloat(camh, XI_PRM_WB_KR, 1.05F)); XI_CARE(xiSetParamFloat(camh, XI_PRM_WB_KG, 1.00F)); XI_CARE(xiSetParamFloat(camh, XI_PRM_WB_KB, 2.10F)); XI_CARE(xiSetParamFloat(camh, XI_PRM_GAMMAY, 1.0F)); XI_CARE(xiSetParamFloat(camh, XI_PRM_SHARPNESS, 1.00F)); // allocate buffers for input images int img_size_bytes=0; XI_CARE(xiGetParamInt(camh, XI_PRM_IMAGE_PAYLOAD_SIZE, &img_size_bytes)); for (int i=0;i