int SensorRealSense::initialize() { std::cout << "SensorRealSense::initialize()" << std::endl; sense_manager = PXCSenseManager::CreateInstance(); if (!sense_manager) { wprintf_s(L"Unable to create the PXCSenseManager\n"); return false; } sense_manager->EnableStream(PXCCapture::STREAM_TYPE_COLOR, D_width/2, D_height/2, 60); sense_manager->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, D_width, D_height, 60); sense_manager->Init(); PXCSession *session = PXCSession::CreateInstance(); PXCSession::ImplDesc desc, desc1; memset(&desc, 0, sizeof(desc)); desc.group = PXCSession::IMPL_GROUP_SENSOR; desc.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; if (session->QueryImpl(&desc, 0, &desc1) < PXC_STATUS_NO_ERROR) return false; PXCCapture * capture; pxcStatus status = session->CreateImpl<PXCCapture>(&desc1, &capture); if(status != PXC_STATUS_NO_ERROR){ QMessageBox::critical(NULL,"FATAL ERROR", "Intel RealSense device not plugged?\n(CreateImpl<PXCCapture> failed)"); exit(0); } PXCCapture::Device* device; device = capture->CreateDevice(0); projection = device->CreateProjection(); this->initialized = true; return true; }
void FEmotionDetector::InitEmotionCapture() { pPXCSession = PXCSession::CreateInstance(); pSenseManager = pPXCSession->CreateSenseManager(); CaptureMgr = pSenseManager->QueryCaptureManager(); pxcCHAR* Device = NULL; PXCSession::ImplDesc desc; memset(&desc, 0, sizeof(desc)); desc.group = PXCSession::IMPL_GROUP_SENSOR; desc.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; for (int i = 0;; i++) { PXCSession::ImplDesc desc1; if (pPXCSession->QueryImpl(&desc, i, &desc1) == PXC_STATUS_NO_ERROR) { PXCCapture *capture; if (pPXCSession->CreateImpl<PXCCapture>(&desc1, &capture) == PXC_STATUS_NO_ERROR) { for (int j = 0;; j++) { PXCCapture::DeviceInfo dinfo; if (capture->QueryDeviceInfo(j, &dinfo) == PXC_STATUS_NO_ERROR) { Device = dinfo.name; break; } } } else { break; } } else { break; } } if (Device != nullptr) { CaptureMgr->FilterByDeviceInfo(Device, 0, 0); pSenseManager->EnableEmotion(); pSenseManager->Init(&Handler); } }
std::vector<unsigned int> RealSenseSensor::connectedSensors() { std::vector<unsigned int> sensors; PXCSession* session = PXCSession::CreateInstance(); PXCSession::ImplDesc desc1 = { }; desc1.group = PXCSession::IMPL_GROUP_SENSOR; desc1.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; for (int m = 0; ; m++) { PXCSession::ImplDesc desc2; if (session->QueryImpl(&desc1, m, &desc2) < PXC_STATUS_NO_ERROR) { break; } std::cout << "Module (" << m << "): " << desc2.friendlyName << std::endl; PXCCapture* capture = 0; if (session->CreateImpl<PXCCapture>(&desc2, &capture) < PXC_STATUS_NO_ERROR) { continue; } for (int d = 0; ; d++) { PXCCapture::DeviceInfo dinfo; if (capture->QueryDeviceInfo(d, &dinfo) < PXC_STATUS_NO_ERROR) { break; } std::cout << "Device (" << d << "): " << dinfo.name << std::endl; if (dinfo.model != PXCCapture::DEVICE_MODEL_F200 && dinfo.model != PXCCapture::DEVICE_MODEL_R200) { continue; } std::string serialStr = toNarrow(dinfo.serial); std::cout << "Found device type: " << std::hex << static_cast<int>(dinfo.model) << " with serial: " << serialStr << std::endl; unsigned int serial = 0; if (tryToNumber(serialStr, serial)) { sensors.push_back(serial); } else { std::cout << "Serial number " << serialStr << " could not be parsed." << std::endl; } } capture->Release(); } session->Release(); return sensors; }
pxcCHAR* GesturePipeline::retrieveDeviceName() { PXCSession::ImplDesc desc; memset(&desc, 0, sizeof(desc)); desc.group = PXCSession::IMPL_GROUP_SENSOR; desc.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; for (int i = 0;; i++) { PXCSession::ImplDesc desc1; if (_pxcSenseManager->QuerySession()->QueryImpl(&desc, i, &desc1) < PXC_STATUS_NO_ERROR) break; PXCCapture * capture = nullptr; if (_pxcSenseManager->QuerySession()->CreateImpl<PXCCapture>(&desc1, &capture) < PXC_STATUS_NO_ERROR) continue; for (int j = 0;; j++) {//may be should use QueryDeviceNum() if there are more than one device connected PXCCapture::DeviceInfo dinfo; if (capture->QueryDeviceInfo(j, &dinfo) < PXC_STATUS_NO_ERROR) break; wcscpy_s(_deviceName[i], dinfo.name); } capture->Release(); } return _deviceName[0]; }