OpenNI2: added parameters to control autoWhiteBalance and autoExposure

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@2056 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-11-20 22:00:47 +00:00
parent 6bf271e04d
commit 3dfbde3b0d
7 changed files with 272 additions and 3 deletions

View File

@@ -196,6 +196,7 @@ class RTABMAP_EXP CameraOpenNI2 :
public:
static bool available();
static bool exposureGainAvailable();
public:
CameraOpenNI2(float imageRate = 0,
@@ -208,6 +209,11 @@ public:
virtual bool init();
bool setAutoWhiteBalance(bool enabled);
bool setAutoExposure(bool enabled);
bool setExposure(int value);
bool setGain(int value);
protected:
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);

View File

@@ -59,6 +59,9 @@ public:
bool isCapturing() const {return this->isRunning();}
void setImageRate(float imageRate);
Camera * camera() {return _camera;} // return null if not set, valid until CameraThread is deleted
CameraRGBD * cameraRGBD() {return _cameraRGBD;} // return null if not set, valid until CameraThread is deleted
private:
virtual void mainLoop();

View File

@@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#ifdef WITH_OPENNI2
#include <OniVersion.h>
#include <OpenNI.h>
#endif
@@ -336,6 +337,15 @@ bool CameraOpenNI2::available()
#endif
}
bool CameraOpenNI2::exposureGainAvailable()
{
#if ONI_VERSION_MAJOR > 2 || (ONI_VERSION_MAJOR==2 && ONI_VERSION_MINOR >= 2)
return true;
#else
return false;
#endif
}
CameraOpenNI2::CameraOpenNI2(float imageRate, const rtabmap::Transform & localTransform, float fx, float fy, float cx, float cy) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy),
#ifdef WITH_OPENNI2
@@ -368,6 +378,66 @@ CameraOpenNI2::~CameraOpenNI2()
#endif
}
bool CameraOpenNI2::setAutoWhiteBalance(bool enabled)
{
#ifdef WITH_OPENNI2
if(_color && _color->getCameraSettings())
{
return _color->getCameraSettings()->setAutoWhiteBalanceEnabled(enabled) == openni::STATUS_OK;
}
#else
UERROR("CameraOpenNI2: RTAB-Map is not built with OpenNI2 support!");
#endif
return false;
}
bool CameraOpenNI2::setAutoExposure(bool enabled)
{
#ifdef WITH_OPENNI2
if(_color && _color->getCameraSettings())
{
return _color->getCameraSettings()->setAutoExposureEnabled(enabled) == openni::STATUS_OK;
}
#else
UERROR("CameraOpenNI2: RTAB-Map is not built with OpenNI2 support!");
#endif
return false;
}
bool CameraOpenNI2::setExposure(int value)
{
#ifdef WITH_OPENNI2
#if ONI_VERSION_MAJOR > 2 || (ONI_VERSION_MAJOR==2 && ONI_VERSION_MINOR >= 2)
if(_color && _color->getCameraSettings())
{
return _color->getCameraSettings()->setExposure(value) == openni::STATUS_OK;
}
#else
UERROR("CameraOpenNI2: OpenNI >= 2.2 required to use this method.");
#endif
#else
UERROR("CameraOpenNI2: RTAB-Map is not built with OpenNI2 support!");
#endif
return false;
}
bool CameraOpenNI2::setGain(int value)
{
#ifdef WITH_OPENNI2
#if ONI_VERSION_MAJOR > 2 || (ONI_VERSION_MAJOR==2 && ONI_VERSION_MINOR >= 2)
if(_color && _color->getCameraSettings())
{
return _color->getCameraSettings()->setGain(value) == openni::STATUS_OK;
}
#else
UERROR("CameraOpenNI2: OpenNI >= 2.2 required to use this method.");
#endif
#else
UERROR("CameraOpenNI2: RTAB-Map is not built with OpenNI2 support!");
#endif
return false;
}
bool CameraOpenNI2::init()
{
#ifdef WITH_OPENNI2
@@ -470,6 +540,16 @@ bool CameraOpenNI2::init()
_depth->getHorizontalFieldOfView(),
_depth->getVerticalFieldOfView());
if(_color->getCameraSettings())
{
UINFO("CameraOpenNI2: AutoWhiteBalanceEnabled = %d", _color->getCameraSettings()->getAutoWhiteBalanceEnabled());
UINFO("CameraOpenNI2: AutoExposureEnabled = %d", _color->getCameraSettings()->getAutoExposureEnabled());
#if ONI_VERSION_MAJOR > 2 || (ONI_VERSION_MAJOR==2 && ONI_VERSION_MINOR >= 2)
UINFO("CameraOpenNI2: Exposure = %d", _color->getCameraSettings()->getExposure());
UINFO("CameraOpenNI2: GAIN = %d", _color->getCameraSettings()->getGain());
#endif
}
bool registered = true;
if(registered)
{