Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
5beefcfa
Commit
5beefcfa
authored
Aug 13, 2015
by
baisheng lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug of multiCamCalib.cpp
parent
2b28181d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
50 deletions
+58
-50
multiCameraCalibration.hpp
modules/ccalib/include/opencv2/multiCameraCalibration.hpp
+4
-3
multiCamCalib.cpp
modules/ccalib/sample/multiCamCalib.cpp
+1
-1
omniCalibration.cpp
modules/ccalib/sample/omniCalibration.cpp
+2
-2
omniStereoCalibration.cpp
modules/ccalib/sample/omniStereoCalibration.cpp
+18
-15
multiCameraCalibration.cpp
modules/ccalib/src/multiCameraCalibration.cpp
+32
-28
omnidir.cpp
modules/ccalib/src/omnidir.cpp
+1
-1
No files found.
modules/ccalib/include/opencv2/multiCameraCalibration.hpp
View file @
5beefcfa
...
...
@@ -126,6 +126,7 @@ public:
@patternHeight the physical height of pattern, in user defined unit.
@showExtration whether show extracted features and feature filtering.
@nMiniMatches minimal number of matched features for a frame.
@flags Calibration flags
@criteria optimization stopping criteria.
@detector feature detector that detect feature points in pattern and images.
@descriptor feature descriptor.
...
...
@@ -133,9 +134,9 @@ public:
*/
multiCameraCalibration
(
int
cameraType
,
int
nCameras
,
const
std
::
string
&
fileName
,
float
patternWidth
,
float
patternHeight
,
int
showExtration
=
0
,
int
nMiniMatches
=
20
,
int
flags
=
0
,
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
300
,
1e-7
),
Ptr
<
FeatureDetector
>
detector
=
AKAZE
::
create
(
AKAZE
::
DESCRIPTOR_MLDB
,
0
,
3
,
0.00
2
f
),
Ptr
<
DescriptorExtractor
>
descriptor
=
AKAZE
::
create
(
AKAZE
::
DESCRIPTOR_MLDB
,
0
,
3
,
0.00
2
f
),
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
100
,
1e-5
),
Ptr
<
FeatureDetector
>
detector
=
AKAZE
::
create
(
AKAZE
::
DESCRIPTOR_MLDB
,
0
,
3
,
0.00
5
f
),
Ptr
<
DescriptorExtractor
>
descriptor
=
AKAZE
::
create
(
AKAZE
::
DESCRIPTOR_MLDB
,
0
,
3
,
0.00
5
f
),
Ptr
<
DescriptorMatcher
>
matcher
=
DescriptorMatcher
::
create
(
"BruteForce-L1"
));
/* @brief load images
...
...
modules/ccalib/sample/multiCamCalib.cpp
View file @
5beefcfa
...
...
@@ -6,7 +6,7 @@ using namespace std;
using
namespace
cv
;
const
char
*
usage
=
"
\n
example command line for multi-camera calibr
s
ation by using random pattern
\n
"
"
\n
example command line for multi-camera calibration by using random pattern
\n
"
" multiCamCalib -nc 5 -pw 800 -ph 600 -ct 1 -fe 0 -nm 10 multi_camera.xml
\n
"
"
\n
"
" the file multi_camera.xml is generated by imagelist_creator as
\n
"
...
...
modules/ccalib/sample/omniCalibration.cpp
View file @
5beefcfa
#include"opencv2/omnidir.hpp"
#include"opencv2/core/core.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include"opencv2/highgui/highgui.hpp"
#include
"opencv2/highgui/highgui.hpp"
#include <vector>
#include <iostream>
#include <string>
...
...
@@ -247,7 +247,7 @@ int main(int argc, char** argv)
Mat
K
,
D
,
xi
,
idx
;
vector
<
Vec3d
>
rvecs
,
tvecs
;
double
_xi
,
rms
;
TermCriteria
criteria
(
3
,
100
,
1e-4
);
TermCriteria
criteria
(
3
,
200
,
1e-8
);
rms
=
omnidir
::
calibrate
(
objectPoints
,
imagePoints
,
imageSize
,
K
,
xi
,
D
,
rvecs
,
tvecs
,
flags
,
criteria
,
idx
);
_xi
=
xi
.
at
<
double
>
(
0
);
saveCameraParams
(
outputFilename
,
imageSize
,
boardSize
,
square_width
,
square_height
,
flags
,
K
,
D
,
_xi
,
...
...
modules/ccalib/sample/omniStereoCalibration.cpp
View file @
5beefcfa
#include
"opencv2/omnidir.hpp"
#include
"opencv2/core/core.hpp"
#include
"opencv2/imgproc/imgproc.hpp"
#include"opencv2/omnidir.hpp"
#include"opencv2/core/core.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <vector>
#include <iostream>
...
...
@@ -12,7 +12,7 @@ using namespace std;
const
char
*
usage
=
"
\n
example command line for calibrate a pair of omnidirectional camera.
\n
"
" omniStereoCalibration -w
6 -h 7 -sw 80 -sh 80 image_list_1.xml image_list_2
.xml
\n
"
" omniStereoCalibration -w
8 -h 6 -sw 2.4399 -sh 2.4399 imagelist_left.xml imagelist_right
.xml
\n
"
"
\n
"
" the file image_list_1.xml and image_list_2.xml generated by imagelist_creator as
\n
"
"imagelist_creator image_list_1.xml *.*"
;
...
...
@@ -53,7 +53,7 @@ static void calcChessboardCorners(Size boardSize, double square_width, double sq
static
bool
detecChessboardCorners
(
const
vector
<
string
>&
list1
,
vector
<
string
>&
list_detected_1
,
const
vector
<
string
>&
list2
,
vector
<
string
>&
list_detected_2
,
vector
<
Mat
>&
image_points_1
,
vector
<
Mat
>&
image_points_2
,
Size
boardSize
,
Size
&
imageSize
)
vector
<
Mat
>&
image_points_1
,
vector
<
Mat
>&
image_points_2
,
Size
boardSize
,
Size
&
imageSize
1
,
Size
&
imageSize2
)
{
image_points_1
.
resize
(
0
);
image_points_2
.
resize
(
0
);
...
...
@@ -81,7 +81,11 @@ static bool detecChessboardCorners(const vector<string>& list1, vector<string>&
}
}
if
(
!
img_l
.
empty
())
imageSize
=
img_l
.
size
();
imageSize1
=
img_l
.
size
();
if
(
!
img_r
.
empty
())
{
imageSize2
=
img_r
.
size
();
}
if
(
image_points_1
.
size
()
<
3
)
return
false
;
...
...
@@ -104,8 +108,7 @@ static bool readStringList( const string& filename, vector<string>& l )
return
true
;
}
static
void
saveCameraParams
(
const
string
&
filename
,
Size
imageSize
,
Size
boardSize
,
double
square_width
,
double
square_height
,
int
flags
,
const
Mat
&
cameraMatrix1
,
const
Mat
&
cameraMatrix2
,
const
Mat
&
distCoeffs1
,
static
void
saveCameraParams
(
const
string
&
filename
,
const
int
flags
,
const
Mat
&
cameraMatrix1
,
const
Mat
&
cameraMatrix2
,
const
Mat
&
distCoeffs1
,
const
Mat
&
disCoeffs2
,
const
double
xi1
,
const
double
xi2
,
const
Vec3d
rvec
,
const
Vec3d
tvec
,
const
vector
<
Vec3d
>&
rvecs
,
const
vector
<
Vec3d
>&
tvecs
,
vector
<
string
>
detec_list_1
,
vector
<
string
>
detec_list_2
,
const
Mat
&
idx
,
const
double
rms
,
const
vector
<
Mat
>&
imagePoints1
,
const
vector
<
Mat
>&
imagePoints2
)
...
...
@@ -208,7 +211,7 @@ static void saveCameraParams( const string & filename, Size imageSize, Size boar
int
main
(
int
argc
,
char
**
argv
)
{
Size
boardSize
,
imageSize
;
Size
boardSize
,
imageSize
1
,
imageSize2
;
int
flags
=
0
;
double
square_width
,
square_height
;
const
char
*
outputFilename
=
"out_camera_params_stereo.xml"
;
...
...
@@ -283,7 +286,7 @@ int main(int argc, char** argv)
// find corners in images
// some images may be failed in automatic corner detection, passed cases are in detec_list
if
(
!
detecChessboardCorners
(
image_list1
,
detec_list_1
,
image_list2
,
detec_list_2
,
imagePoints1
,
imagePoints2
,
boardSize
,
imageSize
))
imagePoints1
,
imagePoints2
,
boardSize
,
imageSize
1
,
imageSize2
))
return
fprintf
(
stderr
,
"Not enough corner detected images
\n
"
),
-
1
;
// calculate object coordinates
...
...
@@ -300,13 +303,12 @@ int main(int argc, char** argv)
vector
<
Vec3d
>
rvecs
,
tvecs
;
Vec3d
rvec
,
tvec
;
double
_xi1
,
_xi2
,
rms
;
TermCriteria
criteria
(
3
,
100
,
1e-4
);
rms
=
omnidir
::
stereoCalibrate
(
objectPoints
,
imagePoints1
,
imagePoints2
,
imageSize
,
K1
,
xi1
,
D1
,
TermCriteria
criteria
(
3
,
200
,
1e-8
);
rms
=
omnidir
::
stereoCalibrate
(
objectPoints
,
imagePoints1
,
imagePoints2
,
imageSize
1
,
imageSize2
,
K1
,
xi1
,
D1
,
K2
,
xi2
,
D2
,
rvec
,
tvec
,
rvecs
,
tvecs
,
flags
,
criteria
,
idx
);
_xi1
=
xi1
.
at
<
double
>
(
0
);
_xi2
=
xi2
.
at
<
double
>
(
0
);
saveCameraParams
(
outputFilename
,
imageSize
,
boardSize
,
square_width
,
square_height
,
flags
,
K1
,
K2
,
D1
,
D2
,
_xi1
,
_xi2
,
rvec
,
tvec
,
rvecs
,
tvecs
,
detec_list_1
,
detec_list_2
,
idx
,
rms
,
imagePoints1
,
imagePoints2
);
saveCameraParams
(
outputFilename
,
flags
,
K1
,
K2
,
D1
,
D2
,
_xi1
,
_xi2
,
rvec
,
tvec
,
rvecs
,
tvecs
,
detec_list_1
,
detec_list_2
,
idx
,
rms
,
imagePoints1
,
imagePoints2
);
}
\ No newline at end of file
modules/ccalib/src/multiCameraCalibration.cpp
View file @
5beefcfa
...
...
@@ -139,6 +139,7 @@ void multiCameraCalibration::loadImages()
std
::
vector
<
std
::
vector
<
std
::
string
>
>
filesEachCameraFull
(
_nCamera
);
std
::
vector
<
std
::
vector
<
int
>
>
timestampFull
(
_nCamera
);
std
::
vector
<
std
::
vector
<
int
>
>
timestampAvailable
(
_nCamera
);
for
(
int
i
=
1
;
i
<
(
int
)
file_list
.
size
();
++
i
)
{
...
...
@@ -170,8 +171,12 @@ void multiCameraCalibration::loadImages()
{
image
=
imread
(
filesEachCameraFull
[
camera
][
imgIdx
],
IMREAD_GRAYSCALE
);
std
::
vector
<
Mat
>
imgObj
=
finder
.
computeObjectImagePointsForSingle
(
image
);
_imagePointsForEachCamera
[
camera
].
push_back
(
imgObj
[
0
]);
_objectPointsForEachCamera
[
camera
].
push_back
(
imgObj
[
1
]);
if
((
int
)
imgObj
[
0
].
total
()
>
_nMiniMatches
)
{
_imagePointsForEachCamera
[
camera
].
push_back
(
imgObj
[
0
]);
_objectPointsForEachCamera
[
camera
].
push_back
(
imgObj
[
1
]);
timestampAvailable
[
camera
].
push_back
(
timestampFull
[
camera
][
imgIdx
]);
}
}
// calibrate
...
...
@@ -216,33 +221,31 @@ void multiCameraCalibration::loadImages()
for
(
int
i
=
0
;
i
<
(
int
)
_omEachCamera
[
camera
].
size
();
++
i
)
{
if
((
int
)
_objectPointsForEachCamera
[
camera
][
idx
.
at
<
int
>
(
i
)].
total
()
>
_nMiniMatches
)
{
int
cameraVertex
,
timestamp
,
photoVertex
;
cameraVertex
=
camera
;
timestamp
=
timestampFull
[
camera
][
idx
.
at
<
int
>
(
i
)];
photoVertex
=
this
->
getPhotoVertex
(
timestamp
);
if
(
_omEachCamera
[
camera
][
i
].
type
()
!=
CV_32F
)
{
_omEachCamera
[
camera
][
i
].
convertTo
(
_omEachCamera
[
camera
][
i
],
CV_32F
);
}
if
(
_tEachCamera
[
camera
][
i
].
type
()
!=
CV_32F
)
{
_tEachCamera
[
camera
][
i
].
convertTo
(
_tEachCamera
[
camera
][
i
],
CV_32F
);
}
Mat
transform
=
Mat
::
eye
(
4
,
4
,
CV_32F
);
Mat
R
,
T
;
Rodrigues
(
_omEachCamera
[
camera
][
i
],
R
);
T
=
(
_tEachCamera
[
camera
][
i
]).
reshape
(
1
,
3
);
R
.
copyTo
(
transform
.
rowRange
(
0
,
3
).
colRange
(
0
,
3
));
T
.
copyTo
(
transform
.
rowRange
(
0
,
3
).
col
(
3
));
this
->
_edgeList
.
push_back
(
edge
(
cameraVertex
,
photoVertex
,
idx
.
at
<
int
>
(
i
),
transform
));
}
int
cameraVertex
,
timestamp
,
photoVertex
;
cameraVertex
=
camera
;
timestamp
=
timestampAvailable
[
camera
][
idx
.
at
<
int
>
(
i
)];
photoVertex
=
this
->
getPhotoVertex
(
timestamp
);
if
(
_omEachCamera
[
camera
][
i
].
type
()
!=
CV_32F
)
{
_omEachCamera
[
camera
][
i
].
convertTo
(
_omEachCamera
[
camera
][
i
],
CV_32F
);
}
if
(
_tEachCamera
[
camera
][
i
].
type
()
!=
CV_32F
)
{
_tEachCamera
[
camera
][
i
].
convertTo
(
_tEachCamera
[
camera
][
i
],
CV_32F
);
}
Mat
transform
=
Mat
::
eye
(
4
,
4
,
CV_32F
);
Mat
R
,
T
;
Rodrigues
(
_omEachCamera
[
camera
][
i
],
R
);
T
=
(
_tEachCamera
[
camera
][
i
]).
reshape
(
1
,
3
);
R
.
copyTo
(
transform
.
rowRange
(
0
,
3
).
colRange
(
0
,
3
));
T
.
copyTo
(
transform
.
rowRange
(
0
,
3
).
col
(
3
));
this
->
_edgeList
.
push_back
(
edge
(
cameraVertex
,
photoVertex
,
idx
.
at
<
int
>
(
i
),
transform
));
}
std
::
cout
<<
"initialized for camera "
<<
camera
<<
" rms = "
<<
rms
<<
std
::
endl
;
}
}
...
...
@@ -355,6 +358,7 @@ double multiCameraCalibration::optimizeExtrinsics()
}
extrinParam
=
extrinParam
+
G
.
reshape
(
1
,
1
);
change
=
norm
(
G
)
/
norm
(
extrinParam
);
//double error = computeProjectError(extrinParam);
}
...
...
modules/ccalib/src/omnidir.cpp
View file @
5beefcfa
...
...
@@ -1638,7 +1638,7 @@ void cv::omnidir::internal::encodeParameters(InputArray K, InputArrayOfArrays om
CV_Assert
(
distoaration
.
total
()
==
4
&&
distoaration
.
type
()
==
CV_64F
);
int
n
=
(
int
)
omAll
.
total
();
Mat
_omAll
=
omAll
.
getMat
(),
_tAll
=
tAll
.
getMat
();
Mat
tmp
=
Mat
(
_omAll
.
at
<
Vec3d
>
(
0
)).
reshape
(
1
,
3
).
clone
();
Matx33d
_K
=
K
.
getMat
();
Vec4d
_D
=
(
Vec4d
)
distoaration
.
getMat
();
parameters
.
create
(
1
,
10
+
6
*
n
,
CV_64F
);
...
...
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