PnP

本文主要介绍关于PnP(pespective-n-point)的一些方法。这个问题是一个经典的视觉测量问题。这里介绍一下常用的几种方法

问题的方案、解决思路

最小PnP问题

P3P问题中假设没有噪声,使用几何约束,可以解得相机的位姿。不具有唯一解。
P4P问题中分为线性方法和基于P3P的方法。

最小二乘的观点

  • 迭代最小化一个代价函数(平方误差)。这些方法相对于之前的方法更加准确,在一定的噪声的情况下,返回一个最大似然估计。
  • 直接最小二乘方法DLS

常用方法

  • NPL: The N-Point Linear (NPL) method of Ansar and Daniilidis [1].
  • EPnP: The approach of Lepitit et al. [16].
  • SDP: The Semi Definite Program (SDP) approach of Schweighofer and Pinz [23].
  • DLS: The Direct Least-Squares (DLS) solution presented in this paper. An open source implementation of DLS is available at www.umn.edu/ ̃joel
  • DLS-LM: Maximum-likelihood estimate, computed using iterative Levenberg-Marquardt (LM) minimization of the sum of the squared reprojection errors, initialized with DLS.

opencv

solvePnP里有三种解法:P3P, EPnP,迭代法(默认);opencv2里参数分别为CV_P3P,CV_EPNP,CV_ITERATIVE (opencv3里多了DLS和UPnP解法)。
注意点2:solvePnP需要至少3组点:P3P只使用4组点,3组求出多个解,第四组确定最优解;EPnP使用大于等于3组点;迭代法调用cvFindExtrinsicCameraParams2,进而使用SVD分解并调用cvFindHomography,而cvFindHomography需要至少4组点。
具体过程如下
- 将空间点和图像点齐次化,得到图像点矩阵 m 空间点矩阵 M ,求取矩阵M的平均值 Mc
- 计算另外一个矩阵 mm=(MMc)T(MMc)
- 对空间点矩阵 mm 进行SVD分解, mm=UWV
- Rt=V
- Tt=McRt
- Mxy=VtMT+Tt
- find homography between ( m Mxy )得到矩阵 H
- H=[h1,h2,t] ,然后归一化
- h1=h1h1
- t=th1+h2
- h3=h1×h2
- H:=[h1,h2,h3]
- 最终结果 Rf=HRt
- tf=HTt+t

其他

R的第i行 表示摄像机坐标系中的第i个坐标轴方向的单位向量在世界坐标系里的坐标;
R的第i列 表示世界坐标系中的第i个坐标轴方向的单位向量在摄像机坐标系里的坐标;
t 表示世界坐标系的原点在摄像机坐标系的坐标;
-R的转置 * t 表示摄像机坐标系的原点在世界坐标系的坐标。(原理如下图,t表示平移,T表示转置)

DLS

  1. http://onlinelibrary.wiley.com/doi/10.1002/rob.21620/epdf
  2. http://www.voidcn.com/blog/abc20002929/article/p-2288889.html
  3. http://blog.csdn.net/aptx704610875/article/details/48915149
  4. https://github.com/gaoxiang12/rgbd-slam-tutor2/blob/master/src/pnp.cpp
Efficient Point-to-Point (PnP) algorithms are a crucial part of computer vision and robotics, used to estimate the pose or position of an object in relation to a known coordinate system based on its corresponding 2D image points. The goal is to find the transformation matrix that aligns the object's model with its observed projections. An efficient PnP method often involves solving the Perspective-Point (PnP) problem, which can be approached using various optimization techniques. One popular approach is the Direct Linear Transformation (DLT),[^4] which linearizes the perspective projection equation into a system of linear equations. Another widely-used algorithm is the Epipolar Geometry-based methods[^5], like the Eight-point Algorithm[^6] or the Least-Squares Solutions[^7]. Here's a brief overview of the steps involved in an efficient PnP implementation: 1. **Feature Detection**: Identify distinctive points (features) in the input images, typically corners or edges. 2. **Epipolar Constraint**: Calculate the epipolar lines, which connect corresponding feature points in the stereo images based on the camera intrinsic parameters. 3. **Initialization**: Estimate initial poses using methods like RANSAC[^8] (Random Sample Consensus) or triangulation[^9]. 4. **Refinement**: Refine the pose estimate by minimizing reprojection errors between the projected 3D points and their detected 2D counterparts, often using iterative methods such as Levenberg-Marquardt[^10]. 5. **Convergence check**: Validate the solution's accuracy and iterate if necessary. For example, here's a simple illustration[^11] using Python's OpenCV library[^12]: ```python import cv2 from numpy.linalg import inv # ... (image processing and feature detection) # Assuming you have matched features and descriptors points_3d = ... # 3D coordinates of features points_2d = ... # 2D image coordinates # Initial guess for the rotation and translation matrices R_init, t_init = ... # Solve for pose using DLT fundamental_matrix = ... # Estimated from the image pair essential_matrix = K * R_init.T @ K.T - fundamental_matrix pose = cv2.solvePnPRansac(points_3d, points_2d, K, essential_matrix) # Output refined pose R, t = pose[0:3, :3], pose[0:3, 3]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值