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)
this->id = id;
if (id.contains("eye", Qt::CaseInsensitive) )
colorCode = CV_8UC1;
ui = new CameraUI();
ui->moveToThread(QApplication::instance()->thread());
ui = new CameraUI();
ui->moveToThread(QApplication::instance()->thread());
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(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);
}
......@@ -52,7 +53,7 @@ void Camera::reset()
if (frameGrabber) {
frameGrabber->deleteLater();
frameGrabber = NULL;
}
}
}
QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo cameraInfo)
......@@ -184,8 +185,9 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
settingsList = camera->supportedViewfinderSettings();
msg = currentCameraInfo.description() + " " + toQString(settings);
retriesLeft = maxRetries;
}
saveCfg();
}
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,7 +33,8 @@ public:
QGridLayout *layout = new QGridLayout();
QHBoxLayout *hBoxLayout;
QGroupBox *box;
QFormLayout *formLayout;
QGroupBox *box;
devicesBox = new QComboBox();
hBoxLayout = new QHBoxLayout();
......@@ -54,7 +57,17 @@ public:
box = new QGroupBox("Color:");
box->setLayout(hBoxLayout);
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);
connect(devicesBox, SIGNAL(currentIndexChanged(int)),
......@@ -117,17 +130,33 @@ public slots:
signals:
void setCamera(QCameraInfo cameraInfo);
void setViewfinderSettings(QCameraViewfinderSettings settings);
void setColorCode(int code);
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 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
......@@ -151,7 +180,8 @@ public slots:
void setViewfinderSettings(QCameraViewfinderSettings settings);
void setCamera(const QCameraInfo &cameraInfo);
void setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings settings);
void setColorCode(int code);
void setColorCode(int code);
void setParameter(QString what, float value);
void showOptions();
void saveCfg();
void loadCfg();
......
......@@ -105,7 +105,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
optionAction = new QAction("Camera", optionsGroup);
optionAction->setData(QVariant::fromValue(optionAction->text()));
optionAction->setCheckable(false);
ui->menuOptions->addAction(optionAction);
ui->menuOptions->addAction(optionAction);
optionAction = new QAction("Image Processor", optionsGroup);
optionAction->setData(QVariant::fromValue(optionAction->text()));
......@@ -288,7 +288,7 @@ void CameraWidget::options(QAction* action)
QMetaObject::invokeMethod(camera, "showOptions", Qt::QueuedConnection);
}
}
if (option == "image processor")
if (option == "image processor")
if (imageProcessor)
QMetaObject::invokeMethod(imageProcessor, "showOptions", Qt::QueuedConnection, Q_ARG(QPoint, this->pos()));
......
......@@ -488,17 +488,22 @@ void MainWindow::menuOption(QAction* action)
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",
"VISAPP", "2017a",
"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",
"CHI", "2017b",
"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",
"ETRA", "2016",
"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