Commit 17c6683b authored by Thiago Santini's avatar Thiago Santini

Adds Tuebingen eye tracker to defaults

Also makes it a little easier to add future known configurations in the
future
parent 8dff3303
......@@ -64,34 +64,14 @@ QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo camera
QCameraViewfinderSettings recommended;
// Recommend based on known cameras
QString description = cameraInfo.description();
if (description == "Pupil Cam1 ID0") { // Pupil V1
recommended.setMaximumFrameRate(60);
recommended.setMinimumFrameRate(60);
recommended.setResolution(640, 480);
recommended.setPixelFormat( QVideoFrame::Format_Jpeg);
} else if (description == "Pupil Cam1 ID1") {
recommended.setMaximumFrameRate(60);
recommended.setMinimumFrameRate(60);
recommended.setResolution(640, 480);
recommended.setPixelFormat( QVideoFrame::Format_Jpeg);
} else if (description == "Pupil Cam1 ID2") {
recommended.setMaximumFrameRate(30);
recommended.setMinimumFrameRate(30);
recommended.setResolution(1280, 720);
recommended.setPixelFormat( QVideoFrame::Format_Jpeg);
} else if (description == "Pupil Cam2 ID0") { // Pupil V2
recommended.setMaximumFrameRate(60);
recommended.setMinimumFrameRate(60);
recommended.setResolution(400, 400);
recommended.setPixelFormat( QVideoFrame::Format_Jpeg);
} else if (description == "Pupil Cam2 ID1") {
recommended.setMaximumFrameRate(60);
recommended.setMinimumFrameRate(60);
recommended.setResolution(400, 400);
recommended.setPixelFormat( QVideoFrame::Format_Jpeg);
} else {
QString description = cameraInfo.description();
if (knownSettings.size() == 0)
buildKnownViewfinderSettings();
if (knownSettings.count(description)) {
recommended = knownSettings[description];
} else {
// Unknown; recommend to maximize fps and minimize resolution
recommended = camera->viewfinderSettings();
foreach (const QCameraViewfinderSettings &setting, camera->supportedViewfinderSettings()) {
......@@ -384,24 +364,32 @@ void Camera::searchDefaultCamera()
*
* 2) extend this so the user can add his own default cameras
*/
QRegularExpression re;
QStringList ets;
if (id.contains("eye", Qt::CaseInsensitive) ) {
if (id.contains("right", Qt::CaseInsensitive) )
re.setPattern("Pupil Cam. ID0");
if (id.contains("left", Qt::CaseInsensitive) )
re.setPattern("Pupil Cam. ID1");
if (id.contains("right", Qt::CaseInsensitive) ) {
ets.push_back("Pupil Cam. ID0");
ets.push_back("RYS THREE");
}
if (id.contains("left", Qt::CaseInsensitive) ) {
ets.push_back("Pupil Cam. ID1");
ets.push_back("RYS TWO");
}
}
if (id.contains("field", Qt::CaseInsensitive) ) {
ets.push_back("Pupil Cam. ID2");
ets.push_back("RYS ONE");
}
if (id.contains("field", Qt::CaseInsensitive) )
re.setPattern("Pupil Cam. ID2");
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
for (int i=0; i<cameras.size(); i++) {
if (re.match(cameras[i].deviceName()).hasMatch()) {
setCamera(cameras[i]);
if (!currentCameraInfo.isNull())
return;
for ( auto et : ets ) {
QRegularExpression re(et);
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
for (int i=0; i<cameras.size(); i++) {
if (re.match(cameras[i].deviceName()).hasMatch()) {
setCamera(cameras[i]);
if (!currentCameraInfo.isNull())
return;
}
}
}
......@@ -421,3 +409,35 @@ void Camera::loadUserCameraParameters()
loadAndSet(settings, "exposure_time");
loadAndSet(settings, "exposure_mode");
}
void Camera::buildKnownViewfinderSettings()
{
auto set = [this] (const QString &cid, const float &fps, const QSize &resolution, const QVideoFrame::PixelFormat &format) {
assert(this->knownSettings.count(cid) == 0);
QCameraViewfinderSettings setting;
setting.setMaximumFrameRate(fps);
setting.setMinimumFrameRate(fps);
setting.setResolution(resolution);
setting.setPixelFormat(format);
this->knownSettings[cid] = std::move(setting);
};
// Pupil eye V1
set("Pupil Cam1 ID0", 60, {640, 480} , QVideoFrame::Format_Jpeg);
set("Pupil Cam1 ID1", 60, {640, 480} , QVideoFrame::Format_Jpeg);
// Pupil eye v2
set("Pupil Cam2 ID0", 60, {400, 400} , QVideoFrame::Format_Jpeg);
set("Pupil Cam2 ID1", 60, {400, 400} , QVideoFrame::Format_Jpeg);
// Pupil field
set("Pupil Cam1 ID2", 30, {1280, 720}, QVideoFrame::Format_Jpeg);
// Tuebingen v1
set("RYS ONE", 60, {640, 480}, QVideoFrame::Format_Jpeg);
set("RYS TWO", 60, {320, 240}, QVideoFrame::Format_Jpeg);
set("RYS THREE", 60, {320, 240}, QVideoFrame::Format_Jpeg);
// Generic
set("HD Webcam C525", 30, {640, 480}, QVideoFrame::Format_Jpeg);
}
......@@ -316,6 +316,9 @@ private:
}
void loadUserCameraParameters();
std::map<QString, QCameraViewfinderSettings> knownSettings;
void buildKnownViewfinderSettings();
private slots:
void reset();
};
......
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