Commit 21ff0b70 authored by Thiago Santini's avatar Thiago Santini

Mimics most of Pupil Labs settings

parent d4a17470
......@@ -6,6 +6,7 @@ UVCCameraSession::UVCCameraSession(QObject *parent)
: QObject(parent),
m_surface(Q_NULLPTR),
streaming(false),
bandwidthFactor(1.3f),
dev(NULL),
devh(NULL)
{
......@@ -81,12 +82,17 @@ bool UVCCameraSession::load()
// TODO: parametrize this
uvc_set_focus_auto(devh, 0);
uvc_set_ae_priority(devh, 0);
uvc_set_ae_mode(devh, 1);
uvc_set_saturation(devh, 63);
uvc_set_exposure_abs(devh, 63);
uvc_set_backlight_compensation(devh, 2);
uvc_set_gamma(devh, 100);
if (isPupilFieldCamera()) {
bandwidthFactor = 2.0f;
uvc_set_ae_priority(devh, 1);
} else if (isPupilEyeCamera()) {
uvc_set_ae_priority(devh, 0);
uvc_set_ae_mode(devh, 1);
uvc_set_saturation(devh, 127); // do not set saturation to zero as to not lose color information
uvc_set_exposure_abs(devh, 63);
uvc_set_backlight_compensation(devh, 2);
uvc_set_gamma(devh, 100);
}
updateSourceCapabilities();
......@@ -136,14 +142,6 @@ bool UVCCameraSession::startPreview()
return false;
}
float bandwidthFactor = 1.3f;
uvc_device_descriptor *desc;
uvc_get_device_descriptor(dev, &desc);
QString name(desc->product);
if (name.contains("ID2"))
bandwidthFactor = 2.0f;
uvc_free_device_descriptor(desc);
res = uvc_stream_start(strmh, cb, (void*) this, bandwidthFactor, 0);
if (res != UVC_SUCCESS) {
qWarning() << "uvc_stream_start" << uvc_strerror(res);
......@@ -245,3 +243,27 @@ void UVCCameraSession::setViewfinderSettings(const QCameraViewfinderSettings &se
{
this->settings = settings;
}
bool UVCCameraSession::isPupilFieldCamera()
{
bool ret = false;
uvc_device_descriptor *desc;
uvc_get_device_descriptor(dev, &desc);
QString name(desc->product);
if ( name.contains("Pupil Cam1 ID2") )
ret = true;
uvc_free_device_descriptor(desc);
return ret;
}
bool UVCCameraSession::isPupilEyeCamera()
{
bool ret = false;
uvc_device_descriptor *desc;
uvc_get_device_descriptor(dev, &desc);
QString name(desc->product);
if ( name.contains("Pupil Cam1 ID0") || name.contains("Pupil Cam1 ID1") )
ret = true;
uvc_free_device_descriptor(desc);
return ret;
}
......@@ -52,6 +52,7 @@ private Q_SLOTS:
private:
bool streaming;
float bandwidthFactor;
QCamera::Status m_status;
QAbstractVideoSurface *m_surface;
......@@ -75,6 +76,9 @@ private:
bool qPixelFormat2UVCFrameFormat(const QVideoFrame::PixelFormat &qFormat, uvc_frame_format &uvcFormat);
static QMutex sessionMutex;
bool isPupilFieldCamera();
bool isPupilEyeCamera();
};
QT_END_NAMESPACE
......
......@@ -71,7 +71,7 @@ void UVCVideoDeviceControl::setSelectedDevice(int index)
uvc_error_t res;
res = uvc_get_device_list(ctx, &devList);
if (res < 0) {
qDebug() << "uvc_get_device_list" << uvc_strerror(res);
qWarning() << "uvc_get_device_list" << uvc_strerror(res);
return;
}
......@@ -84,7 +84,7 @@ void UVCVideoDeviceControl::setSelectedDevice(int index)
uvc_device_descriptor_t *desc;
res = uvc_get_device_descriptor(dev, &desc);
if (res < 0) {
qDebug() << "uvc_get_device_descriptor" << uvc_strerror(res);
qWarning() << "uvc_get_device_descriptor" << uvc_strerror(res);
return;
}
bool selectedDevice = QString::number(desc->idProduct).compare(device) == 0;
......@@ -95,6 +95,8 @@ void UVCVideoDeviceControl::setSelectedDevice(int index)
busyDevices[device] = true;
currentDevice = device;
m_session->setDevice(dev);
} else {
qWarning() << "Device is busy.";
}
break;
}
......@@ -123,10 +125,10 @@ void UVCVideoDeviceControl::updateDevices()
if (!ctx) {
// Init libuvc
qDebug() << "Initializing libuvc context...";
qInfo() << "Initializing libuvc context...";
res = uvc_init(&ctx, NULL);
if (res < 0) {
qDebug() << "uvc_init" << uvc_strerror(res);
qWarning() << "uvc_init" << uvc_strerror(res);
return;
}
}
......@@ -134,7 +136,7 @@ void UVCVideoDeviceControl::updateDevices()
uvc_device_t **devList;
res = uvc_get_device_list(ctx, &devList);
if (res < 0) {
qDebug() << "uvc_get_device_list" << uvc_strerror(res);
qWarning() << "uvc_get_device_list" << uvc_strerror(res);
return;
}
......@@ -147,7 +149,7 @@ void UVCVideoDeviceControl::updateDevices()
uvc_device_descriptor_t *desc;
res = uvc_get_device_descriptor(dev, &desc);
if (res < 0) {
qDebug() << "uvc_get_device_descriptor" << uvc_strerror(res);
qWarning() << "uvc_get_device_descriptor" << uvc_strerror(res);
break;
}
......
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