Commit 5e6d0a7c authored by Thiago Santini's avatar Thiago Santini

Adds parametetrization and default values

parent 96f94e6b
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <vector> #include <vector>
#include <atomic> #include <atomic>
#include <map>
#include "libuvc/libuvc.h" #include "libuvc/libuvc.h"
...@@ -27,6 +28,27 @@ QT_BEGIN_NAMESPACE ...@@ -27,6 +28,27 @@ QT_BEGIN_NAMESPACE
// Maximum acceptable latency for calling the surface present method // Maximum acceptable latency for calling the surface present method
#define MAX_LATENCY_MS 1.0e3/25 #define MAX_LATENCY_MS 1.0e3/25
struct DefaultParameters {
double bandwidthFactor;
double brightness;
double contrast;
double saturation;
double white_balance;
double sharpness;
double backlight_compensation;
double gamma;
double gain;
double exposure_abs;
double hue;
int ae_mode;
int ae_priority;
int contrast_auto;
int focus_auto;
int white_balance_component_auto;
int white_balance_temperature_auto;
int hue_auto;
};
class UVCCameraSession : public QObject class UVCCameraSession : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -56,6 +78,8 @@ public: ...@@ -56,6 +78,8 @@ public:
double interval; double interval;
// Image Processing // Image Processing
// TODO: we don't check if the camera supports the parameters since some
// cameras underreport their capabilities; is this safe?
template<typename T> template<typename T>
QVariant uvc_get( uvc_device_handle_t *devh, QVariant uvc_get( uvc_device_handle_t *devh,
uvc_error_t (*get)( uvc_device_handle_t *, T *, enum uvc_req_code) uvc_error_t (*get)( uvc_device_handle_t *, T *, enum uvc_req_code)
...@@ -64,10 +88,17 @@ public: ...@@ -64,10 +88,17 @@ public:
get(devh, &mn, UVC_GET_MIN); get(devh, &mn, UVC_GET_MIN);
get(devh, &val, UVC_GET_CUR); get(devh, &val, UVC_GET_CUR);
get(devh, &mx, UVC_GET_MAX); get(devh, &mx, UVC_GET_MAX);
//qDebug() << mn << val << mx;
return (val - mn) / (double) (mx - mn) ; return (val - mn) / (double) (mx - mn) ;
} }
template<typename T> template<typename T>
QVariant uvc_get_mode( uvc_device_handle_t *devh,
uvc_error_t (*get)( uvc_device_handle_t *, T *, enum uvc_req_code)
) const {
T val;
get(devh, &val, UVC_GET_CUR);
return val;
}
template<typename T>
void uvc_set( uvc_device_handle_t *devh, void uvc_set( uvc_device_handle_t *devh,
uvc_error_t (*set)( uvc_device_handle_t *, T), uvc_error_t (*set)( uvc_device_handle_t *, T),
QVariant val, QVariant val,
...@@ -78,9 +109,15 @@ public: ...@@ -78,9 +109,15 @@ public:
get(devh, &mx, UVC_GET_MAX); get(devh, &mx, UVC_GET_MAX);
double value = val.toDouble(); double value = val.toDouble();
value = value * (mx - mn ) + mn; value = value * (mx - mn ) + mn;
//qDebug() << val;
set(devh, static_cast<T>(value)); set(devh, static_cast<T>(value));
} }
template<typename T>
void uvc_set_mode( uvc_device_handle_t *devh,
uvc_error_t (*set)( uvc_device_handle_t *, T),
QVariant val
) {
set(devh, static_cast<T>(val.toInt()));
}
// Image Processing // Image Processing
bool isImageProcessingParameterSupported(QCameraImageProcessingControl::ProcessingParameter parameter) const; bool isImageProcessingParameterSupported(QCameraImageProcessingControl::ProcessingParameter parameter) const;
...@@ -101,7 +138,7 @@ private Q_SLOTS: ...@@ -101,7 +138,7 @@ private Q_SLOTS:
void presentFrame(QVideoFrame frame, const qreal t); void presentFrame(QVideoFrame frame, const qreal t);
private: private:
float bandwidthFactor; double bandwidthFactor;
QCamera::Status m_status; QCamera::Status m_status;
QAbstractVideoSurface *m_surface; QAbstractVideoSurface *m_surface;
QMutex surfaceMutex; QMutex surfaceMutex;
...@@ -132,6 +169,9 @@ private: ...@@ -132,6 +169,9 @@ private:
static QMutex UVCCameraSession::devicesMutex; static QMutex UVCCameraSession::devicesMutex;
bool acquire(const QString &device); bool acquire(const QString &device);
void release(const QString &device); void release(const QString &device);
std::map<QString,DefaultParameters> defaults;
void setDefaultParameters();
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
......
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