RealSense: fixed color rectification. Fixed ZR300 odometry frame.

This commit is contained in:
matlabbe
2018-09-26 20:51:12 -04:00
parent 0c2287df77
commit 5e08da51aa
7 changed files with 625 additions and 152 deletions

View File

@@ -630,6 +630,7 @@ void CalibrationDialog::restart()
maxIrs_[1] = 0x7fff;
ui_->pushButton_calibrate->setEnabled(ui_->checkBox_unlock->isChecked());
ui_->checkBox_fisheye->setEnabled(ui_->checkBox_unlock->isChecked());
ui_->pushButton_save->setEnabled(false);
ui_->radioButton_raw->setChecked(true);
ui_->radioButton_rectified->setEnabled(false);
@@ -673,6 +674,7 @@ void CalibrationDialog::restart()
void CalibrationDialog::unlock()
{
ui_->pushButton_calibrate->setEnabled(true);
ui_->checkBox_fisheye->setEnabled(true);
}
void CalibrationDialog::calibrate()
@@ -715,13 +717,26 @@ void CalibrationDialog::calibrate()
if(fishEye)
{
rms = cv::fisheye::calibrate(objectPoints,
imagePoints_[id],
imageSize_[id],
K,
D,
rvecs,
tvecs);
try
{
rms = cv::fisheye::calibrate(objectPoints,
imagePoints_[id],
imageSize_[id],
K,
D,
rvecs,
tvecs,
cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC |
cv::fisheye::CALIB_CHECK_COND |
cv::fisheye::CALIB_FIX_SKEW);
}
catch(const cv::Exception & e)
{
UERROR("Error: %s (try restarting the calibration)", e.what());
QMessageBox::warning(this, tr("Calibration failed!"), tr("Error: %1 (try restarting the calibration)").arg(e.what()));
processingData_ = false;
return;
}
}
else
#endif
@@ -748,7 +763,7 @@ void CalibrationDialog::calibrate()
#if CV_MAJOR_VERSION > 2 or (CV_MAJOR_VERSION == 2 and (CV_MINOR_VERSION >4 or (CV_MINOR_VERSION == 4 and CV_SUBMINOR_VERSION >=10)))
if(fishEye)
{
cv::fisheye::projectPoints( cv::Mat(objectPoints[i]), rvecs[i], tvecs[i], K, D, imagePoints2);
cv::fisheye::projectPoints( cv::Mat(objectPoints[i]), imagePoints2, rvecs[i], tvecs[i], K, D);
}
else
#endif
@@ -1066,8 +1081,7 @@ bool CalibrationDialog::save()
else
{
UASSERT(stereoModel_.left().isValidForRectification() &&
stereoModel_.right().isValidForRectification() &&
(!ui_->label_baseline->isVisible() || stereoModel_.baseline() > 0.0));
stereoModel_.right().isValidForRectification());
QString cameraName = stereoModel_.name().c_str();
QString filePath = QFileDialog::getSaveFileName(this, tr("Export"), savingDirectory_ + "/" + cameraName, "*.yaml");
QString name = QFileInfo(filePath).baseName();

View File

@@ -574,6 +574,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->comboBox_realsensePresetDepth, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkbox_realsenseOdom, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkbox_realsenseDepthScaledToRGBSize, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->comboBox_realsenseRGBSource, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkbox_rs2_emitter, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkbox_rs2_irDepth, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
@@ -1662,6 +1663,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->comboBox_realsensePresetDepth->setCurrentIndex(2);
_ui->checkbox_realsenseOdom->setChecked(false);
_ui->checkbox_realsenseDepthScaledToRGBSize->setChecked(false);
_ui->comboBox_realsenseRGBSource->setCurrentIndex(0);
_ui->checkbox_rs2_emitter->setChecked(true);
_ui->checkbox_rs2_irDepth->setChecked(false);
_ui->lineEdit_openniOniPath->clear();
@@ -2061,6 +2063,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->comboBox_realsensePresetDepth->setCurrentIndex(settings.value("presetDepth", _ui->comboBox_realsensePresetDepth->currentIndex()).toInt());
_ui->checkbox_realsenseOdom->setChecked(settings.value("odom", _ui->checkbox_realsenseOdom->isChecked()).toBool());
_ui->checkbox_realsenseDepthScaledToRGBSize->setChecked(settings.value("depthScaled", _ui->checkbox_realsenseDepthScaledToRGBSize->isChecked()).toBool());
_ui->comboBox_realsenseRGBSource->setCurrentIndex(settings.value("rgbSource", _ui->comboBox_realsenseRGBSource->currentIndex()).toInt());
settings.endGroup(); // RealSense
settings.beginGroup("RealSense2");
@@ -2484,6 +2487,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("presetDepth", _ui->comboBox_realsensePresetDepth->currentIndex());
settings.setValue("odom", _ui->checkbox_realsenseOdom->isChecked());
settings.setValue("depthScaled", _ui->checkbox_realsenseDepthScaledToRGBSize->isChecked());
settings.setValue("rgbSource", _ui->comboBox_realsenseRGBSource->currentIndex());
settings.endGroup(); // RealSense
settings.beginGroup("RealSense2");
@@ -5021,10 +5025,10 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor)
}
else if (driver == kSrcRealSense)
{
if(useRawImages)
if(useRawImages && _ui->comboBox_realsenseRGBSource->currentIndex()!=2)
{
QMessageBox::warning(this, tr("Calibration"),
tr("Using raw images for \"RealSense\" driver is not yet supported. "
tr("Using raw images for \"RealSense\" driver is not yet supported for color and infrared streams. "
"Factory calibration loaded from RealSense is used."), QMessageBox::Ok);
return 0;
}
@@ -5038,6 +5042,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor)
this->getGeneralInputRate(),
this->getSourceLocalTransform());
((CameraRealSense*)camera)->setDepthScaledToRGBSize(_ui->checkbox_realsenseDepthScaledToRGBSize->isChecked());
((CameraRealSense*)camera)->setRGBSource((CameraRealSense::RGBSource)_ui->comboBox_realsenseRGBSource->currentIndex());
}
}
else if (driver == kSrcRealSense2)
@@ -5824,7 +5829,7 @@ void PreferencesDialog::calibrate()
}
bool freenect2 = driver == kSrcFreenect2;
_calibrationDialog->setStereoMode(this->getSourceType() != kSrcRGB, freenect2?"rgb":"left", freenect2?"depth":"right"); // RGB+Depth or left+right
_calibrationDialog->setStereoMode(this->getSourceType() != kSrcRGB && driver != kSrcRealSense, freenect2?"rgb":"left", freenect2?"depth":"right"); // RGB+Depth or left+right
_calibrationDialog->setSwitchedImages(freenect2);
_calibrationDialog->setSavingDirectory(this->getCameraInfoDir());
_calibrationDialog->registerToEventsManager();

View File

@@ -94,8 +94,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>678</width>
<y>-287</y>
<width>681</width>
<height>2943</height>
</rect>
</property>
@@ -117,7 +117,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>7</number>
<number>5</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -3600,7 +3600,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<string>RealSense</string>
</property>
<layout class="QGridLayout" name="gridLayout_73" columnstretch="0,1">
<item row="4" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer_51">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -3706,6 +3706,16 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkbox_realsenseDepthScaledToRGBSize">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_realsenseOdom_2">
<property name="text">
@@ -3719,13 +3729,38 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkbox_realsenseDepthScaledToRGBSize">
<property name="text">
<string/>
<item row="4" column="0">
<widget class="QComboBox" name="comboBox_realsenseRGBSource">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<property name="checked">
<bool>false</bool>
<item>
<property name="text">
<string>Color</string>
</property>
</item>
<item>
<property name="text">
<string>Infrared</string>
</property>
</item>
<item>
<property name="text">
<string>Fisheye</string>
</property>
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_realsenseOdom_3">
<property name="text">
<string>RGB camera source. For fisheye has depth available only if it is calibrated.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>