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
8cfddcfe
Commit
8cfddcfe
authored
Apr 25, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6454 from paroj:fisheye_py
parents
681fd7f2
ccadad42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
fisheye.cpp
modules/calib3d/src/fisheye.cpp
+29
-16
No files found.
modules/calib3d/src/fisheye.cpp
View file @
8cfddcfe
...
@@ -794,13 +794,22 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray
...
@@ -794,13 +794,22 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray
if
(
K
.
needed
())
cv
::
Mat
(
_K
).
convertTo
(
K
,
K
.
empty
()
?
CV_64FC1
:
K
.
type
());
if
(
K
.
needed
())
cv
::
Mat
(
_K
).
convertTo
(
K
,
K
.
empty
()
?
CV_64FC1
:
K
.
type
());
if
(
D
.
needed
())
cv
::
Mat
(
finalParam
.
k
).
convertTo
(
D
,
D
.
empty
()
?
CV_64FC1
:
D
.
type
());
if
(
D
.
needed
())
cv
::
Mat
(
finalParam
.
k
).
convertTo
(
D
,
D
.
empty
()
?
CV_64FC1
:
D
.
type
());
if
(
rvecs
.
kind
()
==
_InputArray
::
STD_VECTOR_MAT
)
if
(
rvecs
.
isMatVector
()
)
{
{
int
i
;
int
N
=
(
int
)
objectPoints
.
total
();
for
(
i
=
0
;
i
<
(
int
)
objectPoints
.
total
();
i
++
)
if
(
rvecs
.
empty
())
rvecs
.
create
(
N
,
1
,
CV_64FC3
);
if
(
tvecs
.
empty
())
tvecs
.
create
(
N
,
1
,
CV_64FC3
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
{
rvecs
.
getMat
(
i
)
=
omc
[
i
];
rvecs
.
create
(
3
,
1
,
CV_64F
,
i
,
true
);
tvecs
.
getMat
(
i
)
=
Tc
[
i
];
tvecs
.
create
(
3
,
1
,
CV_64F
,
i
,
true
);
memcpy
(
rvecs
.
getMat
(
i
).
ptr
(),
omc
[
i
].
val
,
sizeof
(
Vec3d
));
memcpy
(
tvecs
.
getMat
(
i
).
ptr
(),
Tc
[
i
].
val
,
sizeof
(
Vec3d
));
}
}
}
}
else
else
...
@@ -1295,12 +1304,12 @@ cv::Mat cv::internal::NormalizePixels(const Mat& imagePoints, const IntrinsicPar
...
@@ -1295,12 +1304,12 @@ cv::Mat cv::internal::NormalizePixels(const Mat& imagePoints, const IntrinsicPar
CV_Assert
(
!
imagePoints
.
empty
()
&&
imagePoints
.
type
()
==
CV_64FC2
);
CV_Assert
(
!
imagePoints
.
empty
()
&&
imagePoints
.
type
()
==
CV_64FC2
);
Mat
distorted
((
int
)
imagePoints
.
total
(),
1
,
CV_64FC2
),
undistorted
;
Mat
distorted
((
int
)
imagePoints
.
total
(),
1
,
CV_64FC2
),
undistorted
;
const
Vec2d
*
ptr
=
imagePoints
.
ptr
<
Vec2d
>
(
0
);
const
Vec2d
*
ptr
=
imagePoints
.
ptr
<
Vec2d
>
();
Vec2d
*
ptr_d
=
distorted
.
ptr
<
Vec2d
>
(
0
);
Vec2d
*
ptr_d
=
distorted
.
ptr
<
Vec2d
>
();
for
(
size_t
i
=
0
;
i
<
imagePoints
.
total
();
++
i
)
for
(
size_t
i
=
0
;
i
<
imagePoints
.
total
();
++
i
)
{
{
ptr_d
[
i
]
=
(
ptr
[
i
]
-
param
.
c
).
mul
(
Vec2d
(
1.0
/
param
.
f
[
0
],
1.0
/
param
.
f
[
1
]));
ptr_d
[
i
]
=
(
ptr
[
i
]
-
param
.
c
).
mul
(
Vec2d
(
1.0
/
param
.
f
[
0
],
1.0
/
param
.
f
[
1
]));
ptr_d
[
i
][
0
]
=
ptr_d
[
i
][
0
]
-
param
.
alpha
*
ptr_d
[
i
][
1
];
ptr_d
[
i
][
0
]
-=
param
.
alpha
*
ptr_d
[
i
][
1
];
}
}
cv
::
fisheye
::
undistortPoints
(
distorted
,
undistorted
,
Matx33d
::
eye
(),
param
.
k
);
cv
::
fisheye
::
undistortPoints
(
distorted
,
undistorted
,
Matx33d
::
eye
(),
param
.
k
);
return
undistorted
;
return
undistorted
;
...
@@ -1308,12 +1317,11 @@ cv::Mat cv::internal::NormalizePixels(const Mat& imagePoints, const IntrinsicPar
...
@@ -1308,12 +1317,11 @@ cv::Mat cv::internal::NormalizePixels(const Mat& imagePoints, const IntrinsicPar
void
cv
::
internal
::
InitExtrinsics
(
const
Mat
&
_imagePoints
,
const
Mat
&
_objectPoints
,
const
IntrinsicParams
&
param
,
Mat
&
omckk
,
Mat
&
Tckk
)
void
cv
::
internal
::
InitExtrinsics
(
const
Mat
&
_imagePoints
,
const
Mat
&
_objectPoints
,
const
IntrinsicParams
&
param
,
Mat
&
omckk
,
Mat
&
Tckk
)
{
{
CV_Assert
(
!
_objectPoints
.
empty
()
&&
_objectPoints
.
type
()
==
CV_64FC3
);
CV_Assert
(
!
_objectPoints
.
empty
()
&&
_objectPoints
.
type
()
==
CV_64FC3
);
CV_Assert
(
!
_imagePoints
.
empty
()
&&
_imagePoints
.
type
()
==
CV_64FC2
);
CV_Assert
(
!
_imagePoints
.
empty
()
&&
_imagePoints
.
type
()
==
CV_64FC2
);
Mat
imagePointsNormalized
=
NormalizePixels
(
_imagePoints
.
t
()
,
param
).
reshape
(
1
).
t
();
Mat
imagePointsNormalized
=
NormalizePixels
(
_imagePoints
,
param
).
reshape
(
1
).
t
();
Mat
objectPoints
=
Mat
(
_objectPoints
.
t
())
.
reshape
(
1
).
t
();
Mat
objectPoints
=
_objectPoints
.
reshape
(
1
).
t
();
Mat
objectPointsMean
,
covObjectPoints
;
Mat
objectPointsMean
,
covObjectPoints
;
Mat
Rckk
;
Mat
Rckk
;
int
Np
=
imagePointsNormalized
.
cols
;
int
Np
=
imagePointsNormalized
.
cols
;
...
@@ -1366,9 +1374,12 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
...
@@ -1366,9 +1374,12 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
InitExtrinsics
(
image
,
object
,
param
,
omckk
,
Tckk
);
bool
imT
=
image
.
rows
<
image
.
cols
;
bool
obT
=
object
.
rows
<
object
.
cols
;
ComputeExtrinsicRefine
(
image
,
object
,
omckk
,
Tckk
,
JJ_kk
,
maxIter
,
param
,
thresh_cond
);
InitExtrinsics
(
imT
?
image
.
t
()
:
image
,
obT
?
object
.
t
()
:
object
,
param
,
omckk
,
Tckk
);
ComputeExtrinsicRefine
(
!
imT
?
image
.
t
()
:
image
,
!
obT
?
object
.
t
()
:
object
,
omckk
,
Tckk
,
JJ_kk
,
maxIter
,
param
,
thresh_cond
);
if
(
check_cond
)
if
(
check_cond
)
{
{
SVD
svd
(
JJ_kk
,
SVD
::
NO_UV
);
SVD
svd
(
JJ_kk
,
SVD
::
NO_UV
);
...
@@ -1379,7 +1390,6 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
...
@@ -1379,7 +1390,6 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
}
}
}
}
void
cv
::
internal
::
ComputeJacobians
(
InputArrayOfArrays
objectPoints
,
InputArrayOfArrays
imagePoints
,
void
cv
::
internal
::
ComputeJacobians
(
InputArrayOfArrays
objectPoints
,
InputArrayOfArrays
imagePoints
,
const
IntrinsicParams
&
param
,
InputArray
omc
,
InputArray
Tc
,
const
IntrinsicParams
&
param
,
InputArray
omc
,
InputArray
Tc
,
const
int
&
check_cond
,
const
double
&
thresh_cond
,
Mat
&
JJ2
,
Mat
&
ex3
)
const
int
&
check_cond
,
const
double
&
thresh_cond
,
Mat
&
JJ2
,
Mat
&
ex3
)
...
@@ -1401,12 +1411,13 @@ void cv::internal::ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayO
...
@@ -1401,12 +1411,13 @@ void cv::internal::ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayO
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
bool
imT
=
image
.
rows
<
image
.
cols
;
Mat
om
(
omc
.
getMat
().
col
(
image_idx
)),
T
(
Tc
.
getMat
().
col
(
image_idx
));
Mat
om
(
omc
.
getMat
().
col
(
image_idx
)),
T
(
Tc
.
getMat
().
col
(
image_idx
));
std
::
vector
<
Point2d
>
x
;
std
::
vector
<
Point2d
>
x
;
Mat
jacobians
;
Mat
jacobians
;
projectPoints
(
object
,
x
,
om
,
T
,
param
,
jacobians
);
projectPoints
(
object
,
x
,
om
,
T
,
param
,
jacobians
);
Mat
exkk
=
image
.
t
(
)
-
Mat
(
x
);
Mat
exkk
=
(
imT
?
image
.
t
()
:
image
)
-
Mat
(
x
);
Mat
A
(
jacobians
.
rows
,
9
,
CV_64FC1
);
Mat
A
(
jacobians
.
rows
,
9
,
CV_64FC1
);
jacobians
.
colRange
(
0
,
4
).
copyTo
(
A
.
colRange
(
0
,
4
));
jacobians
.
colRange
(
0
,
4
).
copyTo
(
A
.
colRange
(
0
,
4
));
...
@@ -1460,11 +1471,13 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA
...
@@ -1460,11 +1471,13 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
objectPoints
.
getMat
(
image_idx
).
convertTo
(
object
,
CV_64FC3
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
imagePoints
.
getMat
(
image_idx
).
convertTo
(
image
,
CV_64FC2
);
bool
imT
=
image
.
rows
<
image
.
cols
;
Mat
om
(
omc
.
getMat
().
col
(
image_idx
)),
T
(
Tc
.
getMat
().
col
(
image_idx
));
Mat
om
(
omc
.
getMat
().
col
(
image_idx
)),
T
(
Tc
.
getMat
().
col
(
image_idx
));
std
::
vector
<
Point2d
>
x
;
std
::
vector
<
Point2d
>
x
;
projectPoints
(
object
,
x
,
om
,
T
,
params
,
noArray
());
projectPoints
(
object
,
x
,
om
,
T
,
params
,
noArray
());
Mat
ex_
=
image
.
t
(
)
-
Mat
(
x
);
Mat
ex_
=
(
imT
?
image
.
t
()
:
image
)
-
Mat
(
x
);
ex_
.
copyTo
(
ex
.
rowRange
(
ex_
.
rows
*
image_idx
,
ex_
.
rows
*
(
image_idx
+
1
)));
ex_
.
copyTo
(
ex
.
rowRange
(
ex_
.
rows
*
image_idx
,
ex_
.
rows
*
(
image_idx
+
1
)));
}
}
...
...
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