std::shared_ptr<CameraDriverInterface> GetDevice(const Uri& uri) { hal::Uri subUri(uri.url); // pass through properties down the chain subUri.SetProperties( uri.PrintProperties() ); // Create input camera std::shared_ptr<CameraDriverInterface> InCam = DeviceRegistry<hal::CameraDriverInterface>::I().Create(subUri); std::vector<ImageRoi> vROI; const ImageRoi default_roi( 0, 0, InCam->Width(), InCam->Height() ); if( !uri.scheme.compare("split") ) { while(true) { std::stringstream ss; ss << "roi" << (vROI.size() + 1); const std::string key = ss.str(); if(!uri.properties.Contains(key)) { break; } vROI.push_back( uri.properties.Get<ImageRoi>( key, default_roi ) ); } if( vROI.empty() ) { unsigned int nImgWidth = InCam->Width(); unsigned int nImgHeight = InCam->Height(); if( nImgWidth > nImgHeight ) { nImgWidth = nImgWidth / 2; } else { nImgHeight = nImgHeight / 2; } vROI.push_back( ImageRoi( 0, 0, nImgWidth, nImgHeight ) ); vROI.push_back( ImageRoi( nImgWidth, 0, nImgWidth, nImgHeight ) ); } } SplitDriver* pDriver = new SplitDriver( InCam, vROI ); return std::shared_ptr<CameraDriverInterface>( pDriver ); }
std::shared_ptr<CameraDriverInterface> GetDevice(const Uri& uri) { float fps = uri.properties.Get<float>("fps", 0); int exp = uri.properties.Get<int>("exp", 0); float gain = uri.properties.Get<float>("gain", 0.5); std::string mode = uri.properties.Get<std::string>("mode", "MONO8"); ImageDim dims = uri.properties.Get<ImageDim>("size", ImageDim(640,480)); ImageRoi ROI = uri.properties.Get<ImageRoi>("roi", ImageRoi(0,0,0,0)); int sync = uri.properties.Get<int>("sync", 0); int binning = uri.properties.Get<int>("binning", 0); int bus_cams = uri.properties.Get<int>("bus_cams", 0); std::vector<std::string> vector_ids; printf("bus_cams: 0x%x\n", bus_cams); while(true) { std::stringstream ss; ss << "id" << vector_ids.size(); const std::string key = ss.str(); if(!uri.properties.Contains(key)) { break; } vector_ids.push_back(uri.properties.Get<std::string>(key, "")); } if(ROI.w == 0 && ROI.h == 0) { ROI.w = dims.x; ROI.h = dims.y; } XI_IMG_FORMAT xi_mode; if (mode == "RAW8") { xi_mode = XI_RAW8; } else if (mode == "RAW16") { xi_mode = XI_RAW16; } else if (mode == "MONO16") { xi_mode = XI_MONO16; } else if (mode == "RGB24") { xi_mode = XI_RGB24; } else if (mode == "RGB32") { xi_mode = XI_RGB32; }else { xi_mode = XI_MONO8; } XimeaDriver* pDriver = new XimeaDriver(vector_ids, fps, exp, gain, xi_mode, ROI, sync, binning, bus_cams); return std::shared_ptr<CameraDriverInterface>(pDriver); }
PleoraVideo::PleoraVideo(const Params& p): size_bytes(0), lPvSystem(0), lDevice(0), lStream(0), lDeviceParams(0), lStart(0), lStop(0), lTemperatureCelcius(0), getTemp(false), lStreamParams(0), validGrabbedBuffers(0) { std::string sn; std::string mn; int index = 0; size_t buffer_count = PleoraVideo::DEFAULT_BUFFER_COUNT; Params device_params; for(Params::ParamMap::const_iterator it = p.params.begin(); it != p.params.end(); it++) { if(it->first == "model"){ mn = it->second; } else if(it->first == "sn"){ sn = it->second; } else if(it->first == "idx"){ index = p.Get<int>("idx", 0); } else if(it->first == "size") { const ImageDim dim = p.Get<ImageDim>("size", ImageDim(0,0) ); device_params.Set("Width" , dim.x); device_params.Set("Height" , dim.y); } else if(it->first == "pos") { const ImageDim pos = p.Get<ImageDim>("pos", ImageDim(0,0) ); device_params.Set("OffsetX" , pos.x); device_params.Set("OffsetY" , pos.y); } else if(it->first == "roi") { const ImageRoi roi = p.Get<ImageRoi>("roi", ImageRoi(0,0,0,0) ); device_params.Set("Width" , roi.w); device_params.Set("Height" , roi.h); device_params.Set("OffsetX", roi.x); device_params.Set("OffsetY", roi.y); } else { device_params.Set(it->first, it->second); } } InitDevice(mn.empty() ? 0 : mn.c_str(), sn.empty() ? 0 : sn.c_str(), index); SetDeviceParams(device_params); InitStream(); InitPangoStreams(); InitPangoDeviceProperties(); InitBuffers(buffer_count); }