Skip to content

Commit d3a124c

Browse files
committed
Merge pull request opencv#10339 from catree:add_doc_solvepnp_figure_desc
2 parents 86cc4f3 + fcb537b commit d3a124c

File tree

1 file changed

+91
-1
lines changed

1 file changed

+91
-1
lines changed

modules/calib3d/include/opencv2/calib3d.hpp

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,97 @@ focal length.
567567
function requires exactly four object and image points.
568568
569569
The function estimates the object pose given a set of object points, their corresponding image
570-
projections, as well as the camera matrix and the distortion coefficients.
570+
projections, as well as the camera matrix and the distortion coefficients, see the figure below
571+
(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
572+
and the Z-axis forward).
573+
574+
![](pnp.jpg)
575+
576+
Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
577+
using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
578+
579+
\f[
580+
\begin{align*}
581+
\begin{bmatrix}
582+
u \\
583+
v \\
584+
1
585+
\end{bmatrix} &=
586+
\bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{M}_w
587+
\begin{bmatrix}
588+
X_{w} \\
589+
Y_{w} \\
590+
Z_{w} \\
591+
1
592+
\end{bmatrix} \\
593+
\begin{bmatrix}
594+
u \\
595+
v \\
596+
1
597+
\end{bmatrix} &=
598+
\begin{bmatrix}
599+
f_x & 0 & c_x \\
600+
0 & f_y & c_y \\
601+
0 & 0 & 1
602+
\end{bmatrix}
603+
\begin{bmatrix}
604+
1 & 0 & 0 & 0 \\
605+
0 & 1 & 0 & 0 \\
606+
0 & 0 & 1 & 0
607+
\end{bmatrix}
608+
\begin{bmatrix}
609+
r_{11} & r_{12} & r_{13} & t_x \\
610+
r_{21} & r_{22} & r_{23} & t_y \\
611+
r_{31} & r_{32} & r_{33} & t_z \\
612+
0 & 0 & 0 & 1
613+
\end{bmatrix}
614+
\begin{bmatrix}
615+
X_{w} \\
616+
Y_{w} \\
617+
Z_{w} \\
618+
1
619+
\end{bmatrix}
620+
\end{align*}
621+
\f]
622+
623+
The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow to transform
624+
a 3D point expressed in the world frame into the camera frame:
625+
626+
\f[
627+
\begin{align*}
628+
\begin{bmatrix}
629+
X_c \\
630+
Y_c \\
631+
Z_c \\
632+
1
633+
\end{bmatrix} &=
634+
\hspace{0.2em} ^{c}\bf{M}_w
635+
\begin{bmatrix}
636+
X_{w} \\
637+
Y_{w} \\
638+
Z_{w} \\
639+
1
640+
\end{bmatrix} \\
641+
\begin{bmatrix}
642+
X_c \\
643+
Y_c \\
644+
Z_c \\
645+
1
646+
\end{bmatrix} &=
647+
\begin{bmatrix}
648+
r_{11} & r_{12} & r_{13} & t_x \\
649+
r_{21} & r_{22} & r_{23} & t_y \\
650+
r_{31} & r_{32} & r_{33} & t_z \\
651+
0 & 0 & 0 & 1
652+
\end{bmatrix}
653+
\begin{bmatrix}
654+
X_{w} \\
655+
Y_{w} \\
656+
Z_{w} \\
657+
1
658+
\end{bmatrix}
659+
\end{align*}
660+
\f]
571661
572662
@note
573663
- An example of how to use solvePnP for planar augmented reality can be found at

0 commit comments

Comments
 (0)