当前位置: 首页>>代码示例>>C++>>正文


C++ openni::Device类代码示例

本文整理汇总了C++中openni::Device的典型用法代码示例。如果您正苦于以下问题:C++ Device类的具体用法?C++ Device怎么用?C++ Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Device类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: openDevice

openni::Status openDevice(const char* uri, bool defaultRightColor)
{
	openni::Status nRetVal = openni::OpenNI::initialize();
	if (nRetVal != openni::STATUS_OK)
	{
		return nRetVal;
	}

	// Register to OpenNI events.
	static OpenNIDeviceListener deviceListener;
	
	openni::OpenNI::addDeviceDisconnectedListener(&deviceListener);
	openni::OpenNI::addDeviceStateChangedListener(&deviceListener);

	// Open the requested device.
	nRetVal = g_device.open(uri);
	if (nRetVal != openni::STATUS_OK)
	{
		return nRetVal;
	}

	g_pPlaybackControl = g_device.getPlaybackControl();

	openCommon(g_device, defaultRightColor);

	return openni::STATUS_OK;
}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:27,代码来源:Device.cpp

示例2: openDevice

openni::Status openDevice(const char* uri, DeviceConfig config)
{
	openni::Status nRetVal = openni::OpenNI::initialize();
	if (nRetVal != openni::STATUS_OK)
	{
		return nRetVal;
	}

	// Register to OpenNI events.
	static OpenNIDeviceListener deviceListener;
	
	openni::OpenNI::addDeviceDisconnectedListener(&deviceListener);
	openni::OpenNI::addDeviceStateChangedListener(&deviceListener);

	// Open the requested device.
	nRetVal = g_device.open(uri);
	if (nRetVal != openni::STATUS_OK)
	{
		return nRetVal;
	}

	if (0 != openCommon(g_device, config))
	{
		return openni::STATUS_ERROR;
	}

	// If we are here, then the depth camera has been opened okay.
	// Now let's try the sixense, if requested
	if (config.b_captureSixense) {
		return openSixenseDevice();
	}

	return openni::STATUS_OK;
}
开发者ID:malcolmreynolds,项目名称:OpenNI2,代码行数:34,代码来源:Device.cpp

示例3: onDeviceDisconnected

	virtual void onDeviceDisconnected(const openni::DeviceInfo* pInfo)
	{
		if (strcmp(pInfo->getUri(), g_device.getDeviceInfo().getUri()) == 0)
		{
			setErrorState("Device disconnected!");
		}
	}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:7,代码来源:Device.cpp

示例4: closecamera

void KinectCamera::closecamera(void)
{
    mColorStream.destroy();
    mDepthStream.destroy();
    mDevice.close();
    openni:: OpenNI::shutdown();
}
开发者ID:zing235,项目名称:kinect-test-onlycolor-qml,代码行数:7,代码来源:kinectcamera.cpp

示例5: openDevice

openni::Status openDevice(const char* uri, DeviceConfig config)
{
    openni::Status nRetVal = openni::OpenNI::initialize();
    if (nRetVal != openni::STATUS_OK)
    {
        return nRetVal;
    }

    // Register to OpenNI events.
    static OpenNIDeviceListener deviceListener;

    openni::OpenNI::addDeviceDisconnectedListener(&deviceListener);
    openni::OpenNI::addDeviceStateChangedListener(&deviceListener);

    // Open the requested device.
    nRetVal = g_device.open(uri);
    if (nRetVal != openni::STATUS_OK)
    {
        return nRetVal;
    }

    if (0 != openCommon(g_device, config))
    {
        return openni::STATUS_ERROR;
    }

    return openni::STATUS_OK;
}
开发者ID:higuchi-yuuki,项目名称:OpenNI2,代码行数:28,代码来源:Device.cpp

示例6: openCommon

int openCommon(openni::Device& device, DeviceConfig config)
{
    g_pPlaybackControl = g_device.getPlaybackControl();

    int ret;

    ret = openStream(device, "depth", openni::SENSOR_DEPTH, config.openDepth, g_depthStream, &g_depthSensorInfo, &g_bIsDepthOn);
    if (ret != 0)
    {
        return ret;
    }

    ret = openStream(device, "color", openni::SENSOR_COLOR, config.openColor, g_colorStream, &g_colorSensorInfo, &g_bIsColorOn);
    if (ret != 0)
    {
        return ret;
    }

    ret = openStream(device, "IR", openni::SENSOR_IR, config.openIR, g_irStream, &g_irSensorInfo, &g_bIsIROn);
    if (ret != 0)
    {
        return ret;
    }

    initConstants();

    readFrame();

    return 0;
}
开发者ID:higuchi-yuuki,项目名称:OpenNI2,代码行数:30,代码来源:Device.cpp

示例7: VideoException

openni::VideoMode OpenNi2Video::FindOpenNI2Mode(
    openni::Device & device,
    openni::SensorType sensorType,
    int width, int height,
    int fps, openni::PixelFormat fmt
) {
    // Query supported modes for device
    const openni::Array<openni::VideoMode>& modes =
            device.getSensorInfo(sensorType)->getSupportedVideoModes();

    // Select last listed mode which matches parameters
    int best_mode = -1;
    for(int i = 0; i < modes.getSize(); i++) {
        if( (!width || modes[i].getResolutionX() == width) &&
            (!height || modes[i].getResolutionY() == height) &&
            (!fps || modes[i].getFps() == fps) &&
            (!fmt || modes[i].getPixelFormat() == fmt)
        ) {
            best_mode = i;
        }
    }

    if(best_mode >= 0) {
        return modes[best_mode];
    }

    throw pangolin::VideoException("Video mode not supported");
}
开发者ID:mp3guy,项目名称:Pangolin,代码行数:28,代码来源:openni2.cpp

示例8: openDeviceFromList

openni::Status openDeviceFromList(bool defaultRightColor)
{
	openni::Status rc = openni::OpenNI::initialize();
	if (rc != openni::STATUS_OK)
	{
		return rc;
	}

	openni::Array<openni::DeviceInfo> deviceList;
	openni::OpenNI::enumerateDevices(&deviceList);

	for (int i = 0; i < deviceList.getSize(); ++i)
	{
		printf("[%d] %s [%s] (%s)\n", i+1, deviceList[i].getName(), deviceList[i].getVendor(), deviceList[i].getUri());
	}

	printf("\n");
	int chosen = 1;

	do
	{
		printf("Choose device to open (1) [0 to exit]: ");

		int rc = scanf("%d", &chosen);

		if (rc <= 0 || chosen == 0)
		{
			return openni::STATUS_ERROR;
		}

	} while (chosen < 1 || chosen > deviceList.getSize());

	g_device.open(deviceList[chosen-1].getUri());

	if (rc != openni::STATUS_OK)
	{
		return rc;
	}

	g_pPlaybackControl = g_device.getPlaybackControl();

	openCommon(g_device, defaultRightColor);

	return openni::STATUS_OK;
}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:45,代码来源:Device.cpp

示例9: openStream

int openStream(openni::Device& device, const char* name, openni::SensorType sensorType, SensorOpenType openType, openni::VideoStream& stream, const openni::SensorInfo** ppSensorInfo, bool* pbIsStreamOn)
{
    *ppSensorInfo = device.getSensorInfo(sensorType);
    *pbIsStreamOn = false;

    if (openType == SENSOR_OFF)
    {
        return 0;
    }

    if (*ppSensorInfo == NULL)
    {
        if (openType == SENSOR_ON)
        {
            printf("No %s sensor available\n", name);
            return -1;
        }
        else
        {
            return 0;
        }
    }

    openni::Status nRetVal = stream.create(device, sensorType);
    if (nRetVal != openni::STATUS_OK)
    {
        if (openType == SENSOR_ON)
        {
            printf("Failed to create %s stream:\n%s\n", openni::OpenNI::getExtendedError(), name);
            return -2;
        }
        else
        {
            return 0;
        }
    }

    nRetVal = stream.start();
    if (nRetVal != openni::STATUS_OK)
    {
        stream.destroy();

        if (openType == SENSOR_ON)
        {
            printf("Failed to start depth stream:\n%s\n", openni::OpenNI::getExtendedError());
            return -3;
        }
        else
        {
            return 0;
        }
    }

    *pbIsStreamOn = true;

    return 0;
}
开发者ID:higuchi-yuuki,项目名称:OpenNI2,代码行数:57,代码来源:Device.cpp

示例10: startcamera

void KinectCamera::startcamera(void)
{
    openni::OpenNI::initialize();//初始化
    mDevice.open( openni::ANY_DEVICE );//打开设备(已在全局变量中声明设备mDevice)
    mColorStream.create( mDevice, openni::SENSOR_COLOR );// 创建数据流
    mColorStream.start();//开启数据流
    mDepthStream.create( mDevice, openni::SENSOR_DEPTH );// 创建数据流
    mDepthStream.start();//开启数据流
    fig=1;
}
开发者ID:zing235,项目名称:kinect-test-onlycolor-qml,代码行数:10,代码来源:kinectcamera.cpp

示例11: closeDevice

void closeDevice()
{
	g_depthStream.stop();
	g_colorStream.stop();
	g_irStream.stop();

	g_depthStream.destroy();
	g_colorStream.destroy();
	g_irStream.destroy();

	g_device.close();

	openni::OpenNI::shutdown();
}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:14,代码来源:Device.cpp

示例12: onDeviceStateChanged

	virtual void onDeviceStateChanged(const openni::DeviceInfo* pInfo, openni::DeviceState errorState)
	{
		if (strcmp(pInfo->getUri(), g_device.getDeviceInfo().getUri()) == 0)
		{
			if (errorState != 0)
			{
				setErrorState("Device is in error state! (error %d)", errorState);
			}
			else
			{
				setErrorState("");
			}
		}
	}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:14,代码来源:Device.cpp

示例13: initialize

int SensorOpenNI::initialize()
{
    LOG(INFO) << "Initializing OpenNI";
    ///< force shutdown before starting!!
    kinect::OpenNI::shutdown();

    kinect::Status rc;
    rc = kinect::STATUS_OK;

    /// Fetch the device URI to pass to Device::open()
    const char* deviceURI = kinect::ANY_DEVICE;

    /// Initialize the device
    rc = kinect::OpenNI::initialize();
    if(rc!=kinect::STATUS_OK)
    {
        mDebug()<<"Initialization Errors (if any): "<< kinect::OpenNI::getExtendedError();
        kinect::OpenNI::shutdown();
        exit(0);
    }

    /// Open the device using the previously fetched device URI
    rc = device.open(deviceURI);
    if (rc != kinect::STATUS_OK)
    {
        mDebug()<<"Device open failed: "<<kinect::OpenNI::getExtendedError();
        kinect::OpenNI::shutdown();
        exit(0);
    }

    /// Create the depth stream
    rc = g_depthStream.create(device, kinect::SENSOR_DEPTH);
    if (rc == kinect::STATUS_OK)
    {
        /// start the depth stream, if its creation was successful
        rc = g_depthStream.start();

        if (rc != kinect::STATUS_OK)
        {
            mDebug()<<"Couldn't start depth stream: "<<kinect::OpenNI::getExtendedError();
            g_depthStream.destroy();
            exit(0);
        }
    }
    else
    {
        mDebug()<<"Couldn't find depth stream: "<<kinect::OpenNI::getExtendedError();
        exit(0);
    }

    if (!g_depthStream.isValid())
    {
        mDebug()<<"No valid depth streams. Exiting";
        kinect::OpenNI::shutdown();
        exit(0);
    }

    /// Create the color stream
    rc = g_colorStream.create(device, kinect::SENSOR_COLOR);

    if (rc == kinect::STATUS_OK)
    {
        /// start the color stream, if its creation was successful
        rc = g_colorStream.start();

        if (rc != kinect::STATUS_OK)
        {
            mDebug()<<"Couldn't start color stream: "<<kinect::OpenNI::getExtendedError();
            g_colorStream.destroy();
            exit(0);
        }
    }
    else
    {
        mDebug()<<"Couldn't find color stream: "<<kinect::OpenNI::getExtendedError();
        exit(0);
    }

    if (!g_colorStream.isValid())
    {
        mDebug()<<"No valid color streams. Exiting";
        kinect::OpenNI::shutdown();
        exit(0);
    }

    /// Configure resolutions
    {
        /// Attempt to set for depth
        {
            kinect::VideoMode mode = g_depthStream.getVideoMode();
            if(((int)camera->FPS())==60)
                mode.setFps(60);
            else
                mode.setFps(30);
            mode.setResolution(camera->width(), camera->height());
            rc = g_depthStream.setVideoMode(mode);
            if (rc != kinect::STATUS_OK)
                std::cerr << "error setting video mode (depth)" << std::endl;
        }
        /// Attempt to set for color
//.........这里部分代码省略.........
开发者ID:OpenGP,项目名称:htrack,代码行数:101,代码来源:Sensor_openni.cpp

示例14: openCommon

void openCommon(openni::Device& device, bool defaultRightColor)
{
	XnStatus nRetVal = XN_STATUS_OK;

	g_bIsDepthOn = false;
	g_bIsColorOn = false;
	g_bIsIROn    = false;

	g_depthSensorInfo = device.getSensorInfo(openni::SENSOR_DEPTH);
	g_colorSensorInfo = device.getSensorInfo(openni::SENSOR_COLOR);
	g_irSensorInfo = device.getSensorInfo(openni::SENSOR_IR);

	if (g_depthSensorInfo != NULL)
	{
		nRetVal = g_depthStream.create(device, openni::SENSOR_DEPTH);
		if (nRetVal != openni::STATUS_OK)
		{
			printf("Failed to create depth stream:\n%s\n", openni::OpenNI::getExtendedError());
			return;
		}

		nRetVal = g_depthStream.start();
		if (nRetVal != openni::STATUS_OK)
		{
			printf("Failed to start depth stream:\n%s\n", openni::OpenNI::getExtendedError());
			g_depthStream.destroy();
			return;
		}

		g_bIsDepthOn = true;
	}

	if (g_colorSensorInfo != NULL)
	{
		nRetVal = g_colorStream.create(device, openni::SENSOR_COLOR);
		if (nRetVal != openni::STATUS_OK)
		{
			printf("Failed to create color stream:\n%s\n", openni::OpenNI::getExtendedError());
			return;
		}

		if (defaultRightColor)
		{
			nRetVal = g_colorStream.start();
			if (nRetVal != openni::STATUS_OK)
			{
				printf("Failed to start color stream:\n%s\n", openni::OpenNI::getExtendedError());
				g_colorStream.destroy();
				return;
			}

			g_bIsColorOn = true;
		}
	}

	if (g_irSensorInfo != NULL)
	{
		nRetVal = g_irStream.create(device, openni::SENSOR_IR);
		if (nRetVal != openni::STATUS_OK)
		{
			printf("Failed to create IR stream:\n%s\n", openni::OpenNI::getExtendedError());
			return;
		}

		if (!g_bIsColorOn)
		{
			nRetVal = g_irStream.start();
			if (nRetVal != openni::STATUS_OK)
			{
				printf("Failed to start IR stream:\n%s\n", openni::OpenNI::getExtendedError());
				g_irStream.destroy();
				return;
			}

			g_bIsIROn = true;
		}
	}

	initConstants();

	readFrame();
}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:82,代码来源:Device.cpp

示例15: changeRegistration

void changeRegistration(int value)
{
	openni::ImageRegistrationMode mode = (openni::ImageRegistrationMode)value;
	if (!g_device.isValid() || !g_device.isImageRegistrationModeSupported(mode))
	{
		return;
	}

	g_device.setImageRegistrationMode(mode);
}
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:10,代码来源:Device.cpp


注:本文中的openni::Device类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。