diff --git a/corelib/include/rtabmap/core/CameraRGBD.h b/corelib/include/rtabmap/core/CameraRGBD.h
index e3ac14fa..e86b7aa2 100644
--- a/corelib/include/rtabmap/core/CameraRGBD.h
+++ b/corelib/include/rtabmap/core/CameraRGBD.h
@@ -178,6 +178,7 @@ public:
bool setGain(int value);
bool setMirroring(bool enabled);
void setOpenNI2StampsAndIDsUsed(bool used);
+ void setIRDepthShift(int horizontal, int vertical);
protected:
virtual SensorData captureImage(CameraInfo * info = 0);
@@ -193,6 +194,8 @@ private:
std::string _deviceId;
bool _openNI2StampsAndIDsUsed;
StereoCameraModel _stereoModel;
+ int _depthHShift;
+ int _depthVShift;
#endif
};
diff --git a/corelib/src/CameraRGBD.cpp b/corelib/src/CameraRGBD.cpp
index 7cb3c3ff..78b31a15 100644
--- a/corelib/src/CameraRGBD.cpp
+++ b/corelib/src/CameraRGBD.cpp
@@ -396,7 +396,9 @@ CameraOpenNI2::CameraOpenNI2(
_depthFx(0.0f),
_depthFy(0.0f),
_deviceId(deviceId),
- _openNI2StampsAndIDsUsed(false)
+ _openNI2StampsAndIDsUsed(false),
+ _depthHShift(0),
+ _depthVShift(0)
#endif
{
}
@@ -496,6 +498,14 @@ void CameraOpenNI2::setOpenNI2StampsAndIDsUsed(bool used)
#endif
}
+void CameraOpenNI2::setIRDepthShift(int horizontal, int vertical)
+{
+ UASSERT(horizontal >= 0);
+ UASSERT(vertical >= 0);
+ _depthHShift = horizontal;
+ _depthVShift = vertical;
+}
+
bool CameraOpenNI2::init(const std::string & calibrationFolder, const std::string & cameraName)
{
#ifdef RTABMAP_OPENNI2
@@ -848,6 +858,12 @@ SensorData CameraOpenNI2::captureImage(CameraInfo * info)
if(_stereoModel.left().isValidForRectification() && !_stereoModel.stereoTransform().isNull())
{
+ if (_depthHShift > 0 || _depthVShift > 0)
+ {
+ cv::Mat out = cv::Mat::zeros(depth.size(), depth.type());
+ depth(cv::Rect(_depthHShift, _depthVShift, depth.cols - _depthHShift, depth.rows - _depthVShift)).copyTo(out(cv::Rect(0, 0, depth.cols - _depthHShift, depth.rows - _depthVShift)));
+ depth = out;
+ }
depth = _stereoModel.left().rectifyImage(depth, 0);
depth = util2d::registerDepth(depth, _stereoModel.left().K(), rgb.size(), _stereoModel.right().K(), _stereoModel.stereoTransform());
}
diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp
index d421469b..341cf11a 100644
--- a/guilib/src/PreferencesDialog.cpp
+++ b/guilib/src/PreferencesDialog.cpp
@@ -514,6 +514,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->openni2_gain, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->openni2_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->openni2_stampsIdsUsed, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
+ connect(_ui->openni2_hshift, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
+ connect(_ui->openni2_vshift, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->comboBox_freenect2Format, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_freenect2MinDepth, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_freenect2MaxDepth, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
@@ -1511,6 +1513,8 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->openni2_gain->setValue(100);
_ui->openni2_mirroring->setChecked(false);
_ui->openni2_stampsIdsUsed->setChecked(false);
+ _ui->openni2_hshift->setValue(0);
+ _ui->openni2_vshift->setValue(0);
_ui->comboBox_freenect2Format->setCurrentIndex(0);
_ui->doubleSpinBox_freenect2MinDepth->setValue(0.3);
_ui->doubleSpinBox_freenect2MaxDepth->setValue(12.0);
@@ -1881,6 +1885,8 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->openni2_mirroring->setChecked(settings.value("mirroring", _ui->openni2_mirroring->isChecked()).toBool());
_ui->openni2_stampsIdsUsed->setChecked(settings.value("stampsIdsUsed", _ui->openni2_stampsIdsUsed->isChecked()).toBool());
_ui->lineEdit_openni2OniPath->setText(settings.value("oniPath", _ui->lineEdit_openni2OniPath->text()).toString());
+ _ui->openni2_hshift->setValue(settings.value("hshift", _ui->openni2_hshift->value()).toInt());
+ _ui->openni2_vshift->setValue(settings.value("vshift", _ui->openni2_vshift->value()).toInt());
settings.endGroup(); // Openni2
settings.beginGroup("Freenect2");
@@ -2277,6 +2283,8 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("mirroring", _ui->openni2_mirroring->isChecked());
settings.setValue("stampsIdsUsed", _ui->openni2_stampsIdsUsed->isChecked());
settings.setValue("oniPath", _ui->lineEdit_openni2OniPath->text());
+ settings.setValue("hshift", _ui->openni2_hshift->value());
+ settings.setValue("vshift", _ui->openni2_vshift->value());
settings.endGroup(); // Openni2
settings.beginGroup("Freenect2");
@@ -5009,6 +5017,8 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor)
((CameraOpenNI2*)camera)->setExposure(_ui->openni2_exposure->value());
((CameraOpenNI2*)camera)->setGain(_ui->openni2_gain->value());
}
+ ((CameraOpenNI2*)camera)->setIRDepthShift(_ui->openni2_hshift->value(), _ui->openni2_vshift->value());
+ ((CameraOpenNI2*)camera)->setMirroring(_ui->openni2_mirroring->isChecked());
}
}
}
diff --git a/guilib/src/ui/preferencesDialog.ui b/guilib/src/ui/preferencesDialog.ui
index 4240ae7e..b46b0cf3 100644
--- a/guilib/src/ui/preferencesDialog.ui
+++ b/guilib/src/ui/preferencesDialog.ui
@@ -63,7 +63,7 @@
0
- -317
+ -157
677
2682
@@ -72,16 +72,7 @@
0
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -2860,7 +2851,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
-
- 5
+ 4
@@ -2986,6 +2977,23 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
OpenNI 2
+ -
+
+
+ IR-Depth horizontal shift. Only used when custom calibration is done.
+
+
+ true
+
+
+
+ -
+
+
+ 65535
+
+
+
-
@@ -2996,6 +3004,67 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
+ -
+
+
+ 65535
+
+
+
+ -
+
+
+ Use timestamps and frame IDs from OpenNI2.
+
+
+ true
+
+
+
+ -
+
+
+
+
+
+ false
+
+
+
+ -
+
+
+ Path to a *.ONI file.
+
+
+ true
+
+
+
+ -
+
+
+ Gain.
+
+
+ true
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ ...
+
+
+
-
@@ -3006,6 +3075,49 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
+ -
+
+
+ Mirroring.
+
+
+ true
+
+
+
+ -
+
+
+
+
+
+ false
+
+
+
+ -
+
+
+ 1000
+
+
+ 100
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 0
+
+
+
+
-
@@ -3026,13 +3138,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
- -
-
-
- 65535
-
-
-
-
@@ -3043,100 +3148,20 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
- -
-
-
- Qt::Vertical
+
-
+
+
+ IR-Depth vertical shift. Only used when custom calibration is done.
-
-
- 20
- 0
-
+
+ true
-
+
- -
-
+
-
+
- 1000
-
-
- 100
-
-
-
- -
-
-
- Gain.
-
-
- true
-
-
-
- -
-
-
-
-
-
- false
-
-
-
- -
-
-
- Mirroring.
-
-
- true
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- Path to a *.ONI file.
-
-
- true
-
-
-
- -
-
-
- ...
-
-
-
- -
-
-
- Use timestamps and frame IDs from OpenNI2.
-
-
- true
-
-
-
- -
-
-
-
-
-
- false
+ 65535
@@ -4590,16 +4615,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
Directory of images (optional settings)
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -12748,16 +12764,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -12897,16 +12904,7 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -13064,16 +13062,7 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare
0
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -13153,16 +13142,7 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare
0
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -13274,16 +13254,7 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare
0
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-