Exemple #1
0
void toggleStreamState(openni::VideoStream& stream, openni::VideoFrameRef& frame, bool& isOn, openni::SensorType type, const char* name)
{
    openni::Status nRetVal = openni::STATUS_OK;

    if (!stream.isValid())
    {
        nRetVal = stream.create(g_device, type);
        if (nRetVal != openni::STATUS_OK)
        {
            displayError("Failed to create %s stream:\n%s", name, openni::OpenNI::getExtendedError());
            return;
        }
    }

    if (isOn)
    {
        stream.stop();
        frame.release();
    }
    else
    {
        nRetVal = stream.start();
        if (nRetVal != openni::STATUS_OK)
        {
            displayError("Failed to start %s stream:\n%s", name, openni::OpenNI::getExtendedError());
            return;
        }
    }

    isOn = !isOn;
}
Exemple #2
0
void setIRVideoMode(int mode)
{
	bool bIsStreamOn = g_bIsIROn;
	if (bIsStreamOn)
	{
		g_bIsIROn = false;
		g_irStream.stop();
	}

	g_irFrame.release();
	g_irStream.setVideoMode(g_irSensorInfo->getSupportedVideoModes()[mode]);
	if (bIsStreamOn)
	{
		g_irStream.start();
		g_bIsIROn = true;
	}
}
Exemple #3
0
void toggleIRState(int )
{
	if (g_irStream.isValid()) 
	{
		if(g_bIsIROn)
		{
			g_irStream.stop();
			g_irFrame.release();
		}
		else
		{
			openni::Status nRetVal = g_irStream.start();
			if (nRetVal != openni::STATUS_OK)
			{
				displayError("Failed to start IR stream:\n%s", openni::OpenNI::getExtendedError());
				return;
			}
		}

		g_bIsIROn = !g_bIsIROn;
	}
}