Skip to content

Commit

Permalink
CameraOpenNI2: Added OpenNI2 stamps/Ids option
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Oct 15, 2015
1 parent a8b5311 commit 835155e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
2 changes: 2 additions & 0 deletions corelib/include/rtabmap/core/CameraRGBD.h
Expand Up @@ -160,6 +160,7 @@ class RTABMAP_EXP CameraOpenNI2 :
bool setExposure(int value);
bool setGain(int value);
bool setMirroring(bool enabled);
void setOpenNI2StampsAndIDsUsed(bool used) {_openNI2StampsAndIDsUsed = used;}

protected:
virtual SensorData captureImage();
Expand All @@ -171,6 +172,7 @@ class RTABMAP_EXP CameraOpenNI2 :
float _depthFx;
float _depthFy;
std::string _deviceId;
bool _openNI2StampsAndIDsUsed;
};


Expand Down
12 changes: 10 additions & 2 deletions corelib/src/CameraRGBD.cpp
Expand Up @@ -390,7 +390,8 @@ CameraOpenNI2::CameraOpenNI2(
#endif
_depthFx(0.0f),
_depthFy(0.0f),
_deviceId(deviceId)
_deviceId(deviceId),
_openNI2StampsAndIDsUsed(false)
{
}

Expand Down Expand Up @@ -715,7 +716,14 @@ SensorData CameraOpenNI2::captureImage()
float(rgb.cols/2) - 0.5f, //cx
float(rgb.rows/2) - 0.5f, //cy
this->getLocalTransform());
data = SensorData(rgb, depth, model, this->getNextSeqID(), UTimer::now());
if(_openNI2StampsAndIDsUsed)
{
data = SensorData(rgb, depth, model, depthFrame.getFrameIndex(), double(depthFrame.getTimestamp()) / 1000000.0);
}
else
{
data = SensorData(rgb, depth, model, this->getNextSeqID(), UTimer::now());
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions guilib/src/PreferencesDialog.cpp
Expand Up @@ -377,6 +377,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->openni2_exposure, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
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->comboBox_freenect2Format, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));

connect(_ui->toolButton_cameraRGBDImages_timestamps, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesStamps()));
Expand Down Expand Up @@ -1134,6 +1135,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->openni2_exposure->setValue(0);
_ui->openni2_gain->setValue(100);
_ui->openni2_mirroring->setChecked(false);
_ui->openni2_stampsIdsUsed->setChecked(false);
_ui->comboBox_freenect2Format->setCurrentIndex(0);
_ui->lineEdit_openniOniPath->clear();
_ui->lineEdit_openni2OniPath->clear();
Expand Down Expand Up @@ -1408,6 +1410,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->openni2_exposure->setValue(settings.value("exposure", _ui->openni2_exposure->value()).toInt());
_ui->openni2_gain->setValue(settings.value("gain", _ui->openni2_gain->value()).toInt());
_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());
settings.endGroup(); // Openni2

Expand Down Expand Up @@ -1721,6 +1724,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("exposure", _ui->openni2_exposure->value());
settings.setValue("gain", _ui->openni2_gain->value());
settings.setValue("mirroring", _ui->openni2_mirroring->isChecked());
settings.setValue("stampsIdsUsed", _ui->openni2_stampsIdsUsed->isChecked());
settings.setValue("oniPath", _ui->lineEdit_openni2OniPath->text());
settings.endGroup(); // Openni2

Expand Down Expand Up @@ -3733,6 +3737,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages)
((CameraOpenNI2*)camera)->setAutoWhiteBalance(_ui->openni2_autoWhiteBalance->isChecked());
((CameraOpenNI2*)camera)->setAutoExposure(_ui->openni2_autoExposure->isChecked());
((CameraOpenNI2*)camera)->setMirroring(_ui->openni2_mirroring->isChecked());
((CameraOpenNI2*)camera)->setOpenNI2StampsAndIDsUsed(_ui->openni2_stampsIdsUsed->isChecked());
if(CameraOpenNI2::exposureGainAvailable())
{
((CameraOpenNI2*)camera)->setExposure(_ui->openni2_exposure->value());
Expand Down
34 changes: 27 additions & 7 deletions guilib/src/ui/preferencesDialog.ui
Expand Up @@ -63,7 +63,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-1003</y>
<y>-315</y>
<width>760</width>
<height>1705</height>
</rect>
Expand All @@ -86,7 +86,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>19</number>
<number>3</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29">
Expand Down Expand Up @@ -1769,7 +1769,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item>
<widget class="QStackedWidget" name="stackedWidget_src">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="page_41">
<layout class="QVBoxLayout" name="verticalLayout_64">
Expand Down Expand Up @@ -1874,7 +1874,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item>
<widget class="QStackedWidget" name="stackedWidget_rgbd">
<property name="currentIndex">
<number>6</number>
<number>4</number>
</property>
<widget class="QWidget" name="page_32">
<layout class="QVBoxLayout" name="verticalLayout_63">
Expand Down Expand Up @@ -2009,7 +2009,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<spacer name="verticalSpacer_33">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down Expand Up @@ -2042,7 +2042,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QCheckBox" name="openni2_mirroring">
<property name="text">
<string/>
Expand All @@ -2052,7 +2052,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="label_223">
<property name="text">
<string>Mirroring.</string>
Expand Down Expand Up @@ -2086,6 +2086,26 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_264">
<property name="text">
<string>Use timestamps and frame IDs from OpenNI2.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="openni2_stampsIdsUsed">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 835155e

Please sign in to comment.