Commit 6a69a27f authored by Thiago Santini's avatar Thiago Santini

Adds PuRe reference, starts parametrizing camera parameters

parent a08b88c0
......@@ -23,6 +23,7 @@ Camera::Camera(QString id, QObject *parent)
connect(ui, SIGNAL(setCamera(QCameraInfo)), this, SLOT(setCamera(QCameraInfo)) );
connect(ui, SIGNAL(setViewfinderSettings(QCameraViewfinderSettings)), this, SLOT(setViewfinderSettings(QCameraViewfinderSettings)) );
connect(ui, SIGNAL(setColorCode(int)), this, SLOT(setColorCode(int)) );
connect(ui, SIGNAL(setParameter(QString,float)), this, SLOT(setParameter(QString,float)) );
settings = new QSettings(gCfgDir + "/" + id + " Camera", QSettings::IniFormat);
}
......@@ -185,6 +186,7 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
msg = currentCameraInfo.description() + " " + toQString(settings);
retriesLeft = maxRetries;
}
saveCfg();
qInfo() << id << msg;
QMetaObject::invokeMethod(ui, "updateSettings", Q_ARG(QList<QCameraViewfinderSettings>, settingsList), Q_ARG(QCameraViewfinderSettings, currentViewfinderSettings) );
......@@ -197,6 +199,30 @@ void Camera::setColorCode(int code)
saveCfg();
}
void Camera::setParameter(QString what, float value)
{
//qDebug() << what << value;
if (!camera)
return;
QCameraImageProcessing *ip = camera->imageProcessing();
if (!ip->isAvailable())
return;
QString parameter = what.toLower();
if (parameter == "brightness")
ip->setBrightness(value);
if (parameter == "contrast")
ip->setContrast(value);
if (parameter == "white balance")
ip->setManualWhiteBalance(value);
if (parameter == "saturation")
ip->setSaturation(value);
if (parameter == "sharpening level")
ip->setSharpeningLevel(value);
}
void Camera::showOptions()
{
QMetaObject::invokeMethod(ui, "update", Q_ARG(QCameraInfo, currentCameraInfo), Q_ARG(int, colorCode));
......
......@@ -13,11 +13,13 @@
#include <QLabel>
#include <QGridLayout>
#include <QRegularExpression>
#include <QFormLayout>
#include "opencv/cv.h"
#include "FrameGrabber.h"
class CameraUI : public QDialog
{
Q_OBJECT
......@@ -31,6 +33,7 @@ public:
QGridLayout *layout = new QGridLayout();
QHBoxLayout *hBoxLayout;
QFormLayout *formLayout;
QGroupBox *box;
devicesBox = new QComboBox();
......@@ -56,6 +59,16 @@ public:
hBoxLayout->addWidget(colorBox);
layout->addWidget(box);
box = new QGroupBox("Parameters:");
formLayout = new QFormLayout();
addSlider(formLayout, "Brightness");
addSlider(formLayout, "Contrast");
addSlider(formLayout, "White Balance");
addSlider(formLayout, "Saturation");
addSlider(formLayout, "Sharpening Level");
box->setLayout(formLayout);
layout->addWidget(box, 0, 1, 3, 1);
setLayout(layout);
connect(devicesBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(deviceChanged(int)) );
......@@ -118,16 +131,32 @@ signals:
void setCamera(QCameraInfo cameraInfo);
void setViewfinderSettings(QCameraViewfinderSettings settings);
void setColorCode(int code);
void setParameter(QString what, float value);
private slots:
void deviceChanged(int i) { emit setCamera(devicesBox->itemData(i).value<QCameraInfo>());}
void settingsChanged(int i) { emit setViewfinderSettings(settingsBox->itemData(i).value<QCameraViewfinderSettings>());}
void colorChanged(int i) { emit setColorCode(colorBox->itemData(i).value<int>()); }
void sliderReleased() {
QSlider *slider = static_cast<QSlider*>( QObject::sender() );
emit setParameter(slider->objectName(), slider->value() / 100.0);
}
private:
QComboBox *devicesBox;
QComboBox *settingsBox;
QComboBox *colorBox;
QSlider *brightnessSlider;
void addSlider(QFormLayout *formLayout, QString label ) {
QSlider *slider = new QSlider( Qt::Horizontal );
slider->setMinimum(0);
slider->setMaximum(100);
slider->setSingleStep(1);
slider->setObjectName(label);
formLayout->addRow(new QLabel(label), slider);
connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()) );
}
};
class Camera : public QObject
......@@ -152,6 +181,7 @@ public slots:
void setCamera(const QCameraInfo &cameraInfo);
void setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings settings);
void setColorCode(int code);
void setParameter(QString what, float value);
void showOptions();
void saveCfg();
void loadCfg();
......
......@@ -488,6 +488,11 @@ void MainWindow::menuOption(QAction* action)
void MainWindow::showReferencesDialog()
{
ReferenceList::add( "Santini et al.",
"PuRe: Robust pupil detection for real-time pervasive eye tracking",
"CVIU", "2018",
"https://www.sciencedirect.com/science/article/pii/S1077314218300146"
);
ReferenceList::add( "Santini et al.",
"EyeRecToo: Open-source Software for Real-time Pervasive Head-mounted Eye Tracking",
"VISAPP", "2017a",
......
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