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
cd6ca352
Commit
cd6ca352
authored
Oct 19, 2017
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds rectified undistortion
parent
e1518c6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
EyeRecToo/src/CameraCalibration.cpp
EyeRecToo/src/CameraCalibration.cpp
+12
-4
EyeRecToo/src/CameraCalibration.h
EyeRecToo/src/CameraCalibration.h
+4
-4
EyeRecToo/src/FieldImageProcessor.cpp
EyeRecToo/src/FieldImageProcessor.cpp
+5
-5
No files found.
EyeRecToo/src/CameraCalibration.cpp
View file @
cd6ca352
...
...
@@ -124,9 +124,9 @@ void CameraCalibration::undistortSample(const Mat &frame)
return
;
Mat
tmp
;
if
(
fishEyeCB
->
isChecked
())
cv
::
fisheye
::
undistortImage
(
frame
,
tmp
,
newC
ameraMatrix
,
distCoeffs
);
fisheye
::
undistortImage
(
frame
,
tmp
,
c
ameraMatrix
,
distCoeffs
);
else
cv
::
undistort
(
frame
,
tmp
,
newCameraMatrix
,
distCoeffs
);
remap
(
frame
,
tmp
,
map1
,
map2
,
CV_INTER_AREA
);
imshow
(
"Undistorted Image"
,
tmp
);
this
->
activateWindow
();
this
->
setFocus
();
...
...
@@ -222,11 +222,15 @@ void CameraCalibration::calibrate()
Mat
rv
,
tv
;
if
(
fishEyeCB
->
isChecked
())
{
rms
=
fisheye
::
calibrate
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
,
0
);
fisheye
::
estimateNewCameraMatrixForUndistortRectify
(
cameraMatrix
,
distCoeffs
,
imageSize
,
Matx33d
::
eye
(),
newCameraMatrix
,
1
);
rms
=
fisheye
::
calibrate
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
);
fisheye
::
estimateNewCameraMatrixForUndistortRectify
(
cameraMatrix
,
distCoeffs
,
imageSize
,
Matx33d
::
eye
(),
newCameraMatrix
,
1
,
imageSize
);
}
else
{
rms
=
calibrateCamera
(
objectPoints
,
imagePoints
,
imageSize
,
cameraMatrix
,
distCoeffs
,
rv
,
tv
);
newCameraMatrix
=
getOptimalNewCameraMatrix
(
cameraMatrix
,
distCoeffs
,
imageSize
,
1
,
imageSize
);
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Mat
(),
newCameraMatrix
,
imageSize
,
CV_32FC1
,
map1
,
map2
);
}
calibrationSuccessful
=
true
;
}
...
...
@@ -258,6 +262,10 @@ void CameraCalibration::load(const QString &fileName)
fs
[
"coverage"
]
>>
coverage
;
fs
[
"rms"
]
>>
rms
;
calibrationSuccessful
=
true
;
initUndistortRectifyMap
(
cameraMatrix
,
distCoeffs
,
Mat
(),
newCameraMatrix
,
imageSize
,
CV_32FC1
,
map1
,
map2
);
}
updateCalibrationStatus
(
calibrationSuccessful
);
}
EyeRecToo/src/CameraCalibration.h
View file @
cd6ca352
...
...
@@ -132,8 +132,11 @@ public:
cv
::
Mat
cameraMatrix
;
cv
::
Mat
newCameraMatrix
;
cv
::
Mat
distCoeffs
;
cv
::
Size
imageSize
;
cv
::
Rect
covered
;
int
sampleCount
;
double
coverage
;
double
rms
;
bool
calibrationSuccessful
;
signals:
...
...
@@ -172,8 +175,7 @@ private:
QFutureWatcher
<
void
>
watcher
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
imagePoints
;
cv
::
Size
imageSize
;
cv
::
Rect
covered
;
cv
::
Mat
map1
,
map2
;
void
processSample
(
const
cv
::
Mat
&
frame
);
void
undistortSample
(
const
cv
::
Mat
&
frame
);
...
...
@@ -207,8 +209,6 @@ private:
}
}
double
rms
;
private
slots
:
void
startCalibration
();
void
finishCalibration
();
...
...
EyeRecToo/src/FieldImageProcessor.cpp
View file @
cd6ca352
...
...
@@ -104,7 +104,7 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
Mat
emptyDistCoeffs
=
(
Mat_
<
double
>
(
1
,
4
)
<<
0
,
0
,
0
,
0
);
estimatePoseSingleMarkers
(
corners
,
cfg
.
collectionMarkerSizeMeters
,
emptyCameraMatrix
,
emptyDistCoeffs
,
rvecs
,
tvecs
);
}
else
estimatePoseSingleMarkers
(
corners
,
cfg
.
collectionMarkerSizeMeters
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
estimatePoseSingleMarkers
(
corners
,
cfg
.
collectionMarkerSizeMeters
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
}
for
(
unsigned
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
{
...
...
@@ -167,9 +167,9 @@ void FieldImageProcessor::sanitizeCameraParameters(Size size)
FileStorage
fs
(
QString
(
gCfgDir
+
"/"
+
id
+
"Calibration.xml"
).
toStdString
(),
FileStorage
::
READ
);
fs
[
"cameraMatrix"
]
>>
cameraMatrix
;
fs
[
"distCoeffs"
]
>>
distCoeffs
;
fs
[
"imageSize"
]
>>
imageSize
;
bool
haveCameraParameters
=
false
;
fs
[
"distCoeffs"
]
>>
distCoeffs
;
fs
[
"imageSize"
]
>>
imageSize
;
bool
haveCameraParameters
=
false
;
if
(
!
cameraMatrix
.
empty
()
&&
!
distCoeffs
.
empty
())
haveCameraParameters
=
true
;
...
...
@@ -200,7 +200,7 @@ void FieldImageProcessor::sanitizeCameraParameters(Size size)
cameraMatrix
,
distCoeffs
,
Mat
(),
getOptimalNewCameraMatrix
(
cameraMatrix
,
distCoeffs
,
imageSize
,
0
,
imageSize
),
getOptimalNewCameraMatrix
(
cameraMatrix
,
distCoeffs
,
imageSize
,
1
,
imageSize
),
imageSize
,
CV_32FC1
,
map1
,
...
...
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