pxcStatus CaptureRecording::CreateDevice(pxcU32 didx, Device **device) { PXCCapture::Device *device2=0; pxcStatus sts=capture->CreateDevice(didx,&device2); if (sts>=PXC_STATUS_NO_ERROR) { *device=new CaptureRecording::DeviceRecording(device2,scheduler,types); if (!(*device)) sts=PXC_STATUS_ALLOC_FAILED; } return sts; }
bool IntelPerCStreamBase::initDevice(PXCSession *session) { if (NULL == session) return false; pxcStatus sts = PXC_STATUS_NO_ERROR; PXCSession::ImplDesc templat; memset(&templat,0,sizeof(templat)); templat.group = PXCSession::IMPL_GROUP_SENSOR; templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++) { PXCSession::ImplDesc desc; sts = session->QueryImpl(&templat, modidx, &desc); if (PXC_STATUS_NO_ERROR > sts) break; PXCSmartPtr<PXCCapture> capture; sts = session->CreateImpl<PXCCapture>(&desc, &capture); if (!capture.IsValid()) continue; /* enumerate devices */ for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++) { PXCSmartPtr<PXCCapture::Device> device; sts = capture->CreateDevice(devidx, &device); if (PXC_STATUS_NO_ERROR <= sts) { m_device = device.ReleasePtr(); return true; } } } return false; }
//////////////////////////////////////////////////////////////////////////////// // protected member functions //////////////////////////////////////////////////////////////////////////////// int IntelCamera::InitCamera(int device_num) { // create a session pxcStatus sts = PXCSession_Create(&session); if (sts<PXC_STATUS_NO_ERROR) { fprintf(stderr,"Failed to create a session\n"); return -1; } // create a video capture PXCSession::ImplDesc desc; memset(&desc, 0, sizeof(desc)); desc.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; PXCSmartPtr<PXCCapture> capture; sts = session->CreateImpl(&desc, PXCCapture::CUID, (void**)&capture); if (sts<PXC_STATUS_NO_ERROR) { fprintf(stderr,"Failed to create a capture\n"); return -1; } // create a device PXCSmartPtr<PXCCapture::Device> device; sts = capture->CreateDevice(device_num, &device); if (sts<PXC_STATUS_NO_ERROR) { fprintf(stderr,"Failed to create a device\n"); return -1; } // create color stream: 640x480 sts = device->CreateStream(0, PXCCapture::VideoStream::CUID, (void**)&pColorStream); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to create color stream\n"); return -1; } PXCCapture::VideoStream::ProfileInfo pinfoColor; sts = pColorStream->QueryProfile(0, &pinfoColor); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to get color stream profile\n"); return -1; } // set for less error on depth image : because of sync color/depth pinfoColor.frameRateMax.denominator = 0; pinfoColor.frameRateMax.numerator = 60; pinfoColor.frameRateMin.denominator = 0; pinfoColor.frameRateMin.numerator = 60; sts = pColorStream->SetProfile(&pinfoColor); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to get color stream profile\n"); return -1; } // create depth streams: 320x240 sts = device->CreateStream(1, PXCCapture::VideoStream::CUID, (void**)&pDepthStream); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to create depth stream\n"); return -1; } PXCCapture::VideoStream::ProfileInfo pinfoDepth; sts = pDepthStream->QueryProfile(0, &pinfoDepth); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to get depth stream profile\n"); return -1; } // set for less error on depth image pinfoDepth.frameRateMax.denominator = 1; pinfoDepth.frameRateMax.numerator = 60; pinfoDepth.frameRateMin.denominator = 1; pinfoDepth.frameRateMin.numerator = 60; sts = pDepthStream->SetProfile(&pinfoDepth); if(sts<PXC_STATUS_NO_ERROR){ fprintf(stderr,"failed to get depth stream profile\n"); return -1; } // read streams pColorStream->ReadStreamAsync(&images[0], &sps[0]); pDepthStream->ReadStreamAsync(&images[1], &sps[1]); // get constant values pxcUID prj_value; device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_SMOOTHING, 1); // depth smoothing device->QueryPropertyAsUID(PXCCapture::Device::PROPERTY_PROJECTION_SERIALIZABLE, &prj_value); device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, &no_confidence); device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE , &depth_saturation); // get projection instance sts = session->DynamicCast<PXCMetadata>()->CreateSerializable<PXCProjection>(prj_value, &projection); if (sts<PXC_STATUS_NO_ERROR) { fprintf(stderr,"Failed to create a projection\n"); return -1; } return 1; }