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
f4b4ff45
Commit
f4b4ff45
authored
Nov 21, 2017
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small improvement to camera calibration
parent
4314e5a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
20 deletions
+26
-20
EyeRecToo/src/CameraCalibration.cpp
EyeRecToo/src/CameraCalibration.cpp
+24
-19
EyeRecToo/src/CameraWidget.cpp
EyeRecToo/src/CameraWidget.cpp
+2
-1
No files found.
EyeRecToo/src/CameraCalibration.cpp
View file @
f4b4ff45
...
...
@@ -220,26 +220,31 @@ void CameraCalibration::calibrate()
calculateBoardCorners
(
objectPoints
[
0
]);
objectPoints
.
resize
(
imagePoints
.
size
(),
objectPoints
[
0
]);
Mat
rv
,
tv
;
if
(
fishEyeCB
->
isChecked
())
{
int
fisheyeFlags
=
0
;
fisheyeFlags
|=
fisheye
::
CALIB_RECOMPUTE_EXTRINSIC
;
fisheyeFlags
|=
fisheye
::
CALIB_CHECK_COND
;
fisheyeFlags
|=
fisheye
::
CALIB_FIX_SKEW
;
rms
=
fisheye
::
calibrate
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
,
fisheyeFlags
);
fisheye
::
estimateNewCameraMatrixForUndistortRectify
(
cameraMatrix
,
distCoeffs
,
imageSize
,
Matx33d
::
eye
(),
newCameraMatrix
,
1
,
imageSize
);
fisheye
::
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Matx33d
::
eye
(),
newCameraMatrix
,
imageSize
,
CV_16SC2
,
map1
,
map2
);
}
else
{
rms
=
calibrateCamera
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
);
newCameraMatrix
=
getOptimalNewCameraMatrix
(
cameraMatrix
,
distCoeffs
,
imageSize
,
1
,
imageSize
);
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Mat
(),
newCameraMatrix
,
imageSize
,
CV_16SC2
,
map1
,
map2
);
try
{
Mat
rv
,
tv
;
if
(
fishEyeCB
->
isChecked
())
{
int
fisheyeFlags
=
0
;
fisheyeFlags
|=
fisheye
::
CALIB_RECOMPUTE_EXTRINSIC
;
fisheyeFlags
|=
fisheye
::
CALIB_CHECK_COND
;
fisheyeFlags
|=
fisheye
::
CALIB_FIX_SKEW
;
rms
=
fisheye
::
calibrate
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
,
fisheyeFlags
);
fisheye
::
estimateNewCameraMatrixForUndistortRectify
(
cameraMatrix
,
distCoeffs
,
imageSize
,
Matx33d
::
eye
(),
newCameraMatrix
,
1
,
imageSize
);
fisheye
::
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Matx33d
::
eye
(),
newCameraMatrix
,
imageSize
,
CV_16SC2
,
map1
,
map2
);
}
else
{
rms
=
calibrateCamera
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
);
newCameraMatrix
=
getOptimalNewCameraMatrix
(
cameraMatrix
,
distCoeffs
,
imageSize
,
1
,
imageSize
);
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Mat
(),
newCameraMatrix
,
imageSize
,
CV_16SC2
,
map1
,
map2
);
}
calibrationSuccessful
=
true
;
}
catch
(
cv
::
Exception
&
e
)
{
qWarning
()
<<
"Calibration failed:"
<<
e
.
what
();
calibrationSuccessful
=
false
;
}
calibrationSuccessful
=
true
;
}
void
CameraCalibration
::
store
(
const
QString
&
fileName
)
...
...
EyeRecToo/src/CameraWidget.cpp
View file @
f4b4ff45
...
...
@@ -471,7 +471,8 @@ void CameraWidget::onCameraCalibrationFinished(bool success)
return
;
// TODO: at some point we might consider storing this with a unique camera ID instead of this generic one
QString
fileName
=
gCfgDir
+
"/"
+
id
+
"Calibration.xml"
;
QMetaObject
::
invokeMethod
(
cameraCalibration
,
"store"
,
Qt
::
QueuedConnection
,
Q_ARG
(
QString
,
fileName
));
// Do the store here with a direct call to guarantee it will be done before the updateConfig
QMetaObject
::
invokeMethod
(
cameraCalibration
,
"store"
,
Qt
::
DirectConnection
,
Q_ARG
(
QString
,
fileName
));
QMetaObject
::
invokeMethod
(
imageProcessor
,
"updateConfig"
,
Qt
::
QueuedConnection
);
}
...
...
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