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
6fa93647
Commit
6fa93647
authored
Dec 20, 2011
by
Alexander Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compilation errors in epnp with gcc
parent
c5d8ec4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
epnp.cpp
modules/calib3d/src/epnp.cpp
+28
-24
No files found.
modules/calib3d/src/epnp.cpp
View file @
6fa93647
...
...
@@ -2,37 +2,41 @@
using
namespace
std
;
#include "precomp.hpp"
#include "epnp.h"
namespace
cv
{
double
ePnP
(
InputArray
_opoints
,
InputArray
_ipoints
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
OutputArray
_rvec
,
OutputArray
_tvec
)
{
Mat
opoints
=
_opoints
.
getMat
(),
ipoints
=
_ipoints
.
getMat
();
int
npoints
=
std
::
max
(
opoints
.
checkVector
(
3
,
CV_32F
),
opoints
.
checkVector
(
3
,
CV_64F
));
CV_Assert
(
npoints
>=
0
&&
npoints
==
std
::
max
(
ipoints
.
checkVector
(
2
,
CV_32F
),
ipoints
.
checkVector
(
2
,
CV_64F
))
);
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
(),
distCoeffs
=
_distCoeffs
.
getMat
();
Mat
undistortedPoints
;
undistortPoints
(
ipoints
,
undistortedPoints
,
cameraMatrix
,
distCoeffs
);
namespace
cv
{
double
ePnP
(
InputArray
_opoints
,
InputArray
_ipoints
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
OutputArray
_rvec
,
OutputArray
_tvec
)
{
Mat
opoints
=
_opoints
.
getMat
(),
ipoints
=
_ipoints
.
getMat
();
int
npoints
=
std
::
max
(
opoints
.
checkVector
(
3
,
CV_32F
),
opoints
.
checkVector
(
3
,
CV_64F
));
CV_Assert
(
npoints
>=
0
&&
npoints
==
std
::
max
(
ipoints
.
checkVector
(
2
,
CV_32F
),
ipoints
.
checkVector
(
2
,
CV_64F
))
);
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
(),
distCoeffs
=
_distCoeffs
.
getMat
();
Mat
undistortedPoints
;
undistortPoints
(
ipoints
,
undistortedPoints
,
cameraMatrix
,
distCoeffs
);
epnp
PnP
;
PnP
.
set_internal_parameters
(
cameraMatrix
.
at
<
double
>
(
0
,
2
),
cameraMatrix
.
at
<
double
>
(
1
,
2
),
cameraMatrix
.
at
<
double
>
(
0
,
0
),
cameraMatrix
.
at
<
double
>
(
1
,
1
));
PnP
.
set_maximum_number_of_correspondences
(
npoints
);
PnP
.
set_maximum_number_of_correspondences
(
npoints
);
PnP
.
reset_correspondences
();
for
(
int
i
=
0
;
i
<
npoints
;
i
++
)
{
PnP
.
add_correspondence
(
opoints
.
at
<
Point3d
>
(
0
,
i
).
x
,
opoints
.
at
<
Point3d
>
(
0
,
i
).
y
,
opoints
.
at
<
Point3d
>
(
0
,
i
).
z
,
undistortedPoints
.
at
<
Point2d
>
(
0
,
i
).
x
*
cameraMatrix
.
at
<
double
>
(
0
,
0
)
+
cameraMatrix
.
at
<
double
>
(
0
,
2
),
undistortedPoints
.
at
<
Point2d
>
(
0
,
i
).
y
*
cameraMatrix
.
at
<
double
>
(
1
,
1
)
+
cameraMatrix
.
at
<
double
>
(
1
,
2
));
}
}
double
R_est
[
3
][
3
],
t_est
[
3
];
double
error
=
PnP
.
compute_pose
(
R_est
,
t_est
);
_tvec
.
create
(
3
,
1
,
CV_64F
);
_rvec
.
create
(
3
,
1
,
CV_64F
);
Mat
(
3
,
1
,
CV_64FC1
,
t_est
).
copyTo
(
_tvec
.
getMat
());
Rodrigues
(
Mat
(
3
,
3
,
CV_64FC1
,
R_est
),
_rvec
.
getMat
());
return
error
;
double
error
=
PnP
.
compute_pose
(
R_est
,
t_est
);
_tvec
.
create
(
3
,
1
,
CV_64F
);
_rvec
.
create
(
3
,
1
,
CV_64F
);
Mat
t
=
Mat
(
3
,
1
,
CV_64FC1
,
t_est
);
Mat
tvec
=
_tvec
.
getMat
();
t
.
copyTo
(
tvec
);
Mat
R
=
Mat
(
3
,
3
,
CV_64FC1
,
R_est
);
Mat
rvec
=
_rvec
.
getMat
();
Rodrigues
(
R
,
rvec
);
return
error
;
}
}
...
...
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