mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-10 21:40:19 +08:00
Added Source/Mirroring parameter for convenience
This commit is contained in:
@@ -56,10 +56,12 @@ public:
|
||||
//getters
|
||||
void getImageSize(unsigned int & width, unsigned int & height);
|
||||
float getImageRate() const {return _imageRate;}
|
||||
bool isMirroringEnabled() const {return _mirroring;}
|
||||
|
||||
//setters
|
||||
void setImageRate(float imageRate) {_imageRate = imageRate;}
|
||||
void setImageSize(unsigned int width, unsigned int height);
|
||||
void setMirroringEnabled(bool enabled) {_mirroring = enabled;}
|
||||
|
||||
void setCalibration(const std::string & fileName);
|
||||
void setCalibration(const cv::Mat & cameraMatrix, const cv::Mat & distorsionCoefficients);
|
||||
@@ -81,6 +83,7 @@ private:
|
||||
float _imageRate;
|
||||
unsigned int _imageWidth;
|
||||
unsigned int _imageHeight;
|
||||
bool _mirroring;
|
||||
UTimer * _frameRateTimer;
|
||||
cv::Mat _k; // camera_matrix
|
||||
cv::Mat _d; // distorsion_coefficients
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
//getters
|
||||
float getImageRate() const {return _imageRate;}
|
||||
const Transform & getLocalTransform() const {return _localTransform;}
|
||||
bool isMirroringEnabled() const {return _mirroring;}
|
||||
float getFx() const {return _fx;}
|
||||
float getFy() const {return _fy;}
|
||||
float getCx() const {return _cx;}
|
||||
@@ -85,6 +86,7 @@ public:
|
||||
//setters
|
||||
void setImageRate(float imageRate) {_imageRate = imageRate;}
|
||||
void setLocalTransform(const Transform & localTransform) {_localTransform= localTransform;}
|
||||
void setMirroringEnabled(bool mirroring) {_mirroring = mirroring;}
|
||||
void setFx(float fx) {_fx = fx;}
|
||||
void setFy(float fy) {_fy = fy;}
|
||||
void setCx(float cx) {_cx = cx;}
|
||||
@@ -108,6 +110,7 @@ protected:
|
||||
private:
|
||||
float _imageRate;
|
||||
Transform _localTransform;
|
||||
bool _mirroring;
|
||||
UTimer * _frameRateTimer;
|
||||
float _fx;
|
||||
float _fy;
|
||||
|
||||
@@ -50,6 +50,7 @@ Camera::Camera(float imageRate,
|
||||
_imageRate(imageRate),
|
||||
_imageWidth(imageWidth),
|
||||
_imageHeight(imageHeight),
|
||||
_mirroring(false),
|
||||
_frameRateTimer(new UTimer())
|
||||
{
|
||||
}
|
||||
@@ -177,6 +178,10 @@ cv::Mat Camera::takeImage()
|
||||
cv::Mat temp = img.clone();
|
||||
cv::undistort(temp, img, _k, _d);
|
||||
}
|
||||
if(!img.empty() && _mirroring)
|
||||
{
|
||||
cv::flip(img,img,1);
|
||||
}
|
||||
UDEBUG("Time capturing image = %fs", timer.ticks());
|
||||
return img;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,15 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
|
||||
{
|
||||
cy = _cy; // override if set
|
||||
}
|
||||
if(!rgb.empty() && !depth.empty() && _mirroring)
|
||||
{
|
||||
cv::flip(rgb,rgb,1);
|
||||
cv::flip(depth,depth,1);
|
||||
if(cx != 0.0f)
|
||||
{
|
||||
cx = float(rgb.cols) - cx;
|
||||
}
|
||||
}
|
||||
UDEBUG("Time capturing image = %fs", timer.ticks());
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtCore/QMetaType>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include "rtabmap/gui/CloudViewer.h"
|
||||
#include "rtabmap/core/util3d.h"
|
||||
#include "rtabmap/core/RtabmapEvent.h"
|
||||
#endif
|
||||
#include "rtabmap/utilite/UStl.h"
|
||||
#include "rtabmap/utilite/UConversion.h"
|
||||
#include "rtabmap/utilite/UEventsHandler.h"
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
#include "rtabmap/core/util3d.h"
|
||||
#include "rtabmap/core/RtabmapEvent.h"
|
||||
#include "rtabmap/core/OdometryEvent.h"
|
||||
|
||||
using namespace rtabmap;
|
||||
|
||||
@@ -155,6 +155,7 @@ public:
|
||||
|
||||
// source panel
|
||||
double getGeneralInputRate() const;
|
||||
bool isSourceMirroring() const;
|
||||
bool isSourceImageUsed() const;
|
||||
bool isSourceDatabaseUsed() const;
|
||||
bool isSourceOpenniUsed() const;
|
||||
|
||||
@@ -1905,6 +1905,14 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
|
||||
((CameraOpenNI2*)_camera->cameraRGBD())->setGain(_preferencesDialog->getSourceOpenni2Gain());
|
||||
}
|
||||
}
|
||||
if(_camera->camera())
|
||||
{
|
||||
_camera->camera()->setMirroringEnabled(_preferencesDialog->isSourceMirroring());
|
||||
}
|
||||
if(_camera->cameraRGBD())
|
||||
{
|
||||
_camera->cameraRGBD()->setMirroringEnabled(_preferencesDialog->isSourceMirroring());
|
||||
}
|
||||
}
|
||||
if(_dbReader)
|
||||
{
|
||||
@@ -2633,6 +2641,7 @@ void MainWindow::startDetection()
|
||||
((CameraOpenNI2*)camera)->setGain(_preferencesDialog->getSourceOpenni2Gain());
|
||||
}
|
||||
}
|
||||
camera->setMirroringEnabled(_preferencesDialog->isSourceMirroring());
|
||||
|
||||
_camera = new CameraThread(camera);
|
||||
if(_odomThread)
|
||||
@@ -2738,6 +2747,7 @@ void MainWindow::startDetection()
|
||||
camera = 0;
|
||||
return;
|
||||
}
|
||||
camera->setMirroringEnabled(_preferencesDialog->isSourceMirroring());
|
||||
|
||||
_camera = new CameraThread(camera);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
||||
#ifdef _WIN32
|
||||
_ui->radioButton_openni2->setChecked(true);
|
||||
_ui->radioButton_opennipcl->setChecked(false);
|
||||
showOpenNI2GroupBox(true);
|
||||
#endif
|
||||
|
||||
if(RTABMAP_NONFREE == 0)
|
||||
@@ -241,6 +242,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
||||
|
||||
//Source panel
|
||||
connect(_ui->general_doubleSpinBox_imgRate, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
connect(_ui->source_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
//Image source
|
||||
connect(_ui->groupBox_sourceImage, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
_ui->stackedWidget_image->setCurrentIndex(_ui->source_comboBox_image_type->currentIndex());
|
||||
@@ -888,6 +890,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
||||
else if(groupBox->objectName() == _ui->groupBox_source0->objectName())
|
||||
{
|
||||
_ui->general_doubleSpinBox_imgRate->setValue(30.0);
|
||||
_ui->source_mirroring->setChecked(false);
|
||||
|
||||
_ui->groupBox_sourceImage->setChecked(false);
|
||||
_ui->source_spinBox_imgWidth->setValue(0);
|
||||
@@ -1143,6 +1146,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
|
||||
settings.beginGroup("Camera");
|
||||
_ui->groupBox_sourceImage->setChecked(settings.value("imageUsed", _ui->groupBox_sourceImage->isChecked()).toBool());
|
||||
_ui->general_doubleSpinBox_imgRate->setValue(settings.value("imgRate", _ui->general_doubleSpinBox_imgRate->value()).toDouble());
|
||||
_ui->source_mirroring->setChecked(settings.value("mirroring", _ui->source_mirroring->isChecked()).toBool());
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(settings.value("type", _ui->source_comboBox_image_type->currentIndex()).toInt());
|
||||
_ui->source_spinBox_imgWidth->setValue(settings.value("imgWidth",_ui->source_spinBox_imgWidth->value()).toInt());
|
||||
_ui->source_spinBox_imgheight->setValue(settings.value("imgHeight",_ui->source_spinBox_imgheight->value()).toInt());
|
||||
@@ -1391,6 +1395,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
|
||||
settings.beginGroup("Camera");
|
||||
settings.setValue("imageUsed", _ui->groupBox_sourceImage->isChecked());
|
||||
settings.setValue("imgRate", _ui->general_doubleSpinBox_imgRate->value());
|
||||
settings.setValue("mirroring", _ui->source_mirroring->isChecked());
|
||||
settings.setValue("type", _ui->source_comboBox_image_type->currentIndex());
|
||||
settings.setValue("imgWidth", _ui->source_spinBox_imgWidth->value());
|
||||
settings.setValue("imgHeight", _ui->source_spinBox_imgheight->value());
|
||||
@@ -3046,6 +3051,10 @@ double PreferencesDialog::getGeneralInputRate() const
|
||||
{
|
||||
return _ui->general_doubleSpinBox_imgRate->value();
|
||||
}
|
||||
bool PreferencesDialog::isSourceMirroring() const
|
||||
{
|
||||
return _ui->source_mirroring->isChecked();
|
||||
}
|
||||
bool PreferencesDialog::isSourceImageUsed() const
|
||||
{
|
||||
return _ui->groupBox_sourceImage->isChecked();
|
||||
@@ -3406,6 +3415,7 @@ void PreferencesDialog::testOdometry(int type)
|
||||
((CameraOpenNI2*)camera)->setGain(getSourceOpenni2Gain());
|
||||
}
|
||||
}
|
||||
camera->setMirroringEnabled(isSourceMirroring());
|
||||
|
||||
|
||||
if(camera)
|
||||
@@ -3573,6 +3583,7 @@ void PreferencesDialog::testRGBDCamera()
|
||||
((CameraOpenNI2*)camera)->setGain(getSourceOpenni2Gain());
|
||||
}
|
||||
}
|
||||
camera->setMirroringEnabled(isSourceMirroring());
|
||||
|
||||
|
||||
if(camera)
|
||||
@@ -3671,6 +3682,7 @@ void PreferencesDialog::calibrate()
|
||||
((CameraOpenNI2*)camera)->setGain(getSourceOpenni2Gain());
|
||||
}
|
||||
}
|
||||
camera->setMirroringEnabled(isSourceMirroring());
|
||||
|
||||
|
||||
if(camera)
|
||||
|
||||
@@ -63,9 +63,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-203</y>
|
||||
<width>744</width>
|
||||
<height>1101</height>
|
||||
<y>0</y>
|
||||
<width>737</width>
|
||||
<height>1320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
@@ -86,7 +86,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>20</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29">
|
||||
@@ -1288,6 +1288,20 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Mirroring mode (flip image horizontally). It has no effect on database source.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="source_mirroring">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -1719,34 +1733,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
<property name="title">
|
||||
<string>OpenNI 2</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_6">
|
||||
<item row="6" column="0">
|
||||
<widget class="QSpinBox" name="openni2_gain">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QSpinBox" name="openni2_exposure">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="openni2_autoExposure">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_54" columnstretch="0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="openni2_autoWhiteBalance">
|
||||
<property name="text">
|
||||
@@ -1767,6 +1754,16 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="openni2_autoExposure">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_218">
|
||||
<property name="text">
|
||||
@@ -1777,7 +1774,14 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="0">
|
||||
<widget class="QSpinBox" name="openni2_exposure">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_219">
|
||||
<property name="text">
|
||||
<string>Exposure.</string>
|
||||
@@ -1787,7 +1791,17 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="3" column="0">
|
||||
<widget class="QSpinBox" name="openni2_gain">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_220">
|
||||
<property name="text">
|
||||
<string>Gain.</string>
|
||||
@@ -1797,7 +1811,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="openni2_mirroring">
|
||||
<property name="text">
|
||||
<string/>
|
||||
@@ -1807,7 +1821,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="label_223">
|
||||
<property name="text">
|
||||
<string>Mirroring.</string>
|
||||
@@ -1878,10 +1892,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_21">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_55" columnstretch="0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_openniFx">
|
||||
<property name="maximum">
|
||||
@@ -4720,7 +4731,7 @@ When set to false, no new words are added to dictionary, so no more updates are
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_9">
|
||||
<layout class="QGridLayout" name="gridLayout_10" columnstretch="0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboBox_vh_strategy">
|
||||
<property name="sizeAdjustPolicy">
|
||||
|
||||
Reference in New Issue
Block a user