Commit 9d532627 authored by Thiago Santini's avatar Thiago Santini

Moving from sliders to spinboxes

parent 6a69a27f
...@@ -206,21 +206,39 @@ void Camera::setParameter(QString what, float value) ...@@ -206,21 +206,39 @@ void Camera::setParameter(QString what, float value)
return; return;
QCameraImageProcessing *ip = camera->imageProcessing(); QCameraImageProcessing *ip = camera->imageProcessing();
QCameraExposure *exp = camera->exposure();
if (!ip->isAvailable())
return;
QString parameter = what.toLower(); QString parameter = what.toLower();
if (parameter == "brightness") qDebug() << what << value;
ip->setBrightness(value);
if (parameter == "contrast") if ( ip->isAvailable() ) {
ip->setContrast(value); if (parameter == "brightness")
if (parameter == "white balance") ip->setBrightness(value);
ip->setManualWhiteBalance(value); if (parameter == "contrast")
if (parameter == "saturation") ip->setContrast(value);
ip->setSaturation(value); if (parameter == "white balance")
if (parameter == "sharpening level") ip->setManualWhiteBalance(value);
ip->setSharpeningLevel(value); if (parameter == "saturation")
ip->setSaturation(value);
if (parameter == "sharpening level")
ip->setSharpeningLevel(value);
}
if ( exp->isAvailable() ) {
if (parameter == "exposure mode") {
switch ( (int) value ) {
case 1:
exp->setExposureMode(QCameraExposure::ExposureManual);
break;
case 2:
exp->setExposureMode(QCameraExposure::ExposureAuto);
break;
}
}
if (parameter == "exposure time")
exp->setManualAperture(value);
}
} }
void Camera::showOptions() void Camera::showOptions()
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <QGridLayout> #include <QGridLayout>
#include <QRegularExpression> #include <QRegularExpression>
#include <QFormLayout> #include <QFormLayout>
#include <QDoubleSpinBox>
#include "opencv/cv.h" #include "opencv/cv.h"
...@@ -59,13 +60,36 @@ public: ...@@ -59,13 +60,36 @@ public:
hBoxLayout->addWidget(colorBox); hBoxLayout->addWidget(colorBox);
layout->addWidget(box); layout->addWidget(box);
// Sliders are prettier and easier, but spinboxes are more accurate; unfortunatelly, that's what we favor.
bool useSliders = false;
QComboBox *parBox;
box = new QGroupBox("Parameters:"); box = new QGroupBox("Parameters:");
box->setWhatsThis("Set camera parameters mode or values as % of their range.\nCurrently, no test is performed to check if the camera actually supports changing the parameter.");
box->setToolTip(box->whatsThis());
formLayout = new QFormLayout(); formLayout = new QFormLayout();
addSlider(formLayout, "Brightness"); QStringList list = {
addSlider(formLayout, "Contrast"); "Brightness",
addSlider(formLayout, "White Balance"); "Contrast",
addSlider(formLayout, "Saturation"); "White Balance",
addSlider(formLayout, "Sharpening Level"); "Saturation",
"Sharpening Level",
"Gamma",
"Gain",
"Backlight",
"Exposure Time",
};
for (auto i = list.begin(); i != list.end(); i++) {
if (useSliders)
addSlider(formLayout, *i);
else
addSpinBox(formLayout, *i);
}
parBox = addComboBox(formLayout, "Exposure Mode");
parBox->addItem("Manual", 1);
parBox->addItem("Auto", 2);
parBox->addItem("Shutter", 4);
parBox->addItem("Aperture", 8);
box->setLayout(formLayout); box->setLayout(formLayout);
layout->addWidget(box, 0, 1, 3, 1); layout->addWidget(box, 0, 1, 3, 1);
...@@ -141,6 +165,14 @@ private slots: ...@@ -141,6 +165,14 @@ private slots:
QSlider *slider = static_cast<QSlider*>( QObject::sender() ); QSlider *slider = static_cast<QSlider*>( QObject::sender() );
emit setParameter(slider->objectName(), slider->value() / 100.0); emit setParameter(slider->objectName(), slider->value() / 100.0);
} }
void spinBoxChanged(double value) {
QDoubleSpinBox *sb = static_cast<QDoubleSpinBox*>( QObject::sender() );
emit setParameter(sb->objectName(), value/ 100.0);
}
void comboBoxChanged() {
QComboBox *box = static_cast<QComboBox*>( QObject::sender() );
emit setParameter(box->objectName(), box->currentData().toFloat());
}
private: private:
QComboBox *devicesBox; QComboBox *devicesBox;
...@@ -157,6 +189,26 @@ private: ...@@ -157,6 +189,26 @@ private:
formLayout->addRow(new QLabel(label), slider); formLayout->addRow(new QLabel(label), slider);
connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()) ); connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()) );
} }
void addSpinBox(QFormLayout *formLayout, QString label ) {
QDoubleSpinBox *sb = new QDoubleSpinBox();
sb->setMinimum(0);
sb->setMaximum(100);
sb->setSingleStep(0.5);
sb->setDecimals(1);
sb->setObjectName(label);
sb->setSuffix("%");
formLayout->addRow(new QLabel(label), sb);
connect(sb, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged(double)) );
}
QComboBox* addComboBox(QFormLayout *formLayout, QString label ) {
QComboBox *box = new QComboBox();
box->setObjectName(label);
formLayout->addRow(new QLabel(label), box);
connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBoxChanged()) );
return box;
}
}; };
class Camera : public QObject class Camera : public QObject
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment