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

Adds PuRe reference, starts parametrizing camera parameters

parent a08b88c0
...@@ -18,11 +18,12 @@ Camera::Camera(QString id, QObject *parent) ...@@ -18,11 +18,12 @@ Camera::Camera(QString id, QObject *parent)
this->id = id; this->id = id;
if (id.contains("eye", Qt::CaseInsensitive) ) if (id.contains("eye", Qt::CaseInsensitive) )
colorCode = CV_8UC1; colorCode = CV_8UC1;
ui = new CameraUI(); ui = new CameraUI();
ui->moveToThread(QApplication::instance()->thread()); ui->moveToThread(QApplication::instance()->thread());
connect(ui, SIGNAL(setCamera(QCameraInfo)), this, SLOT(setCamera(QCameraInfo)) ); connect(ui, SIGNAL(setCamera(QCameraInfo)), this, SLOT(setCamera(QCameraInfo)) );
connect(ui, SIGNAL(setViewfinderSettings(QCameraViewfinderSettings)), this, SLOT(setViewfinderSettings(QCameraViewfinderSettings)) ); connect(ui, SIGNAL(setViewfinderSettings(QCameraViewfinderSettings)), this, SLOT(setViewfinderSettings(QCameraViewfinderSettings)) );
connect(ui, SIGNAL(setColorCode(int)), this, SLOT(setColorCode(int)) ); 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); settings = new QSettings(gCfgDir + "/" + id + " Camera", QSettings::IniFormat);
} }
...@@ -52,7 +53,7 @@ void Camera::reset() ...@@ -52,7 +53,7 @@ void Camera::reset()
if (frameGrabber) { if (frameGrabber) {
frameGrabber->deleteLater(); frameGrabber->deleteLater();
frameGrabber = NULL; frameGrabber = NULL;
} }
} }
QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo cameraInfo) QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo cameraInfo)
...@@ -184,8 +185,9 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings ...@@ -184,8 +185,9 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
settingsList = camera->supportedViewfinderSettings(); settingsList = camera->supportedViewfinderSettings();
msg = currentCameraInfo.description() + " " + toQString(settings); msg = currentCameraInfo.description() + " " + toQString(settings);
retriesLeft = maxRetries; retriesLeft = maxRetries;
} }
saveCfg();
saveCfg();
qInfo() << id << msg; qInfo() << id << msg;
QMetaObject::invokeMethod(ui, "updateSettings", Q_ARG(QList<QCameraViewfinderSettings>, settingsList), Q_ARG(QCameraViewfinderSettings, currentViewfinderSettings) ); QMetaObject::invokeMethod(ui, "updateSettings", Q_ARG(QList<QCameraViewfinderSettings>, settingsList), Q_ARG(QCameraViewfinderSettings, currentViewfinderSettings) );
} }
...@@ -197,6 +199,30 @@ void Camera::setColorCode(int code) ...@@ -197,6 +199,30 @@ void Camera::setColorCode(int code)
saveCfg(); 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() void Camera::showOptions()
{ {
QMetaObject::invokeMethod(ui, "update", Q_ARG(QCameraInfo, currentCameraInfo), Q_ARG(int, colorCode)); QMetaObject::invokeMethod(ui, "update", Q_ARG(QCameraInfo, currentCameraInfo), Q_ARG(int, colorCode));
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
#include <QLabel> #include <QLabel>
#include <QGridLayout> #include <QGridLayout>
#include <QRegularExpression> #include <QRegularExpression>
#include <QFormLayout>
#include "opencv/cv.h" #include "opencv/cv.h"
#include "FrameGrabber.h" #include "FrameGrabber.h"
class CameraUI : public QDialog class CameraUI : public QDialog
{ {
Q_OBJECT Q_OBJECT
...@@ -31,7 +33,8 @@ public: ...@@ -31,7 +33,8 @@ public:
QGridLayout *layout = new QGridLayout(); QGridLayout *layout = new QGridLayout();
QHBoxLayout *hBoxLayout; QHBoxLayout *hBoxLayout;
QGroupBox *box; QFormLayout *formLayout;
QGroupBox *box;
devicesBox = new QComboBox(); devicesBox = new QComboBox();
hBoxLayout = new QHBoxLayout(); hBoxLayout = new QHBoxLayout();
...@@ -54,7 +57,17 @@ public: ...@@ -54,7 +57,17 @@ public:
box = new QGroupBox("Color:"); box = new QGroupBox("Color:");
box->setLayout(hBoxLayout); box->setLayout(hBoxLayout);
hBoxLayout->addWidget(colorBox); hBoxLayout->addWidget(colorBox);
layout->addWidget(box); 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); setLayout(layout);
connect(devicesBox, SIGNAL(currentIndexChanged(int)), connect(devicesBox, SIGNAL(currentIndexChanged(int)),
...@@ -117,17 +130,33 @@ public slots: ...@@ -117,17 +130,33 @@ public slots:
signals: signals:
void setCamera(QCameraInfo cameraInfo); void setCamera(QCameraInfo cameraInfo);
void setViewfinderSettings(QCameraViewfinderSettings settings); void setViewfinderSettings(QCameraViewfinderSettings settings);
void setColorCode(int code); void setColorCode(int code);
void setParameter(QString what, float value);
private slots: private slots:
void deviceChanged(int i) { emit setCamera(devicesBox->itemData(i).value<QCameraInfo>());} void deviceChanged(int i) { emit setCamera(devicesBox->itemData(i).value<QCameraInfo>());}
void settingsChanged(int i) { emit setViewfinderSettings(settingsBox->itemData(i).value<QCameraViewfinderSettings>());} void settingsChanged(int i) { emit setViewfinderSettings(settingsBox->itemData(i).value<QCameraViewfinderSettings>());}
void colorChanged(int i) { emit setColorCode(colorBox->itemData(i).value<int>()); } 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: private:
QComboBox *devicesBox; QComboBox *devicesBox;
QComboBox *settingsBox; QComboBox *settingsBox;
QComboBox *colorBox; 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 class Camera : public QObject
...@@ -151,7 +180,8 @@ public slots: ...@@ -151,7 +180,8 @@ public slots:
void setViewfinderSettings(QCameraViewfinderSettings settings); void setViewfinderSettings(QCameraViewfinderSettings settings);
void setCamera(const QCameraInfo &cameraInfo); void setCamera(const QCameraInfo &cameraInfo);
void setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings settings); void setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings settings);
void setColorCode(int code); void setColorCode(int code);
void setParameter(QString what, float value);
void showOptions(); void showOptions();
void saveCfg(); void saveCfg();
void loadCfg(); void loadCfg();
......
...@@ -105,7 +105,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren ...@@ -105,7 +105,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
optionAction = new QAction("Camera", optionsGroup); optionAction = new QAction("Camera", optionsGroup);
optionAction->setData(QVariant::fromValue(optionAction->text())); optionAction->setData(QVariant::fromValue(optionAction->text()));
optionAction->setCheckable(false); optionAction->setCheckable(false);
ui->menuOptions->addAction(optionAction); ui->menuOptions->addAction(optionAction);
optionAction = new QAction("Image Processor", optionsGroup); optionAction = new QAction("Image Processor", optionsGroup);
optionAction->setData(QVariant::fromValue(optionAction->text())); optionAction->setData(QVariant::fromValue(optionAction->text()));
...@@ -288,7 +288,7 @@ void CameraWidget::options(QAction* action) ...@@ -288,7 +288,7 @@ void CameraWidget::options(QAction* action)
QMetaObject::invokeMethod(camera, "showOptions", Qt::QueuedConnection); QMetaObject::invokeMethod(camera, "showOptions", Qt::QueuedConnection);
} }
} }
if (option == "image processor") if (option == "image processor")
if (imageProcessor) if (imageProcessor)
QMetaObject::invokeMethod(imageProcessor, "showOptions", Qt::QueuedConnection, Q_ARG(QPoint, this->pos())); QMetaObject::invokeMethod(imageProcessor, "showOptions", Qt::QueuedConnection, Q_ARG(QPoint, this->pos()));
......
...@@ -488,17 +488,22 @@ void MainWindow::menuOption(QAction* action) ...@@ -488,17 +488,22 @@ void MainWindow::menuOption(QAction* action)
void MainWindow::showReferencesDialog() void MainWindow::showReferencesDialog()
{ {
ReferenceList::add( "Santini et al.", 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", "EyeRecToo: Open-source Software for Real-time Pervasive Head-mounted Eye Tracking",
"VISAPP", "2017a", "VISAPP", "2017a",
"http://www.scitepress.org/DigitalLibrary/PublicationsDetail.aspx?ID=gLeoir7PxnI=&t=1" "http://www.scitepress.org/DigitalLibrary/PublicationsDetail.aspx?ID=gLeoir7PxnI=&t=1"
); );
ReferenceList::add( "Santini et al.", ReferenceList::add( "Santini et al.",
"CalibMe: Fast and Unsupervised Eye Tracker Calibration for Gaze-Based Pervasive Human-Computer Interaction", "CalibMe: Fast and Unsupervised Eye Tracker Calibration for Gaze-Based Pervasive Human-Computer Interaction",
"CHI", "2017b", "CHI", "2017b",
"http://dl.acm.org/citation.cfm?id=3025453.3025950" "http://dl.acm.org/citation.cfm?id=3025453.3025950"
); );
ReferenceList::add( "Fuhl et al.", ReferenceList::add( "Fuhl et al.",
"ElSe: Ellipse Selection for Robust Pupil Detection in Real-World Environments", "ElSe: Ellipse Selection for Robust Pupil Detection in Real-World Environments",
"ETRA", "2016", "ETRA", "2016",
"http://dl.acm.org/citation.cfm?id=2857505" "http://dl.acm.org/citation.cfm?id=2857505"
......
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