Example #1
0
void toggleImageAutoWhiteBalance(int)
{
    if (g_colorStream.getCameraSettings() == NULL)
    {
        displayError("Color stream doesn't support camera settings");
        return;
    }
    g_colorStream.getCameraSettings()->setAutoWhiteBalanceEnabled(!g_colorStream.getCameraSettings()->getAutoWhiteBalanceEnabled());
    displayMessage("Auto White balance: %s", g_colorStream.getCameraSettings()->getAutoWhiteBalanceEnabled() ? "ON" : "OFF");
}
Example #2
0
void toggleCMOSAutoLoops(int )
{
	if (g_colorStream.getCameraSettings() == NULL)
	{
		displayMessage("Color stream doesn't support camera settings");
		return;
	}
	toggleImageAutoExposure(0);
	toggleImageAutoWhiteBalance(0);

	displayMessage ("CMOS Auto Loops: %s", g_colorStream.getCameraSettings()->getAutoExposureEnabled()?"On":"Off");	
}
Example #3
0
void changeImageGain(int delta)
{
    if (g_colorStream.getCameraSettings() == NULL)
    {
        displayError("Color stream doesn't support camera settings");
        return;
    }
    int gain = g_colorStream.getCameraSettings()->getGain();
    openni::Status rc = g_colorStream.getCameraSettings()->setGain(gain + delta);
    if (rc != openni::STATUS_OK)
    {
        displayMessage("Can't change gain");
        return;
    }
    displayMessage("Changed gain to: %d", g_colorStream.getCameraSettings()->getGain());
}
Example #4
0
void changeImageExposure(int delta)
{
    if (g_colorStream.getCameraSettings() == NULL)
    {
        displayError("Color stream doesn't support camera settings");
        return;
    }
    int exposure = g_colorStream.getCameraSettings()->getExposure();
    openni::Status rc = g_colorStream.getCameraSettings()->setExposure(exposure + delta);
    if (rc != openni::STATUS_OK)
    {
        displayMessage("Can't change exposure");
        return;
    }
    displayMessage("Changed exposure to: %d", g_colorStream.getCameraSettings()->getExposure());
}
Example #5
0
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
        {
            kinect::VideoMode mode = g_colorStream.getVideoMode();
            if(((int)camera->FPS())==60)
                mode.setFps(60);
            else
                mode.setFps(30);
            mode.setFps(30); ///< @todo check!!!
            mode.setResolution(camera->width(), camera->height());
            rc = g_colorStream.setVideoMode(mode);
            if (rc != kinect::STATUS_OK)
                std::cerr << "error setting video mode (color)" << std::endl;
        }
    }


#ifdef THIS_CAUSES_INIT_STALLS
    /// Enable depth/color frame synchronization
    rc = device.setDepthColorSyncEnabled(true);
    if (rc != kinect::STATUS_OK)
    {
        qDebug()<<"Could not synchronise device";
        // VGA Kinect always seems to shut down here
        kinect::OpenNI::shutdown();
        exit(0);
    }
#endif

    /// Camera settings
    kinect::CameraSettings* settings = g_colorStream.getCameraSettings();
    settings->setAutoExposureEnabled(true);
    settings->setAutoWhiteBalanceEnabled(true);

    /// Fetch the camera intrinsics
#if 0
        float w = g_depthStream.getVideoMode().getResolutionX();protected:
Example #6
0
void toggleImageAutoWhiteBalance(int)
{
	g_colorStream.getCameraSettings()->setAutoWhiteBalanceEnabled(!g_colorStream.getCameraSettings()->getAutoWhiteBalanceEnabled());
}
Example #7
0
void toggleImageAutoExposure(int)
{
	g_colorStream.getCameraSettings()->setAutoExposureEnabled(!g_colorStream.getCameraSettings()->getAutoExposureEnabled());
}
Example #8
0
				void enableAutoExposure() {m_stream.getCameraSettings()->setAutoExposureEnabled(true); }
Example #9
0
				void disableAutoExposure() {m_stream.getCameraSettings()->setAutoExposureEnabled(false); }