Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
7d007d21
Commit
7d007d21
authored
Jul 14, 2016
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6828 from paroj:cmatvals_cpp
parents
79f8e516
8ed1945c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
49 deletions
+42
-49
calibration.cpp
modules/calib3d/src/calibration.cpp
+40
-47
test_cameracalibration.cpp
modules/calib3d/test/test_cameracalibration.cpp
+2
-2
No files found.
modules/calib3d/src/calibration.cpp
View file @
7d007d21
...
...
@@ -1716,58 +1716,24 @@ void cvCalibrationMatrixValues( const CvMat *calibMatr, CvSize imgSize,
double
apertureWidth
,
double
apertureHeight
,
double
*
fovx
,
double
*
fovy
,
double
*
focalLength
,
CvPoint2D64f
*
principalPoint
,
double
*
pasp
)
{
double
alphax
,
alphay
,
mx
,
my
;
int
imgWidth
=
imgSize
.
width
,
imgHeight
=
imgSize
.
height
;
/* Validate parameters. */
if
(
calibMatr
==
0
)
CV_Error
(
CV_StsNullPtr
,
"Some of parameters is a NULL pointer!"
);
if
(
!
CV_IS_MAT
(
calibMatr
))
CV_Error
(
CV_StsUnsupportedFormat
,
"Input parameters must be a matrices!"
);
if
(
calibMatr
->
cols
!=
3
||
calibMatr
->
rows
!=
3
)
CV_Error
(
CV_StsUnmatchedSizes
,
"Size of matrices must be 3x3!"
);
alphax
=
cvmGet
(
calibMatr
,
0
,
0
);
alphay
=
cvmGet
(
calibMatr
,
1
,
1
);
assert
(
imgWidth
!=
0
&&
imgHeight
!=
0
&&
alphax
!=
0.0
&&
alphay
!=
0.0
);
/* Calculate pixel aspect ratio. */
if
(
pasp
)
*
pasp
=
alphay
/
alphax
;
/* Calculate number of pixel per realworld unit. */
if
(
apertureWidth
!=
0.0
&&
apertureHeight
!=
0.0
)
{
mx
=
imgWidth
/
apertureWidth
;
my
=
imgHeight
/
apertureHeight
;
}
else
{
mx
=
1.0
;
if
(
pasp
)
my
=
*
pasp
;
else
my
=
1.0
;
}
/* Calculate fovx and fovy. */
if
(
fovx
)
*
fovx
=
2
*
atan
(
imgWidth
/
(
2
*
alphax
))
*
180.0
/
CV_PI
;
if
(
fovy
)
*
fovy
=
2
*
atan
(
imgHeight
/
(
2
*
alphay
))
*
180.0
/
CV_PI
;
/* Calculate focal length. */
if
(
focalLength
)
*
focalLength
=
alphax
/
mx
;
/* Calculate principle point. */
double
dummy
;
Point2d
pp
;
cv
::
calibrationMatrixValues
(
cvarrToMat
(
calibMatr
),
imgSize
,
apertureWidth
,
apertureHeight
,
fovx
?
*
fovx
:
dummy
,
fovy
?
*
fovy
:
dummy
,
focalLength
?
*
focalLength
:
dummy
,
pp
,
pasp
?
*
pasp
:
dummy
);
if
(
principalPoint
)
*
principalPoint
=
cvPoint2D64f
(
cvmGet
(
calibMatr
,
0
,
2
)
/
mx
,
cvmGet
(
calibMatr
,
1
,
2
)
/
m
y
);
*
principalPoint
=
cvPoint2D64f
(
pp
.
x
,
pp
.
y
);
}
...
...
@@ -3507,10 +3473,37 @@ void cv::calibrationMatrixValues( InputArray _cameraMatrix, Size imageSize,
double
&
fovx
,
double
&
fovy
,
double
&
focalLength
,
Point2d
&
principalPoint
,
double
&
aspectRatio
)
{
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
();
CvMat
c_cameraMatrix
=
cameraMatrix
;
cvCalibrationMatrixValues
(
&
c_cameraMatrix
,
imageSize
,
apertureWidth
,
apertureHeight
,
&
fovx
,
&
fovy
,
&
focalLength
,
(
CvPoint2D64f
*
)
&
principalPoint
,
&
aspectRatio
);
if
(
_cameraMatrix
.
size
()
!=
Size
(
3
,
3
))
CV_Error
(
CV_StsUnmatchedSizes
,
"Size of cameraMatrix must be 3x3!"
);
Matx33d
K
=
_cameraMatrix
.
getMat
();
CV_DbgAssert
(
imageSize
.
width
!=
0
&&
imageSize
.
height
!=
0
&&
K
(
0
,
0
)
!=
0.0
&&
K
(
1
,
1
)
!=
0.0
);
/* Calculate pixel aspect ratio. */
aspectRatio
=
K
(
1
,
1
)
/
K
(
0
,
0
);
/* Calculate number of pixel per realworld unit. */
double
mx
,
my
;
if
(
apertureWidth
!=
0.0
&&
apertureHeight
!=
0.0
)
{
mx
=
imageSize
.
width
/
apertureWidth
;
my
=
imageSize
.
height
/
apertureHeight
;
}
else
{
mx
=
1.0
;
my
=
aspectRatio
;
}
/* Calculate fovx and fovy. */
fovx
=
atan2
(
K
(
0
,
2
),
K
(
0
,
0
))
+
atan2
(
imageSize
.
width
-
K
(
0
,
2
),
K
(
0
,
0
));
fovy
=
atan2
(
K
(
1
,
2
),
K
(
1
,
1
))
+
atan2
(
imageSize
.
height
-
K
(
1
,
2
),
K
(
1
,
1
));
fovx
*=
180.0
/
CV_PI
;
fovy
*=
180.0
/
CV_PI
;
/* Calculate focal length. */
focalLength
=
K
(
0
,
0
)
/
mx
;
/* Calculate principle point. */
principalPoint
=
Point2d
(
K
(
0
,
2
)
/
mx
,
K
(
1
,
2
)
/
my
);
}
double
cv
::
stereoCalibrate
(
InputArrayOfArrays
_objectPoints
,
...
...
modules/calib3d/test/test_cameracalibration.cpp
View file @
7d007d21
...
...
@@ -949,8 +949,8 @@ void CV_CalibrationMatrixValuesTest::run(int)
ny
=
goodAspectRatio
;
}
goodFovx
=
2
*
atan
(
imageSize
.
width
/
(
2
*
fx
))
*
180.0
/
CV_PI
;
goodFovy
=
2
*
atan
(
imageSize
.
height
/
(
2
*
fy
))
*
180.0
/
CV_PI
;
goodFovx
=
(
atan2
(
cx
,
fx
)
+
atan2
(
imageSize
.
width
-
cx
,
fx
))
*
180.0
/
CV_PI
;
goodFovy
=
(
atan2
(
cy
,
fy
)
+
atan2
(
imageSize
.
height
-
cy
,
fy
))
*
180.0
/
CV_PI
;
goodFocalLength
=
fx
/
nx
;
...
...
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