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];
}