随手笔记——2D−2D: 对极几何及代码示例
说明
2D−2D: 对极几何及代码示例
几个重要矩阵
基础矩阵(Fundamental Matrix)F 、本质矩阵(Essential Matrix)E、单应矩阵(Homography)H
几个重要函数
fundamental_matrix = findFundamentalMat(points1, points2, CV_FM_8POINT);
essential_matrix = findEssentialMat(points1, points2, focal_length, principal_point);
homography_matrix = findHomography(points1, points2, RANSAC, 3);
// 此函数仅在Opencv3中提供
recoverPose(essential_matrix, points1, points2, R, t, focal_length, principal_point);
对极约束求解相机运动
整个程序使用opencv提供的算法进行求解
源代码:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
// #include "extra.h" // use this if in OpenCV2
using namespace std;
using namespace cv;
/****************************************************
* 本程序演示了如何使用2D-2D的特征匹配估计相机运动
* **************************************************/
void find_feature_matches(
const Mat &img_1, const Mat &img_2,
std::vector<KeyPoint> &keypoints_1,
std::vector<KeyPoint> &keypoints_2,
std::vector<DMatch> &matches);
void pose_estimation_2d2d(
std::vector<KeyPoint> keypoints_1

该程序演示如何使用OpenCV库通过2D特征匹配来估计相机运动。关键步骤包括检测ORB特征,匹配描述符,计算基础矩阵、本质矩阵和单应矩阵,以及使用对极约束求解旋转(R)和平移(t)。代码利用findFundamentalMat、findEssentialMat和recoverPose等函数实现运动恢复。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



