Added more Freenect2 options

This commit is contained in:
matlabbe
2015-11-04 18:31:52 -05:00
parent 2ee9183c17
commit 58190d5422
5 changed files with 322 additions and 66 deletions

View File

@@ -219,8 +219,9 @@ public:
enum Type{ enum Type{
kTypeColor2DepthSD, kTypeColor2DepthSD,
kTypeDepth2ColorHD,
kTypeDepth2ColorSD, kTypeDepth2ColorSD,
kTypeDepth2ColorHD,
kTypeDepth2ColorHD2,
kTypeIRDepth, kTypeIRDepth,
kTypeColorIR kTypeColorIR
}; };
@@ -230,7 +231,12 @@ public:
CameraFreenect2(int deviceId= 0, CameraFreenect2(int deviceId= 0,
Type type = kTypeColor2DepthSD, Type type = kTypeColor2DepthSD,
float imageRate=0.0f, float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity()); const Transform & localTransform = Transform::getIdentity(),
float minDepth = 0.3f,
float maxDepth = 12.0f,
bool bilateralFiltering = true,
bool edgeAwareFiltering = true,
bool noiseFiltering = true);
virtual ~CameraFreenect2(); virtual ~CameraFreenect2();
virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = ""); virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
@@ -249,8 +255,11 @@ private:
libfreenect2::PacketPipeline * pipeline_; libfreenect2::PacketPipeline * pipeline_;
libfreenect2::SyncMultiFrameListener * listener_; libfreenect2::SyncMultiFrameListener * listener_;
libfreenect2::Registration * reg_; libfreenect2::Registration * reg_;
double minKinect2Depth_; float minKinect2Depth_;
double maxKinect2Depth_; float maxKinect2Depth_;
bool bilateralFiltering_;
bool edgeAwareFiltering_;
bool noiseFiltering_;
}; };

View File

@@ -1082,7 +1082,16 @@ bool CameraFreenect2::available()
#endif #endif
} }
CameraFreenect2::CameraFreenect2(int deviceId, Type type, float imageRate, const Transform & localTransform) : CameraFreenect2::CameraFreenect2(
int deviceId,
Type type,
float imageRate,
const Transform & localTransform,
float minDepth,
float maxDepth,
bool bilateralFiltering,
bool edgeAwareFiltering,
bool noiseFiltering) :
Camera(imageRate, localTransform), Camera(imageRate, localTransform),
deviceId_(deviceId), deviceId_(deviceId),
type_(type), type_(type),
@@ -1091,10 +1100,14 @@ CameraFreenect2::CameraFreenect2(int deviceId, Type type, float imageRate, const
pipeline_(0), pipeline_(0),
listener_(0), listener_(0),
reg_(0), reg_(0),
minKinect2Depth_(0.1), minKinect2Depth_(minDepth),
maxKinect2Depth_(12.0) maxKinect2Depth_(maxDepth),
bilateralFiltering_(bilateralFiltering),
edgeAwareFiltering_(edgeAwareFiltering),
noiseFiltering_(noiseFiltering)
{ {
#ifdef WITH_FREENECT2 #ifdef WITH_FREENECT2
UASSERT(minKinect2Depth_ < maxKinect2Depth_ && minKinect2Depth_>0 && maxKinect2Depth_>0 && maxKinect2Depth_<=65.535f);
freenect2_ = new libfreenect2::Freenect2(); freenect2_ = new libfreenect2::Freenect2();
switch(type_) switch(type_)
{ {
@@ -1127,8 +1140,8 @@ CameraFreenect2::CameraFreenect2(int deviceId, Type type, float imageRate, const
//EnableBilateralFilter(true), //EnableBilateralFilter(true),
//EnableEdgeAwareFilter(true) //EnableEdgeAwareFilter(true)
libfreenect2::DepthPacketProcessor::Config config; libfreenect2::DepthPacketProcessor::Config config;
config.EnableBilateralFilter = true; config.EnableBilateralFilter = bilateralFiltering_;
config.EnableEdgeAwareFilter = true; config.EnableEdgeAwareFilter = edgeAwareFiltering_;
config.MinDepth = minKinect2Depth_; config.MinDepth = minKinect2Depth_;
config.MaxDepth = maxKinect2Depth_; config.MaxDepth = maxKinect2Depth_;
pipeline_->getDepthPacketProcessor()->setConfiguration(config); pipeline_->getDepthPacketProcessor()->setConfiguration(config);
@@ -1225,7 +1238,8 @@ bool CameraFreenect2::init(const std::string & calibrationFolder, const std::str
{ {
if(type_==kTypeColor2DepthSD) if(type_==kTypeColor2DepthSD)
{ {
UWARN("Freenect2: When using custom calibration file, type kTypeColor2DepthSD is not supported. kTypeDepth2ColorSD is used instead..."); UWARN("Freenect2: When using custom calibration file, type "
"kTypeColor2DepthSD is not supported. kTypeDepth2ColorSD is used instead...");
type_ = kTypeDepth2ColorSD; type_ = kTypeDepth2ColorSD;
} }
@@ -1324,8 +1338,9 @@ SensorData CameraFreenect2::captureImage()
depthFrame = uValue(frames, libfreenect2::Frame::Depth, (libfreenect2::Frame*)0); depthFrame = uValue(frames, libfreenect2::Frame::Depth, (libfreenect2::Frame*)0);
break; break;
case kTypeColor2DepthSD: case kTypeColor2DepthSD:
case kTypeDepth2ColorHD:
case kTypeDepth2ColorSD: case kTypeDepth2ColorSD:
case kTypeDepth2ColorHD:
case kTypeDepth2ColorHD2:
default: default:
rgbFrame = uValue(frames, libfreenect2::Frame::Color, (libfreenect2::Frame*)0); rgbFrame = uValue(frames, libfreenect2::Frame::Color, (libfreenect2::Frame*)0);
depthFrame = uValue(frames, libfreenect2::Frame::Depth, (libfreenect2::Frame*)0); depthFrame = uValue(frames, libfreenect2::Frame::Depth, (libfreenect2::Frame*)0);
@@ -1440,20 +1455,66 @@ SensorData CameraFreenect2::captureImage()
{ {
//registration of the depth //registration of the depth
UASSERT(reg_!=0); UASSERT(reg_!=0);
if(type_ != kTypeDepth2ColorSD) float maxDepth = maxKinect2Depth_*1000.0f;
float minDepth = minKinect2Depth_*1000.0f;
if(type_ == kTypeColor2DepthSD || type_ == kTypeDepth2ColorHD)
{ {
cv::Mat rgbMatBGRA; cv::Mat rgbMatBGRA;
libfreenect2::Frame depthUndistorted(512, 424, 4); libfreenect2::Frame depthUndistorted(512, 424, 4);
libfreenect2::Frame rgbRegistered(512, 424, 4); libfreenect2::Frame rgbRegistered(512, 424, 4);
// do it before registration
if(noiseFiltering_)
{
cv::Mat depthMat = cv::Mat((int)depthFrame->height, (int)depthFrame->width, CV_32FC1, depthFrame->data);
for(int dx=0; dx<depthMat.cols; ++dx)
{
bool onEdgeX = dx==depthMat.cols-1;
for(int dy=0; dy<depthMat.rows; ++dy)
{
bool onEdge = onEdgeX || dy==depthMat.rows-1;
float z = 0.0f;
float & dz = depthMat.at<float>(dy,dx);
if(dz>=minDepth && dz <= maxDepth)
{
z = dz;
if(noiseFiltering_ && !onEdge)
{
z=0;
const float & dz1 = depthMat.at<float>(dy,dx+1);
const float & dz2 = depthMat.at<float>(dy+1,dx);
const float & dz3 = depthMat.at<float>(dy+1,dx+1);
if( dz1>=minDepth && dz1 <= maxDepth &&
dz2>=minDepth && dz2 <= maxDepth &&
dz3>=minDepth && dz3 <= maxDepth)
{
float avg = (dz + dz1 + dz2 + dz3) / 4.0f;
float thres = 0.01f*avg;
if( fabs(dz-avg) < thres &&
fabs(dz1-avg) < thres &&
fabs(dz2-avg) < thres &&
fabs(dz3-avg) < thres)
{
z = dz;
}
}
}
}
dz = z;
}
}
}
libfreenect2::Frame bidDepth(1920, 1082, 4); // HD libfreenect2::Frame bidDepth(1920, 1082, 4); // HD
reg_->apply(rgbFrame, depthFrame, &depthUndistorted, &rgbRegistered, true, &bidDepth); reg_->apply(rgbFrame, depthFrame, &depthUndistorted, &rgbRegistered, true, &bidDepth);
cv::Mat depthMat;
if(type_ == kTypeColor2DepthSD) if(type_ == kTypeColor2DepthSD)
{ {
rgbMatBGRA = cv::Mat((int)rgbRegistered.height, (int)rgbRegistered.width, CV_8UC4, rgbRegistered.data); rgbMatBGRA = cv::Mat((int)rgbRegistered.height, (int)rgbRegistered.width, CV_8UC4, rgbRegistered.data);
cv::Mat((int)depthUndistorted.height, (int)depthUndistorted.width, CV_32FC1, depthUndistorted.data).convertTo(depth, CV_16U, 1); depthMat = cv::Mat((int)depthUndistorted.height, (int)depthUndistorted.width, CV_32FC1, depthUndistorted.data);
//use IR params //use IR params
libfreenect2::Freenect2Device::IrCameraParams params = dev_->getIrCameraParams(); libfreenect2::Freenect2Device::IrCameraParams params = dev_->getIrCameraParams();
@@ -1465,21 +1526,9 @@ SensorData CameraFreenect2::captureImage()
else else
{ {
rgbMatBGRA = cv::Mat((int)rgbFrame->height, (int)rgbFrame->width, CV_8UC4, rgbFrame->data); rgbMatBGRA = cv::Mat((int)rgbFrame->height, (int)rgbFrame->width, CV_8UC4, rgbFrame->data);
cv::Mat((int)bidDepth.height, (int)bidDepth.width, CV_32FC1, bidDepth.data).convertTo(depth, CV_16U, 1); depthMat = cv::Mat((int)bidDepth.height, (int)bidDepth.width, CV_32FC1, bidDepth.data);
depth = depth(cv::Range(1, 1081), cv::Range::all()); depthMat = depthMat(cv::Range(1, 1081), cv::Range::all());
unsigned short maxDepth = (unsigned short)(maxKinect2Depth_*1000.0);
if(maxDepth < 65535)
{
int size = 1920*1080;
for(int i=0; i<size;++i)
{
if(((unsigned short *)depth.data)[i] > maxDepth)
{
((unsigned short *)depth.data)[i] = 0;
}
}
}
//use color params //use color params
libfreenect2::Freenect2Device::ColorCameraParams params = dev_->getColorCameraParams(); libfreenect2::Freenect2Device::ColorCameraParams params = dev_->getColorCameraParams();
fx = params.fx; fx = params.fx;
@@ -1487,14 +1536,30 @@ SensorData CameraFreenect2::captureImage()
cx = params.cx; cx = params.cx;
cy = params.cy; cy = params.cy;
} }
//filter max depth and flip
depth = cv::Mat(depthMat.size(), CV_16UC1);
for(int dx=0; dx<depthMat.cols; ++dx)
{
for(int dy=0; dy<depthMat.rows; ++dy)
{
unsigned short z = 0;
const float & dz = depthMat.at<float>(dy,dx);
if(dz>=minDepth && dz <= maxDepth)
{
z = (unsigned short)dz;
}
depth.at<unsigned short>(dy,(depthMat.cols-1)-dx) = z; //flip
}
}
// rtabmap uses 3 channels RGB // rtabmap uses 3 channels RGB
cv::cvtColor(rgbMatBGRA, rgb, CV_BGRA2BGR); cv::cvtColor(rgbMatBGRA, rgb, CV_BGRA2BGR);
cv::flip(rgb, rgb, 1); cv::flip(rgb, rgb, 1);
cv::flip(depth, depth, 1);
} }
else //register depth to color else //register depth to color (OLD WAY)
{ {
UASSERT(type_ == kTypeDepth2ColorSD || type_ == kTypeDepth2ColorHD); UASSERT(type_ == kTypeDepth2ColorSD || type_ == kTypeDepth2ColorHD2);
cv::Mat rgbMatBGRA = cv::Mat((int)rgbFrame->height, (int)rgbFrame->width, CV_8UC4, rgbFrame->data); cv::Mat rgbMatBGRA = cv::Mat((int)rgbFrame->height, (int)rgbFrame->width, CV_8UC4, rgbFrame->data);
if(type_ == kTypeDepth2ColorSD) if(type_ == kTypeDepth2ColorSD)
{ {
@@ -1513,17 +1578,31 @@ SensorData CameraFreenect2::captureImage()
for(int dy=0; dy<depthFrameMat.rows-1; ++dy) for(int dy=0; dy<depthFrameMat.rows-1; ++dy)
{ {
float dz = depthFrameMat.at<float>(dy,dx); float dz = depthFrameMat.at<float>(dy,dx);
float dz1 = depthFrameMat.at<float>(dy,dx+1); if(dz>=minDepth && dz<=maxDepth)
float dz2 = depthFrameMat.at<float>(dy+1,dx);
float dz3 = depthFrameMat.at<float>(dy+1,dx+1);
if(dz && dz1 && dz2 && dz3)
{ {
float avg = (dz + dz1 + dz2 + dz3) / 4; bool goodDepth = true;
float thres = 0.01 * avg; if(noiseFiltering_)
if( fabs(dz - avg) < thres && {
fabs(dz1 - avg) < thres && goodDepth = false;
fabs(dz2 - avg) < thres && float dz1 = depthFrameMat.at<float>(dy,dx+1);
fabs(dz3 - avg) < thres) float dz2 = depthFrameMat.at<float>(dy+1,dx);
float dz3 = depthFrameMat.at<float>(dy+1,dx+1);
if(dz1>=minDepth && dz1 <= maxDepth &&
dz2>=minDepth && dz2 <= maxDepth &&
dz3>=minDepth && dz3 <= maxDepth)
{
float avg = (dz + dz1 + dz2 + dz3) / 4.0f;
float thres = 0.01 * avg;
if( fabs(dz-avg) < thres &&
fabs(dz1-avg) < thres &&
fabs(dz2-avg) < thres &&
fabs(dz3-avg) < thres)
{
goodDepth = true;
}
}
}
if(goodDepth)
{ {
float cx=-1,cy=-1; float cx=-1,cy=-1;
reg_->apply(dx, dy, dz, cx, cy); reg_->apply(dx, dy, dz, cx, cy);
@@ -1546,8 +1625,8 @@ SensorData CameraFreenect2::captureImage()
} }
} }
} }
util2d::fillRegisteredDepthHoles(depth, true, true, type_==kTypeDepth2ColorHD); util2d::fillRegisteredDepthHoles(depth, true, true, type_==kTypeDepth2ColorHD2);
util2d::fillRegisteredDepthHoles(depth, type_==kTypeDepth2ColorSD, type_==kTypeDepth2ColorHD);//second pass util2d::fillRegisteredDepthHoles(depth, type_==kTypeDepth2ColorSD, type_==kTypeDepth2ColorHD2);//second pass
cv::flip(depth, depth, 1); cv::flip(depth, depth, 1);
libfreenect2::Freenect2Device::ColorCameraParams params = dev_->getColorCameraParams(); libfreenect2::Freenect2Device::ColorCameraParams params = dev_->getColorCameraParams();
fx = params.fx*(type_==kTypeDepth2ColorSD?0.5:1.0f); fx = params.fx*(type_==kTypeDepth2ColorSD?0.5:1.0f);

View File

@@ -434,22 +434,33 @@ SensorData::SensorData(
void SensorData::setUserDataRaw(const cv::Mat & userDataRaw) void SensorData::setUserDataRaw(const cv::Mat & userDataRaw)
{ {
if(!_userDataRaw.empty()) if(!userDataRaw.empty() && (!_userDataCompressed.empty() || !_userDataRaw.empty()))
{ {
UWARN("Writing new user data over existing user data. This may result in data loss."); UWARN("Cannot write new user data (%d bytes) over existing user "
"data (%d bytes, %d compressed). Set user data of %d to null "
"before setting a new one.",
int(userDataRaw.total()*userDataRaw.elemSize()),
int(_userDataRaw.total()*_userDataRaw.elemSize()),
_userDataCompressed.cols,
this->id());
return;
} }
_userDataRaw = userDataRaw; _userDataRaw = userDataRaw;
_userDataCompressed = cv::Mat();
} }
void SensorData::setUserData(const cv::Mat & userData) void SensorData::setUserData(const cv::Mat & userData)
{ {
if(!userData.empty() && (!_userDataCompressed.empty() || !_userDataRaw.empty())) if(!userData.empty() && (!_userDataCompressed.empty() || !_userDataRaw.empty()))
{ {
UWARN("Writing new user data (%d bytes) over existing user " UWARN("Cannot write new user data (%d bytes) over existing user "
"data (%d bytes, %d compressed). This may result in data loss.", "data (%d bytes, %d compressed). Set user data of %d to null "
"before setting a new one.",
int(userData.total()*userData.elemSize()), int(userData.total()*userData.elemSize()),
int(_userDataRaw.total()*_userDataRaw.elemSize()), int(_userDataRaw.total()*_userDataRaw.elemSize()),
_userDataCompressed.cols); _userDataCompressed.cols,
this->id());
return;
} }
_userDataRaw = cv::Mat(); _userDataRaw = cv::Mat();
_userDataCompressed = cv::Mat(); _userDataCompressed = cv::Mat();

View File

@@ -379,6 +379,11 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->openni2_mirroring, SIGNAL(stateChanged(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_stampsIdsUsed, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->comboBox_freenect2Format, SIGNAL(currentIndexChanged(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()));
connect(_ui->checkBox_freenect2BilateralFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkBox_freenect2EdgeAwareFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkBox_freenect2NoiseFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->toolButton_cameraRGBDImages_timestamps, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesStamps())); connect(_ui->toolButton_cameraRGBDImages_timestamps, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesStamps()));
connect(_ui->lineEdit_cameraRGBDImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_cameraRGBDImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
@@ -1095,8 +1100,8 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->checkBox_rgbVideo_rectify->setChecked(false); _ui->checkBox_rgbVideo_rectify->setChecked(false);
_ui->source_checkBox_ignoreOdometry->setChecked(false); _ui->source_checkBox_ignoreOdometry->setChecked(false);
_ui->source_checkBox_ignoreGoalDelay->setChecked(false); _ui->source_checkBox_ignoreGoalDelay->setChecked(true);
_ui->source_checkBox_ignoreGoals->setChecked(false); _ui->source_checkBox_ignoreGoals->setChecked(true);
_ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_spinBox_databaseStartPos->setValue(0);
_ui->source_checkBox_useDbStamps->setChecked(true); _ui->source_checkBox_useDbStamps->setChecked(true);
@@ -1138,6 +1143,11 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->openni2_mirroring->setChecked(false); _ui->openni2_mirroring->setChecked(false);
_ui->openni2_stampsIdsUsed->setChecked(false); _ui->openni2_stampsIdsUsed->setChecked(false);
_ui->comboBox_freenect2Format->setCurrentIndex(0); _ui->comboBox_freenect2Format->setCurrentIndex(0);
_ui->doubleSpinBox_freenect2MinDepth->setValue(0.3);
_ui->doubleSpinBox_freenect2MaxDepth->setValue(12.0);
_ui->checkBox_freenect2BilateralFiltering->setChecked(true);
_ui->checkBox_freenect2EdgeAwareFiltering->setChecked(true);
_ui->checkBox_freenect2NoiseFiltering->setChecked(true);
_ui->lineEdit_openniOniPath->clear(); _ui->lineEdit_openniOniPath->clear();
_ui->lineEdit_openni2OniPath->clear(); _ui->lineEdit_openni2OniPath->clear();
_ui->lineEdit_cameraRGBDImages_path_rgb->setText(""); _ui->lineEdit_cameraRGBDImages_path_rgb->setText("");
@@ -1417,6 +1427,11 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
settings.beginGroup("Freenect2"); settings.beginGroup("Freenect2");
_ui->comboBox_freenect2Format->setCurrentIndex(settings.value("format", _ui->comboBox_freenect2Format->currentIndex()).toInt()); _ui->comboBox_freenect2Format->setCurrentIndex(settings.value("format", _ui->comboBox_freenect2Format->currentIndex()).toInt());
_ui->doubleSpinBox_freenect2MinDepth->setValue(settings.value("minDepth", _ui->doubleSpinBox_freenect2MinDepth->value()).toDouble());
_ui->doubleSpinBox_freenect2MaxDepth->setValue(settings.value("maxDepth", _ui->doubleSpinBox_freenect2MaxDepth->value()).toDouble());
_ui->checkBox_freenect2BilateralFiltering->setChecked(settings.value("bilateralFiltering", _ui->checkBox_freenect2BilateralFiltering->isChecked()).toBool());
_ui->checkBox_freenect2EdgeAwareFiltering->setChecked(settings.value("edgeAwareFiltering", _ui->checkBox_freenect2EdgeAwareFiltering->isChecked()).toBool());
_ui->checkBox_freenect2NoiseFiltering->setChecked(settings.value("noiseFiltering", _ui->checkBox_freenect2NoiseFiltering->isChecked()).toBool());
settings.endGroup(); // Freenect2 settings.endGroup(); // Freenect2
settings.beginGroup("RGBDImages"); settings.beginGroup("RGBDImages");
@@ -1730,7 +1745,12 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.endGroup(); // Openni2 settings.endGroup(); // Openni2
settings.beginGroup("Freenect2"); settings.beginGroup("Freenect2");
settings.setValue("format", _ui->comboBox_freenect2Format->currentIndex()); settings.setValue("format", _ui->comboBox_freenect2Format->currentIndex());
settings.setValue("minDepth", _ui->doubleSpinBox_freenect2MinDepth->value());
settings.setValue("maxDepth", _ui->doubleSpinBox_freenect2MaxDepth->value());
settings.setValue("bilateralFiltering", _ui->checkBox_freenect2BilateralFiltering->isChecked());
settings.setValue("edgeAwareFiltering", _ui->checkBox_freenect2EdgeAwareFiltering->isChecked());
settings.setValue("noiseFiltering", _ui->checkBox_freenect2NoiseFiltering->isChecked());
settings.endGroup(); // Freenect2 settings.endGroup(); // Freenect2
settings.beginGroup("RGBDImages"); settings.beginGroup("RGBDImages");
@@ -1952,8 +1972,7 @@ bool PreferencesDialog::validateForm()
_ui->odom_bin_nn->setCurrentIndex(VWDictionary::kNNBruteForce); _ui->odom_bin_nn->setCurrentIndex(VWDictionary::kNNBruteForce);
} }
if(_ui->groupBox_odometry1->isEnabled() && if(_ui->loopClosure_bowVarianceFromInliersCount->isChecked() != _ui->odom_varianceFromInliersCount->isChecked())
_ui->loopClosure_bowVarianceFromInliersCount->isChecked() != _ui->odom_varianceFromInliersCount->isChecked())
{ {
QMessageBox::warning(this, tr("Parameter warning"), QMessageBox::warning(this, tr("Parameter warning"),
tr("Odometry %1 variance from inliers count but Loop Closure constraint %2. " tr("Odometry %1 variance from inliers count but Loop Closure constraint %2. "
@@ -1963,6 +1982,16 @@ bool PreferencesDialog::validateForm()
_ui->loopClosure_bowVarianceFromInliersCount->setChecked(_ui->odom_varianceFromInliersCount->isChecked()); _ui->loopClosure_bowVarianceFromInliersCount->setChecked(_ui->odom_varianceFromInliersCount->isChecked());
} }
if(_ui->doubleSpinBox_freenect2MinDepth->value() >= _ui->doubleSpinBox_freenect2MaxDepth->value())
{
QMessageBox::warning(this, tr("Parameter warning"),
tr("Freenect2 minimum depth (%1 m) should be lower than maximum depth (%2 m). Setting maximum depth to %3 m.")
.arg(_ui->doubleSpinBox_freenect2MinDepth->value())
.arg(_ui->doubleSpinBox_freenect2MaxDepth->value())
.arg(_ui->doubleSpinBox_freenect2MaxDepth->value()+1));
_ui->doubleSpinBox_freenect2MaxDepth->setValue(_ui->doubleSpinBox_freenect2MaxDepth->value()+1);
}
return true; return true;
} }
@@ -3628,7 +3657,12 @@ Camera * PreferencesDialog::createCamera(bool useRawImages)
this->getSourceDevice().isEmpty()?0:atoi(this->getSourceDevice().toStdString().c_str()), this->getSourceDevice().isEmpty()?0:atoi(this->getSourceDevice().toStdString().c_str()),
useRawImages?CameraFreenect2::kTypeColorIR:(CameraFreenect2::Type)_ui->comboBox_freenect2Format->currentIndex(), useRawImages?CameraFreenect2::kTypeColorIR:(CameraFreenect2::Type)_ui->comboBox_freenect2Format->currentIndex(),
this->getGeneralInputRate(), this->getGeneralInputRate(),
this->getSourceLocalTransform()); this->getSourceLocalTransform(),
_ui->doubleSpinBox_freenect2MinDepth->value(),
_ui->doubleSpinBox_freenect2MaxDepth->value(),
_ui->checkBox_freenect2BilateralFiltering->isChecked(),
_ui->checkBox_freenect2EdgeAwareFiltering->isChecked(),
_ui->checkBox_freenect2NoiseFiltering->isChecked());
} }
else if(driver == kSrcRGBDImages) else if(driver == kSrcRGBDImages)
{ {

View File

@@ -2138,6 +2138,19 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<spacer name="verticalSpacer_32">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QComboBox" name="comboBox_freenect2Format"> <widget class="QComboBox" name="comboBox_freenect2Format">
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
@@ -2148,6 +2161,11 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<string>Registered Color to Depth SD</string> <string>Registered Color to Depth SD</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Registered Depth to Color SD (old way)</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Registered Depth to Color HD</string> <string>Registered Depth to Color HD</string>
@@ -2155,7 +2173,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Registered Depth to Color SD</string> <string>Registered Depth to Color HD (old way)</string>
</property> </property>
</item> </item>
<item> <item>
@@ -2165,18 +2183,123 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QLabel" name="label_268">
<property name="text">
<string>Depth bilateral filtering.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_266">
<property name="text">
<string>Min depth.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_269">
<property name="text">
<string>Depth edge aware filtering.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_freenect2MaxDepth">
<property name="maximum">
<double>65.000000000000000</double>
</property>
<property name="value">
<double>12.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_freenect2BilateralFiltering">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_freenect2EdgeAwareFiltering">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_267">
<property name="text">
<string>Max depth.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<spacer name="verticalSpacer_32"> <widget class="QDoubleSpinBox" name="doubleSpinBox_freenect2MinDepth">
<property name="orientation"> <property name="maximum">
<enum>Qt::Vertical</enum> <double>64.000000000000000</double>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="singleStep">
<size> <double>0.100000000000000</double>
<width>20</width>
<height>0</height>
</size>
</property> </property>
</spacer> <property name="value">
<double>0.300000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_freenect2NoiseFiltering">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_270">
<property name="text">
<string>Depth noise filtering.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>