Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uvcengine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Thiago Santini
uvcengine
Commits
98ac2765
Commit
98ac2765
authored
Mar 08, 2018
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starts camera parameter access implementation
parent
4c296197
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
191 additions
and
126 deletions
+191
-126
uvcengine/uvccameraimageprocessingcontrol.cpp
uvcengine/uvccameraimageprocessingcontrol.cpp
+41
-0
uvcengine/uvccameraimageprocessingcontrol.h
uvcengine/uvccameraimageprocessingcontrol.h
+30
-0
uvcengine/uvccameraservice.cpp
uvcengine/uvccameraservice.cpp
+6
-43
uvcengine/uvccameraservice.h
uvcengine/uvccameraservice.h
+5
-42
uvcengine/uvccamerasession.cpp
uvcengine/uvccamerasession.cpp
+65
-30
uvcengine/uvccamerasession.h
uvcengine/uvccamerasession.h
+36
-5
uvcengine/uvcengine.pro
uvcengine/uvcengine.pro
+8
-6
No files found.
uvcengine/uvccameraimageprocessingcontrol.cpp
0 → 100644
View file @
98ac2765
#include "uvccameraimageprocessingcontrol.h"
#include "uvccamerasession.h"
QT_BEGIN_NAMESPACE
UVCCameraImageProcessingControl
::
UVCCameraImageProcessingControl
(
UVCCameraSession
*
session
)
:
QCameraImageProcessingControl
(
session
)
,
m_session
(
session
)
{
}
UVCCameraImageProcessingControl
::~
UVCCameraImageProcessingControl
()
{
}
bool
UVCCameraImageProcessingControl
::
isParameterSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
{
return
m_session
->
isImageProcessingParameterSupported
(
parameter
);
}
bool
UVCCameraImageProcessingControl
::
isParameterValueSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
)
const
{
return
m_session
->
isImageProcessingParameterValueSupported
(
parameter
,
value
);
}
QVariant
UVCCameraImageProcessingControl
::
parameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
{
return
m_session
->
imageProcessingParameter
(
parameter
);
}
void
UVCCameraImageProcessingControl
::
setParameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
)
{
m_session
->
setImageProcessingParameter
(
parameter
,
value
);
}
QT_END_NAMESPACE
uvcengine/uvccameraimageprocessingcontrol.h
0 → 100644
View file @
98ac2765
#ifndef UVCCAMERAIMAGEPROCESSINGCONTROL_H
#define UVCCAMERAIMAGEPROCESSINGCONTROL_H
#include <qcamera.h>
#include <qcameraimageprocessingcontrol.h>
QT_BEGIN_NAMESPACE
class
UVCCameraSession
;
class
UVCCameraImageProcessingControl
:
public
QCameraImageProcessingControl
{
Q_OBJECT
public:
UVCCameraImageProcessingControl
(
UVCCameraSession
*
session
);
virtual
~
UVCCameraImageProcessingControl
();
bool
isParameterSupported
(
ProcessingParameter
)
const
;
bool
isParameterValueSupported
(
ProcessingParameter
parameter
,
const
QVariant
&
value
)
const
;
QVariant
parameter
(
ProcessingParameter
parameter
)
const
;
void
setParameter
(
ProcessingParameter
parameter
,
const
QVariant
&
value
);
private:
UVCCameraSession
*
m_session
;
};
QT_END_NAMESPACE
#endif // UVCCAMERAIMAGEPROCESSINGCONTROL_H
uvcengine/uvccameraservice.cpp
View file @
98ac2765
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtCore/qvariant.h>
#include <QtCore/qdebug.h>
...
...
@@ -46,6 +7,7 @@
#include "uvcvideodevicecontrol.h"
#include "uvcvideorenderercontrol.h"
#include "uvccameraviewfindersettingscontrol.h"
#include "uvccameraimageprocessingcontrol.h"
QT_BEGIN_NAMESPACE
...
...
@@ -56,7 +18,8 @@ UVCCameraService::UVCCameraService(QObject *parent):
m_session
=
new
UVCCameraSession
(
this
);
m_control
=
new
UVCCameraControl
(
m_session
);
m_videoDevice
=
new
UVCVideoDeviceControl
(
m_session
);
m_viewfinderSettings
=
new
UVCCameraViewfinderSettingsControl
(
m_session
);
m_viewfinderSettings
=
new
UVCCameraViewfinderSettingsControl
(
m_session
);
m_imageProcessingControl
=
new
UVCCameraImageProcessingControl
(
m_session
);
}
UVCCameraService
::~
UVCCameraService
()
...
...
@@ -86,9 +49,9 @@ QMediaControl* UVCCameraService::requestControl(const char *name)
if
(
qstrcmp
(
name
,
QCameraViewfinderSettingsControl2_iid
)
==
0
)
return
m_viewfinderSettings
;
//
if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0)
//
return m_imageProcessingControl;
//
if
(
qstrcmp
(
name
,
QCameraImageProcessingControl_iid
)
==
0
)
return
m_imageProcessingControl
;
return
NULL
;
}
...
...
uvcengine/uvccameraservice.h
View file @
98ac2765
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef DSCAMERASERVICE_H
#define DSCAMERASERVICE_H
#ifndef UVCCAMERASERVICE_H
#define UVCCAMERASERVICE_H
#include <QtCore/qobject.h>
#include <QtMultimedia/QMediaService>
...
...
@@ -50,6 +11,7 @@ class UVCCameraSession;
class
UVCVideoDeviceControl
;
class
UVCVideoRendererControl
;
class
UVCCameraViewfinderSettingsControl
;
class
UVCCameraImageProcessingControl
;
class
UVCCameraService
:
public
QMediaService
{
...
...
@@ -66,7 +28,8 @@ private:
UVCCameraSession
*
m_session
;
UVCVideoDeviceControl
*
m_videoDevice
;
UVCVideoRendererControl
*
m_videoRenderer
;
UVCCameraViewfinderSettingsControl
*
m_viewfinderSettings
;
UVCCameraViewfinderSettingsControl
*
m_viewfinderSettings
;
UVCCameraImageProcessingControl
*
m_imageProcessingControl
;
};
QT_END_NAMESPACE
...
...
uvcengine/uvccamerasession.cpp
View file @
98ac2765
...
...
@@ -170,6 +170,12 @@ bool UVCCameraSession::load()
}
*/
QSettings
*
settings
;
QFileInfo
uvcSettingsFile
(
QString
(
"%1/cfg/uvc/%2.ini"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
deviceName
)
);
bool
hasSettings
=
uvcSettingsFile
.
exists
();
settings
=
new
QSettings
(
uvcSettingsFile
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
uint8_t
focus_auto
;
uint8_t
ae_priority
;
uint8_t
ae_mode
;
...
...
@@ -185,11 +191,6 @@ bool UVCCameraSession::load()
uint32_t
exposure_abs
;
QSettings
*
settings
;
QFileInfo
uvcSettingsFile
(
QString
(
"%1/cfg/uvc/%2.ini"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
deviceName
)
);
bool
hasSettings
=
uvcSettingsFile
.
exists
();
settings
=
new
QSettings
(
uvcSettingsFile
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
// If we didn't have settings, create with default values; otherwise read and set
if
(
!
hasSettings
)
{
qDebug
()
<<
uvcSettingsFile
.
absoluteFilePath
()
<<
"not found. Generating..."
;
...
...
@@ -417,7 +418,8 @@ void UVCCameraSession::updateSourceCapabilities()
}
formatDesc
=
formatDesc
->
next
;
}
}
}
bool
UVCCameraSession
::
stopPreview
()
...
...
@@ -454,30 +456,6 @@ void UVCCameraSession::setViewfinderSettings(const QCameraViewfinderSettings &se
interval
=
1
/
settings
.
maximumFrameRate
();
}
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
;
}
bool
UVCCameraSession
::
acquire
(
const
QString
&
device
)
{
QMutexLocker
locker
(
&
devicesMutex
);
...
...
@@ -493,3 +471,60 @@ void UVCCameraSession::release(const QString &device)
if
(
devices
.
contains
(
device
))
devices
.
remove
(
device
);
}
bool
UVCCameraSession
::
isImageProcessingParameterSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
{
// TODO
return
false
;
}
bool
UVCCameraSession
::
isImageProcessingParameterValueSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
)
const
{
// TODO
return
false
;
}
QVariant
UVCCameraSession
::
imageProcessingParameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
{
//qDebug() << parameter;
switch
(
parameter
)
{
case
QCameraImageProcessingControl
::
BrightnessAdjustment
:
return
uvc_get
(
devh
,
uvc_get_brightness
);
case
QCameraImageProcessingControl
::
ContrastAdjustment
:
return
uvc_get
(
devh
,
uvc_get_contrast
);
case
QCameraImageProcessingControl
::
ColorTemperature
:
return
uvc_get
(
devh
,
uvc_get_white_balance_temperature
);
case
QCameraImageProcessingControl
::
SaturationAdjustment
:
return
uvc_get
(
devh
,
uvc_get_saturation
);
case
QCameraImageProcessingControl
::
SharpeningAdjustment
:
return
uvc_get
(
devh
,
uvc_get_sharpness
);
default:
qWarning
()
<<
parameter
<<
"not supported"
;
return
QVariant
();
}
}
void
UVCCameraSession
::
setImageProcessingParameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
)
{
//qDebug() << parameter;
switch
(
parameter
)
{
case
QCameraImageProcessingControl
::
BrightnessAdjustment
:
uvc_set
(
devh
,
uvc_set_brightness
,
value
,
uvc_get_brightness
);
break
;
case
QCameraImageProcessingControl
::
ContrastAdjustment
:
uvc_set
(
devh
,
uvc_set_contrast
,
value
,
uvc_get_contrast
);
break
;
case
QCameraImageProcessingControl
::
ColorTemperature
:
uvc_set
(
devh
,
uvc_set_white_balance_temperature
,
value
,
uvc_get_white_balance_temperature
);
break
;
case
QCameraImageProcessingControl
::
SaturationAdjustment
:
uvc_set
(
devh
,
uvc_set_saturation
,
value
,
uvc_get_saturation
);
break
;
case
QCameraImageProcessingControl
::
SharpeningAdjustment
:
uvc_set
(
devh
,
uvc_set_sharpness
,
value
,
uvc_get_sharpness
);
break
;
default:
qWarning
()
<<
parameter
<<
"not supported"
;
}
return
;
}
uvcengine/uvccamerasession.h
View file @
98ac2765
...
...
@@ -13,6 +13,7 @@
#include <QtMultimedia/qvideosurfaceformat.h>
#include <QtMultimedia/qcameraimageprocessingcontrol.h>
#include <QtMultimedia/qabstractvideobuffer.h>
#include <QtMultimedia/qcameraexposurecontrol.h>
#include <QElapsedTimer>
...
...
@@ -54,6 +55,40 @@ public:
QMutex
getFrameMutex
;
double
interval
;
// Image Processing
template
<
typename
T
>
QVariant
uvc_get
(
uvc_device_handle_t
*
devh
,
uvc_error_t
(
*
get
)(
uvc_device_handle_t
*
,
T
*
,
enum
uvc_req_code
)
)
const
{
T
mn
,
val
,
mx
;
get
(
devh
,
&
mn
,
UVC_GET_MIN
);
get
(
devh
,
&
val
,
UVC_GET_CUR
);
get
(
devh
,
&
mx
,
UVC_GET_MAX
);
//qDebug() << mn << val << mx;
return
(
val
-
mn
)
/
(
double
)
(
mx
-
mn
)
;
}
template
<
typename
T
>
void
uvc_set
(
uvc_device_handle_t
*
devh
,
uvc_error_t
(
*
set
)(
uvc_device_handle_t
*
,
T
),
QVariant
val
,
uvc_error_t
(
*
get
)(
uvc_device_handle_t
*
,
T
*
,
enum
uvc_req_code
)
)
{
T
mn
,
mx
;
get
(
devh
,
&
mn
,
UVC_GET_MIN
);
get
(
devh
,
&
mx
,
UVC_GET_MAX
);
double
value
=
val
.
toDouble
();
value
=
value
*
(
mx
-
mn
)
+
mn
;
//qDebug() << val;
set
(
devh
,
static_cast
<
T
>
(
value
));
}
bool
isImageProcessingParameterSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
;
bool
isImageProcessingParameterValueSupported
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
)
const
;
QVariant
imageProcessingParameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
)
const
;
void
setImageProcessingParameter
(
QCameraImageProcessingControl
::
ProcessingParameter
parameter
,
const
QVariant
&
value
);
private
Q_SLOTS
:
void
presentFrame
(
QVideoFrame
frame
,
const
qreal
t
);
...
...
@@ -79,20 +114,16 @@ private:
// capabilities
QList
<
QCameraViewfinderSettings
>
m_supportedViewfinderSettings
;
void
updateSourceCapabilities
();
QCameraViewfinderSettings
settings
;
QCameraViewfinderSettings
settings
;
bool
qPixelFormat2UVCFrameFormat
(
const
QVideoFrame
::
PixelFormat
&
qFormat
,
uvc_frame_format
&
uvcFormat
);
static
QMutex
sessionMutex
;
bool
isPupilFieldCamera
();
bool
isPupilEyeCamera
();
// device availability
static
QMap
<
QString
,
bool
>
UVCCameraSession
::
devices
;
static
QMutex
UVCCameraSession
::
devicesMutex
;
bool
acquire
(
const
QString
&
device
);
void
release
(
const
QString
&
device
);
};
QT_END_NAMESPACE
...
...
uvcengine/uvcengine.pro
View file @
98ac2765
...
...
@@ -20,7 +20,8 @@ SOURCES += uvcserviceplugin.cpp \
uvccameracontrol
.
cpp
\
uvccamerasession
.
cpp
\
uvcvideorenderercontrol
.
cpp
\
uvccameraviewfindersettingscontrol
.
cpp
uvccameraviewfindersettingscontrol
.
cpp
\
uvccameraimageprocessingcontrol
.
cpp
HEADERS
+=
uvcserviceplugin
.
h
\
uvccameraservice
.
h
\
...
...
@@ -28,7 +29,8 @@ HEADERS += uvcserviceplugin.h \
uvccameracontrol
.
h
\
uvccamerasession
.
h
\
uvcvideorenderercontrol
.
h
\
uvccameraviewfindersettingscontrol
.
h
uvccameraviewfindersettingscontrol
.
h
\
uvccameraimageprocessingcontrol
.
h
DISTFILES
+=
uvcengine
.
json
unix
{
...
...
@@ -47,11 +49,11 @@ win32:{
# LIBUSB-1.0
INCLUDEPATH += "$${LIBUSBPATH}/libusb/"
contains(QMAKE_HOST.arch, x86_64) {
Release:LIBS += "-L$${LIBUSBPATH}/x64/Release/dll"
Debug:LIBS += "-L$${LIBUSBPATH}/x64/Debug/dll"
Release:LIBS += "-L$${LIBUSBPATH}/x64/Release/dll"
Debug:LIBS += "-L$${LIBUSBPATH}/x64/Debug/dll"
} else {
Release:LIBS += "-L$${LIBUSBPATH}/x86/Release/dll"
Debug:LIBS += "-L$${LIBUSBPATH}/x86/Debug/dll"
Release:LIBS += "-L$${LIBUSBPATH}/x86/Release/dll"
Debug:LIBS += "-L$${LIBUSBPATH}/x86/Debug/dll"
}
LIBS += -llibusb-1.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment