private void initSystem() { ppSystem = new BGAPI.System[0]; pCamera = null; ppImage = new BGAPI.Image[0]; listint = new BGAPI.BGAPIX_TypeListINT(); state = new BGAPI.BGAPI_FeatureState(); intNumberofbuffer = new BGAPI.BGAPIX_TypeINT(); imgcallback = new BGAPI.BGAPI_NOTIFY_CALLBACK(CallbackFunction); //init the system like shown in bgapi_init example res = init_systems(ref system_count, ref ppSystem); ReturnError(res, "init_systems"); }
private static int init_camera(int system_count, ref BGAPI.System[] externppSystem, ref int pCurrSystem, ref BGAPI.Camera externppCamera) { int res = BGAPI.Result.FAIL; int i = 0; int cam = 0; int[] cameras = new int[system_count]; int camera_count = 0; BGAPI.BGAPI_FeatureState state = new BGAPI_FeatureState(); BGAPI.BGAPIX_CameraInfo cameradeviceinfo = new BGAPIX_CameraInfo(); int inputVal = 0; for (i = 0; i < system_count; i++) { //this is an example how to count available cameras for all available systems res = externppSystem[i].countCameras(ref cameras[i]); if (res != BGAPI.Result.OK) { MessageBox.Show(string.Format("countCameras Systemnumber {0} Errorcode: {1}\n", i, res)); return(0); } for (cam = 0; cam < cameras[i]; cam++) { camera_count++; //this is an example how to create a camera res = externppSystem[i].createCamera(cam, ref externppCamera); if (res != BGAPI.Result.OK) { MessageBox.Show(string.Format("\n")); MessageBox.Show(string.Format("createCamera Systemnumber {0} Errorcode: {1}\n", i, res)); return(res); } //this is an example how to get the device information for a camera res = externppCamera.getDeviceInformation(ref state, ref cameradeviceinfo); if (res != BGAPI.Result.OK) { MessageBox.Show(string.Format("\n")); MessageBox.Show(string.Format("getDeviceInformation Errorcode: {0}\n", res)); return(0); } MessageBox.Show(string.Format("{0} select Camera {1} of system {2} - {3} SN: {4}\n", camera_count, cam, i, cameradeviceinfo.modelName, cameradeviceinfo.serialNumber)); externppSystem[i].releaseCamera(ref externppCamera); } } do { //[TODO] CUSTOM SELECTOR inputVal = 1; //inputVal = Convert.ToInt32(Console.ReadLine(), 10); }while (inputVal < 0 || inputVal > camera_count); camera_count = 0; for (i = 0; i < system_count; i++) { for (cam = 0; cam < cameras[i]; cam++) { camera_count++; if (camera_count == inputVal) { pCurrSystem = i; //this is an example how to create a camera res = externppSystem[pCurrSystem].createCamera(cam, ref externppCamera); if (res != BGAPI.Result.OK) { MessageBox.Show(string.Format("createCamera Systemnumber {0} Errorcode: {1}\n", i, res)); return(res); } //this is an example how to open a camera res = externppCamera.open(); if (res != BGAPI.Result.OK) { MessageBox.Show(string.Format("open Systemnumber {0} Errorcode: {1}\n", i, res)); return(res); } break; } } } return(res); }