Exemple #1
0
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();
}
Exemple #2
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 #3
0
bool record_oni(char *tmpfile, int bufsize, openni::VideoStream &depth, openni::VideoStream &color, Config &conf) {
    openni::Recorder recorder;

    time_t t = time(NULL);
    strftime(tmpfile, bufsize, "rgbd_%Y%m%d_%H-%M-%S_", localtime(&t));
    strncat(tmpfile, getenv("HOSTNAME"), bufsize);
    strncat(tmpfile, ".oni", bufsize);
    printf("Starting ONI Capture.\n");
    depth.start();
    color.start();
    openni::Status rc = recorder.create(tmpfile);
    if(rc != openni::STATUS_OK) {
        printf("Error: Failed to open '%s' for writing!\n%s", tmpfile, openni::OpenNI::getExtendedError());
        return false;
    }

    recorder.attach(color);
    recorder.attach(depth);
    recorder.start();

    struct timespec	start, tp;
    clock_gettime(CLOCK_MONOTONIC, &start);

    long tt;
    do {
        usleep(100);
        clock_gettime(CLOCK_MONOTONIC, &tp);
        tt = (tp.tv_sec-start.tv_sec)*1000+(tp.tv_nsec-start.tv_nsec)/1000000;
    } while(tt < conf.capture_time);


    recorder.stop();
    color.stop();
    depth.stop();
    recorder.destroy();

    printf("Captured ONI to '%s'\n", tmpfile);

    return true;
}
Exemple #4
0
void setDepthVideoMode(int mode)
{
	bool bIsStreamOn = g_bIsDepthOn;
	if (bIsStreamOn)
	{
		g_bIsDepthOn = false;
		g_depthStream.stop();
	}

	g_depthStream.setVideoMode(g_depthSensorInfo->getSupportedVideoModes()[mode]);
	if (bIsStreamOn)
	{
		g_depthStream.start();
		g_bIsDepthOn = true;
	}
}
Exemple #5
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 #6
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;
	}
}
Exemple #7
0
 ~Impl() {
   color_stream.stop();
   color_stream.destroy();
   device.close();
   openni::OpenNI::shutdown();
 }
// Stop recording
void Oni2Grabber::stopAndDestroyStream_(openni::VideoStream &stream) 
{
	stream.stop();
	stream.destroy();
}
bool OpenNI2Driver::stop()
{
    rgbStream.stop() ;
    depthStream.stop() ;
    return true ;
}