예제 #1
0
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;
}
예제 #2
0
void foo1()
{
	PXCSession *session;
	PXCSession_Create(&session);

	// session is a PXCSession instance
	PXCSession::ImplDesc desc1;
	memset(&desc1,0,sizeof(desc1));
	desc1.group=PXCSession::IMPL_GROUP_SENSOR;
	desc1.subgroup=PXCSession::IMPL_SUBGROUP_AUDIO_CAPTURE;

	vector<std::wstring> deviceNames;
	for (int m=0;;m++) {
		PXCSession::ImplDesc desc2;
		if (session->QueryImpl(&desc1,m,&desc2)<PXC_STATUS_NO_ERROR) break;

		PXCSmartPtr<PXCCapture> capture;
		if (session->CreateImpl<PXCCapture>(&desc2,&capture)<PXC_STATUS_NO_ERROR) continue;
		for (int d=0;;d++) {
			PXCCapture::DeviceInfo dinfo;
			if (capture->QueryDevice(d,&dinfo)<PXC_STATUS_NO_ERROR) break;
			std::wstring dname(dinfo.name);
			deviceNames.push_back(dname);
		}
	}

	// display devices and require a selection
	int deviceNum = deviceNames.size();
	int selectedDeviceId = 0;
	wprintf_s(L"Device list:\n");
	for (int i = 0; i < deviceNum; i++)
	{
		wprintf_s(L"Device[%d]: %s\n",i,deviceNames[i].c_str());
	}
	if (deviceNum > 0)
	{
		while (true)
		{
			wprintf_s(L"Please select a device from [0]~[%d]\n", deviceNum-1);
			cin >> selectedDeviceId;
			if (selectedDeviceId > -1 && selectedDeviceId < deviceNum)
			{
				wprintf_s(L"You selected device: [%d]%s\n", selectedDeviceId, deviceNames[selectedDeviceId].c_str());
				break;
			}
		}
	}
	else
	{
예제 #3
0
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;
}