Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thiago Santini
EyeRecToo
Commits
22897a30
Commit
22897a30
authored
Mar 15, 2018
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds parameters UI
parent
cddf1351
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
33 deletions
+114
-33
EyeRecToo/src/Camera.cpp
EyeRecToo/src/Camera.cpp
+54
-8
EyeRecToo/src/Camera.h
EyeRecToo/src/Camera.h
+60
-7
EyeRecToo/src/FieldImageProcessor.cpp
EyeRecToo/src/FieldImageProcessor.cpp
+0
-18
No files found.
EyeRecToo/src/Camera.cpp
View file @
22897a30
#include "Camera.h"
#include <QFileInfo>
static
int
gQCameraInfoMetaTypeId
=
qRegisterMetaType
<
QCameraInfo
>
(
"QCameraInfo"
);
static
int
gMatMetaTypeId
=
qRegisterMetaType
<
cv
::
Mat
>
(
"cv::Mat"
);
...
...
@@ -187,6 +188,8 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
retriesLeft
=
maxRetries
;
}
loadUserCameraParameters
();
setValuesUI
();
saveCfg
();
qInfo
()
<<
id
<<
msg
;
QMetaObject
::
invokeMethod
(
ui
,
"updateSettings"
,
Q_ARG
(
QList
<
QCameraViewfinderSettings
>
,
settingsList
),
Q_ARG
(
QCameraViewfinderSettings
,
currentViewfinderSettings
)
);
...
...
@@ -201,31 +204,31 @@ void Camera::setColorCode(int code)
void
Camera
::
setParameter
(
QString
what
,
float
value
)
{
//qDebug() << what << value;
if
(
!
camera
)
return
;
QCameraImageProcessing
*
ip
=
camera
->
imageProcessing
();
QCameraExposure
*
exp
=
camera
->
exposure
();
QString
parameter
=
what
.
toLower
();
qDebug
()
<<
what
<<
value
;
QString
parameter
=
what
;
if
(
ip
->
isAvailable
()
)
{
if
(
parameter
==
"brightness"
)
ip
->
setBrightness
(
value
);
if
(
parameter
==
"contrast"
)
ip
->
setContrast
(
value
);
if
(
parameter
==
"white
balance"
)
if
(
parameter
==
"white
_
balance"
)
ip
->
setManualWhiteBalance
(
value
);
if
(
parameter
==
"saturation"
)
ip
->
setSaturation
(
value
);
if
(
parameter
==
"sharpening
level"
)
if
(
parameter
==
"sharpening
_
level"
)
ip
->
setSharpeningLevel
(
value
);
}
if
(
exp
->
isAvailable
()
)
{
if
(
parameter
==
"exposure mode"
)
{
if
(
parameter
==
"exposure_time"
)
exp
->
setManualAperture
(
value
);
if
(
parameter
==
"exposure_mode"
)
{
switch
(
(
int
)
value
)
{
case
1
:
exp
->
setExposureMode
(
QCameraExposure
::
ExposureManual
);
...
...
@@ -235,10 +238,38 @@ void Camera::setParameter(QString what, float value)
break
;
}
}
if
(
parameter
==
"exposure time"
)
exp
->
setManualAperture
(
value
);
}
saveCameraParameter
(
parameter
,
value
);
}
void
Camera
::
setValuesUI
()
{
if
(
!
camera
)
return
;
QCameraImageProcessing
*
ip
=
camera
->
imageProcessing
();
QCameraExposure
*
exp
=
camera
->
exposure
();
if
(
ip
->
isAvailable
()
)
{
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"brightness"
),
ip
->
brightness
()
);
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"contrast"
),
ip
->
contrast
()
);
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"white_balance"
),
ip
->
manualWhiteBalance
()
);
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"saturation"
),
ip
->
saturation
()
);
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"sharpening_level"
),
ip
->
sharpeningLevel
()
);
}
if
(
exp
->
isAvailable
()
)
{
ui
->
setValue
(
ui
->
findChild
<
QDoubleSpinBox
*>
(
"exposure_time"
),
exp
->
aperture
()
);
switch
(
(
int
)
exp
->
exposureMode
()
)
{
case
QCameraExposure
::
ExposureManual
:
ui
->
setValue
(
ui
->
findChild
<
QComboBox
*>
(
"exposure_mode"
),
1
);
break
;
case
QCameraExposure
::
ExposureAuto
:
ui
->
setValue
(
ui
->
findChild
<
QComboBox
*>
(
"exposure_mode"
),
2
);
break
;
}
}
}
void
Camera
::
showOptions
()
...
...
@@ -363,3 +394,18 @@ void Camera::searchDefaultCamera()
}
}
void
Camera
::
loadUserCameraParameters
()
{
QFileInfo
cameraSettingsFile
(
makeSettingsFileName
()
);
if
(
!
cameraSettingsFile
.
exists
()
)
return
;
QSettings
settings
(
cameraSettingsFile
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
loadAndSet
(
settings
,
"brightness"
);
loadAndSet
(
settings
,
"contrast"
);
loadAndSet
(
settings
,
"white_balance"
);
loadAndSet
(
settings
,
"saturation"
);
loadAndSet
(
settings
,
"sharpening_level"
);
loadAndSet
(
settings
,
"exposure_time"
);
loadAndSet
(
settings
,
"exposure_mode"
);
}
EyeRecToo/src/Camera.h
View file @
22897a30
...
...
@@ -15,6 +15,7 @@
#include <QRegularExpression>
#include <QFormLayout>
#include <QDoubleSpinBox>
#include <QFileInfo>
#include "opencv/cv.h"
...
...
@@ -100,7 +101,29 @@ public:
this
,
SLOT
(
settingsChanged
(
int
))
);
connect
(
colorBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
colorChanged
(
int
))
);
}
}
void
setValue
(
QDoubleSpinBox
*
sb
,
double
val
)
{
if
(
!
sb
)
return
;
sb
->
blockSignals
(
true
);
sb
->
setValue
(
100
*
val
);
sb
->
blockSignals
(
false
);
}
void
setValue
(
QSlider
*
s
,
double
val
)
{
if
(
!
s
)
return
;
s
->
blockSignals
(
true
);
s
->
setValue
(
100
*
val
);
s
->
blockSignals
(
false
);
}
void
setValue
(
QComboBox
*
cb
,
QVariant
val
)
{
if
(
!
cb
)
return
;
cb
->
blockSignals
(
true
);
cb
->
setCurrentIndex
(
cb
->
findData
(
val
));
cb
->
blockSignals
(
false
);
}
public
slots
:
void
update
(
QCameraInfo
current
,
int
colorCode
)
...
...
@@ -178,14 +201,13 @@ 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
);
slider
->
setObjectName
(
label
.
toLower
().
replace
(
" "
,
"_"
)
);
formLayout
->
addRow
(
new
QLabel
(
label
),
slider
);
connect
(
slider
,
SIGNAL
(
sliderReleased
()),
this
,
SLOT
(
sliderReleased
())
);
}
...
...
@@ -196,7 +218,7 @@ private:
sb
->
setMaximum
(
100
);
sb
->
setSingleStep
(
0.5
);
sb
->
setDecimals
(
1
);
sb
->
setObjectName
(
label
);
sb
->
setObjectName
(
label
.
toLower
().
replace
(
" "
,
"_"
)
);
sb
->
setSuffix
(
"%"
);
formLayout
->
addRow
(
new
QLabel
(
label
),
sb
);
connect
(
sb
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
spinBoxChanged
(
double
))
);
...
...
@@ -204,7 +226,7 @@ private:
QComboBox
*
addComboBox
(
QFormLayout
*
formLayout
,
QString
label
)
{
QComboBox
*
box
=
new
QComboBox
();
box
->
setObjectName
(
label
);
box
->
setObjectName
(
label
.
toLower
().
replace
(
" "
,
"_"
)
);
formLayout
->
addRow
(
new
QLabel
(
label
),
box
);
connect
(
box
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
comboBoxChanged
())
);
return
box
;
...
...
@@ -234,11 +256,12 @@ public slots:
void
setCamera
(
const
QCameraInfo
&
cameraInfo
,
QCameraViewfinderSettings
settings
);
void
setColorCode
(
int
code
);
void
setParameter
(
QString
what
,
float
value
);
void
showOptions
();
void
setValuesUI
();
void
showOptions
();
void
saveCfg
();
void
loadCfg
();
void
timedout
();
void
retry
();
void
retry
();
private:
QString
id
;
...
...
@@ -256,6 +279,36 @@ private:
static
QMutex
setCameraMutex
;
void
searchDefaultCamera
();
QString
makeSettingsFileName
()
{
return
QString
(
"%1/cfg/camera-parameters/%2.ini"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
currentCameraInfo
.
deviceName
());
}
bool
loadCameraParameter
(
const
QSettings
&
settings
,
const
QString
&
parameter
,
double
&
value
)
{
if
(
!
settings
.
contains
(
parameter
)
)
return
false
;
value
=
settings
.
value
(
parameter
).
toDouble
();
return
true
;
}
bool
loadCameraParameter
(
const
QString
&
parameter
,
double
&
value
)
{
QFileInfo
cameraSettingsFile
(
makeSettingsFileName
()
);
if
(
!
cameraSettingsFile
.
exists
()
)
return
false
;
QSettings
settings
(
cameraSettingsFile
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
return
loadCameraParameter
(
settings
,
parameter
,
value
);
}
void
saveCameraParameter
(
const
QString
&
parameter
,
const
double
&
value
)
{
QFileInfo
cameraSettingsFile
(
makeSettingsFileName
()
);
QSettings
s
(
cameraSettingsFile
.
absoluteFilePath
(),
QSettings
::
IniFormat
);
s
.
setValue
(
parameter
,
value
);
}
void
loadAndSet
(
const
QSettings
&
settings
,
QString
key
)
{
double
value
;
if
(
loadCameraParameter
(
settings
,
key
,
value
)
)
setParameter
(
key
,
value
);
}
void
loadUserCameraParameters
();
private
slots
:
void
reset
();
};
...
...
EyeRecToo/src/FieldImageProcessor.cpp
View file @
22897a30
...
...
@@ -7,9 +7,6 @@ using namespace aruco;
static
int
gFieldDataId
=
qRegisterMetaType
<
FieldData
>
(
"FieldData"
);
static
int
markerDetectionCounter
=
0
;
static
int
redetectMarkerCounter
=
1
;
FieldImageProcessor
::
FieldImageProcessor
(
QString
id
,
QObject
*
parent
)
:
id
(
id
),
sROI
(
QPointF
(
0
,
0
)),
...
...
@@ -94,20 +91,6 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
}
if
(
cfg
.
markerDetectionMethod
==
"aruco"
||
gCalibrating
)
{
#define LIMIT_MARKER_DETECTION
#ifdef LIMIT_MARKER_DETECTION
if
(
markerDetectionCounter
==
redetectMarkerCounter
)
{
detectMarkers
(
downscaled
,
dict
,
corners
,
ids
,
detectorParameters
);
if
(
cfg
.
processingDownscalingFactor
>
1
)
{
// Upscale if necessary
for
(
unsigned
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
corners
[
i
].
size
();
j
++
)
corners
[
i
][
j
]
=
cfg
.
processingDownscalingFactor
*
corners
[
i
][
j
];
}
markerDetectionCounter
=
0
;
}
else
markerDetectionCounter
++
;
#else
detectMarkers
(
downscaled
,
dict
,
corners
,
ids
,
detectorParameters
);
if
(
cfg
.
processingDownscalingFactor
>
1
)
{
// Upscale if necessary
...
...
@@ -115,7 +98,6 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
for
(
unsigned
int
j
=
0
;
j
<
corners
[
i
].
size
();
j
++
)
corners
[
i
][
j
]
=
cfg
.
processingDownscalingFactor
*
corners
[
i
][
j
];
}
#endif
}
// Filling the marker data
...
...
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