// Enumerate connected devices void CvCaptureCAM_XIMEA::init() { #if defined WIN32 || defined _WIN32 xiGetNumberDevices( &numDevices); #else // try second re-enumeration if first one fails if (xiGetNumberDevices( &numDevices) != XI_OK) { xiGetNumberDevices( &numDevices); } #endif hmv = NULL; frame = NULL; timeout = 0; memset(&image, 0, sizeof(XI_IMG)); }
// Enumerate connected devices void CvCaptureCAM_XIMEA::init() { xiGetNumberDevices( &numDevices); hmv = NULL; frame = NULL; timeout = 0; memset(&image, 0, sizeof(XI_IMG)); }
void CaptureCAM_XIMEA::init() { stat = xiGetNumberDevices(&numDevices); // cout << "Number of connected devices: " << numDevices << endl; HandleResult(stat,"xiGetNumberDevices (no camera found)"); try{ if (!numDevices) { throw "No camera found\n"; } hmv = NULL; isopened=false; timeout = 0; memset(&image, 0, sizeof(XI_IMG)); }catch(const char* e){ cout<< "An Exception occured. Exception: "<<e<<endl; close(); } }
std::vector<CameraInfo> CameraXIMEA::getCameraList(){ XI_RETURN stat = XI_OK; DWORD numCams; stat = xiGetNumberDevices(&numCams); HandleResult(stat, "xiGetNumberDevices"); std::vector<CameraInfo> ret(numCams); for(unsigned int i=0; i<numCams; i++){ CameraInfo info; info.vendor = "Ximea"; char name[20]; xiGetDeviceInfoString(i, XI_PRM_DEVICE_NAME, name, 20); info.model = name; info.busID = i; ret[i] = info; } return ret; }
void CRCamera::initialize() { DWORD dwNumberOfDevices = 0; float maxFps; xiGetNumberDevices(&dwNumberOfDevices); if (!dwNumberOfDevices) { LOG("Camera was NOT found."); } xiOpenDevice(0, &this->xiH); int exposure = (int)(1000000.0 / Global::crConfig->frameRate); xiSetParamInt(this->xiH, XI_PRM_EXPOSURE, exposure); xiGetParamFloat(this->xiH, XI_PRM_FRAMERATE XI_PRM_INFO_MAX, &maxFps); LOG("Max framerate : %f [fps]", maxFps); LOG("Exposure time : %d [us]", exposure); xiSetParamInt(this->xiH, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FRAME_RATE); xiSetParamFloat(this->xiH, XI_PRM_FRAMERATE, Global::crConfig->frameRate); xiSetParamInt(this->xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24); }
bool Camera::open(int serial) { std::cout << "! Searching for a camera with serial: " << serial << std::endl; DWORD deviceCount = 0; xiGetNumberDevices(&deviceCount); if (deviceCount == 0) { std::cout << "- Failed to detect any cameras" << std::endl; return false; } if (serial != 0) { std::cout << " > found " << deviceCount << " available devices" << std::endl; } int sn = 0; bool found = false; for (unsigned int i = 0; i < deviceCount; i++) { std::cout << " > opening camera #" << i << ".. "; xiOpenDevice(i, &device); std::cout << "done!" << std::endl; xiGetParamInt(device, XI_PRM_DEVICE_SN, &sn); std::cout << " > found camera with serial number: " << sn << ".. "; if (serial == 0 || serial == sn) { found = true; std::cout << "match found!" << std::endl; break; } else { std::cout << "not the right one, closing it" << std::endl; xiCloseDevice(device); } } if (!found) { std::cout << "- No camera with serial #" << serial << " could be found" << std::endl; return false; } xiSetParamInt(device, XI_PRM_EXPOSURE, 16000); //xiSetParamInt(device, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8); //xiSetParamInt(device, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24); xiSetParamInt(device, XI_PRM_BUFFER_POLICY, XI_BP_UNSAFE); //xiSetParamInt(device, XI_PRM_FRAMERATE, 60); //xiSetParamInt(device, XI_PRM_DOWNSAMPLING, 2); // @TEMP //xiSetParamInt(device, XI_PRM_DOWNSAMPLING_TYPE, XI_BINNING); //xiSetParamFloat(device, XI_PRM_GAIN, 5.0f); //xiSetParamInt(device, XI_PRM_ACQ_BUFFER_SIZE, 70*1000*1000); xiSetParamInt(device, XI_PRM_BUFFERS_QUEUE_SIZE, 1); //xiSetParamInt(device, XI_PRM_RECENT_FRAME, 1); xiSetParamInt(device, XI_PRM_AUTO_WB, 0); //xiSetParamFloat(device, XI_PRM_WB_KR, 1.0f); //xiSetParamFloat(device, XI_PRM_WB_KG, 1.0f); //xiSetParamFloat(device, XI_PRM_WB_KB, 1.0f); //xiSetParamFloat(device, XI_PRM_GAMMAY, 1.0f); //xiSetParamFloat(device, XI_PRM_GAMMAC, 1.0f); //xiSetParamFloat(device, XI_PRM_SHARPNESS, 0.0f); xiSetParamInt(device, XI_PRM_AEAG, 0); //xiSetParamInt(device, XI_PRM_BPC, 1); // fixes bad pixel //xiSetParamInt(device, XI_PRM_HDR, 1); opened = true; serialNumber = serial; return true; }
// Enumerate connected devices void CvCaptureCAM_XIMEA::init() { xiGetNumberDevices( &numDevices); hmv = NULL; }