mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-14 23:40:20 +08:00
CameraStereoVideo: added resolution options for usb camera
This commit is contained in:
@@ -70,6 +70,8 @@ public:
|
||||
virtual bool isCalibrated() const;
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
void setResolution(int width, int height) {_width=width, _height=height;}
|
||||
|
||||
protected:
|
||||
virtual SensorData captureImage(CameraInfo * info = 0);
|
||||
|
||||
@@ -84,6 +86,8 @@ private:
|
||||
CameraVideo::Source src_;
|
||||
int usbDevice_;
|
||||
int usbDevice2_;
|
||||
int _width;
|
||||
int _height;
|
||||
};
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
@@ -31,6 +31,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#if CV_MAJOR_VERSION > 3
|
||||
#include <opencv2/videoio/videoio_c.h>
|
||||
#if CV_MAJOR_VERSION > 4
|
||||
#include <opencv2/videoio/legacy/constants_c.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace rtabmap
|
||||
@@ -51,7 +54,9 @@ CameraStereoVideo::CameraStereoVideo(
|
||||
rectifyImages_(rectifyImages),
|
||||
src_(CameraVideo::kVideoFile),
|
||||
usbDevice_(0),
|
||||
usbDevice2_(-1)
|
||||
usbDevice2_(-1),
|
||||
_width(0),
|
||||
_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,7 +72,9 @@ CameraStereoVideo::CameraStereoVideo(
|
||||
rectifyImages_(rectifyImages),
|
||||
src_(CameraVideo::kVideoFile),
|
||||
usbDevice_(0),
|
||||
usbDevice2_(-1)
|
||||
usbDevice2_(-1),
|
||||
_width(0),
|
||||
_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -80,7 +87,9 @@ CameraStereoVideo::CameraStereoVideo(
|
||||
rectifyImages_(rectifyImages),
|
||||
src_(CameraVideo::kUsbDevice),
|
||||
usbDevice_(device),
|
||||
usbDevice2_(-1)
|
||||
usbDevice2_(-1),
|
||||
_width(0),
|
||||
_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,7 +103,9 @@ CameraStereoVideo::CameraStereoVideo(
|
||||
rectifyImages_(rectifyImages),
|
||||
src_(CameraVideo::kUsbDevice),
|
||||
usbDevice_(deviceLeft),
|
||||
usbDevice2_(deviceRight)
|
||||
usbDevice2_(deviceRight),
|
||||
_width(0),
|
||||
_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -183,6 +194,37 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
}
|
||||
|
||||
stereoModel_.setLocalTransform(this->getLocalTransform());
|
||||
|
||||
if(src_ == CameraVideo::kUsbDevice)
|
||||
{
|
||||
if(stereoModel_.isValidForProjection())
|
||||
{
|
||||
if(capture_.isOpened())
|
||||
{
|
||||
capture_.set(CV_CAP_PROP_FRAME_WIDTH, stereoModel_.left().imageWidth()*(capture2_.isOpened()?1:2));
|
||||
capture_.set(CV_CAP_PROP_FRAME_HEIGHT, stereoModel_.left().imageHeight());
|
||||
if(capture2_.isOpened())
|
||||
{
|
||||
capture2_.set(CV_CAP_PROP_FRAME_WIDTH, stereoModel_.right().imageWidth());
|
||||
capture2_.set(CV_CAP_PROP_FRAME_HEIGHT, stereoModel_.right().imageHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_width > 0 && _height > 0)
|
||||
{
|
||||
if(capture_.isOpened())
|
||||
{
|
||||
capture_.set(CV_CAP_PROP_FRAME_WIDTH, _width*(capture2_.isOpened()?1:2));
|
||||
capture_.set(CV_CAP_PROP_FRAME_HEIGHT, _height);
|
||||
if(capture2_.isOpened())
|
||||
{
|
||||
capture2_.set(CV_CAP_PROP_FRAME_WIDTH, _width);
|
||||
capture2_.set(CV_CAP_PROP_FRAME_HEIGHT, _height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rectifyImages_ && !stereoModel_.isValidForRectification())
|
||||
{
|
||||
UERROR("Parameter \"rectifyImages\" is set, but no stereo model is loaded or valid.");
|
||||
|
||||
@@ -740,6 +740,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
||||
connect(_ui->lineEdit_cameraStereoVideo_path_2, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
|
||||
connect(_ui->spinBox_stereo_right_device, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
connect(_ui->spinBox_stereousbcam_streamWidth, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
connect(_ui->spinBox_stereousbcam_streamHeight, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
|
||||
connect(_ui->comboBox_stereoZed_resolution, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
connect(_ui->comboBox_stereoZed_quality, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||
@@ -1954,6 +1956,8 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
||||
_ui->lineEdit_cameraStereoVideo_path->setText("");
|
||||
_ui->lineEdit_cameraStereoVideo_path_2->setText("");
|
||||
_ui->spinBox_stereo_right_device->setValue(-1);
|
||||
_ui->spinBox_stereousbcam_streamWidth->setValue(0);
|
||||
_ui->spinBox_stereousbcam_streamHeight->setValue(0);
|
||||
_ui->comboBox_stereoZed_resolution->setCurrentIndex(2);
|
||||
_ui->comboBox_stereoZed_quality->setCurrentIndex(1);
|
||||
_ui->checkbox_stereoZed_selfCalibration->setChecked(true);
|
||||
@@ -2408,6 +2412,8 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
|
||||
_ui->lineEdit_cameraStereoVideo_path->setText(settings.value("path", _ui->lineEdit_cameraStereoVideo_path->text()).toString());
|
||||
_ui->lineEdit_cameraStereoVideo_path_2->setText(settings.value("path2", _ui->lineEdit_cameraStereoVideo_path_2->text()).toString());
|
||||
_ui->spinBox_stereo_right_device->setValue(settings.value("device2", _ui->spinBox_stereo_right_device->value()).toInt());
|
||||
_ui->spinBox_stereousbcam_streamWidth->setValue(settings.value("width", _ui->spinBox_stereousbcam_streamWidth->value()).toInt());
|
||||
_ui->spinBox_stereousbcam_streamHeight->setValue(settings.value("height", _ui->spinBox_stereousbcam_streamHeight->value()).toInt());
|
||||
settings.endGroup(); // StereoVideo
|
||||
|
||||
settings.beginGroup("StereoZed");
|
||||
@@ -2894,6 +2900,8 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
|
||||
settings.setValue("path", _ui->lineEdit_cameraStereoVideo_path->text());
|
||||
settings.setValue("path2", _ui->lineEdit_cameraStereoVideo_path_2->text());
|
||||
settings.setValue("device2", _ui->spinBox_stereo_right_device->value());
|
||||
settings.setValue("width", _ui->spinBox_stereousbcam_streamWidth->value());
|
||||
settings.setValue("height", _ui->spinBox_stereousbcam_streamHeight->value());
|
||||
settings.endGroup(); // StereoVideo
|
||||
|
||||
settings.beginGroup("StereoZed");
|
||||
@@ -5933,6 +5941,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor)
|
||||
this->getGeneralInputRate(),
|
||||
this->getSourceLocalTransform());
|
||||
}
|
||||
((CameraStereoVideo*)camera)->setResolution(_ui->spinBox_stereousbcam_streamWidth->value(), _ui->spinBox_stereousbcam_streamHeight->value());
|
||||
}
|
||||
else if(driver == kSrcStereoVideo)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-976</y>
|
||||
<y>-673</y>
|
||||
<width>686</width>
|
||||
<height>3357</height>
|
||||
</rect>
|
||||
@@ -95,7 +95,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>22</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
||||
@@ -4896,7 +4896,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget_stereo">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_49">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_91">
|
||||
@@ -5402,19 +5402,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
<string>Usb Camera</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_99" columnstretch="0,1">
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_70">
|
||||
<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="1">
|
||||
<widget class="QLabel" name="label_470">
|
||||
<property name="text">
|
||||
@@ -5428,6 +5415,42 @@ 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="QSpinBox" name="spinBox_stereousbcam_streamHeight">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_620">
|
||||
<property name="text">
|
||||
<string>Stream width (0 for default resolution).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_619">
|
||||
<property name="text">
|
||||
<string>Stream height (0 for default resolution).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSpinBox" name="spinBox_stereo_right_device">
|
||||
<property name="minimum">
|
||||
@@ -5435,6 +5458,29 @@ 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="QSpinBox" name="spinBox_stereousbcam_streamWidth">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer_51">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user