#include <F2FTransform.h>
|
static void | opticalFlowMatch (const cv::Mat &f1Gray, const cv::Mat &f2Gray, std::vector< cv::Point2f > &p1, std::vector< cv::Point2f > &p2, std::vector< uchar > &inliers, std::vector< float > &err) |
|
static float | filterPoints (const std::vector< cv::Point2f > &p1, const std::vector< cv::Point2f > &p2, std::vector< cv::Point2f > &goodP1, std::vector< cv::Point2f > &goodP2, std::vector< uchar > &inliers, std::vector< float > &err) |
|
static bool | estimateRot (const cv::Mat K, std::vector< cv::Point2f > &p1, std::vector< cv::Point2f > &p2, float &yaw, float &pitch, float &roll) |
|
static bool | estimateRotXYZ (const cv::Mat &K, const std::vector< cv::Point2f > &p1, const std::vector< cv::Point2f > &p2, float &xAngRAD, float &yAngRAD, float &zAngRAD, std::vector< uchar > &inliers) |
|
static bool | estimateRotXY (const cv::Mat &K, const std::vector< cv::Point2f > &p1, const std::vector< cv::Point2f > &p2, float &xAngRAD, float &yAngRAD, const float zAngRAD, std::vector< uchar > &inliers) |
|
static void | eulerToMat (float xAngRAD, float yAngRAD, float zAngRAD, cv::Mat &Rx, cv::Mat &Ry, cv::Mat &Rz) |
|
|
static cv::Mat | eigen2cv (Eigen::Matrix3f m) |
|
Definition at line 11 of file F2FTransform.h.
◆ eigen2cv()
cv::Mat F2FTransform::eigen2cv |
( |
Eigen::Matrix3f |
m | ) |
|
|
staticprivate |
Definition at line 266 of file F2FTransform.cpp.
269 r = (cv::Mat_<float>(3, 3) << m(0), m(3), m(6), m(1), m(4), m(7), m(2), m(5), m(8));
◆ estimateRot()
bool F2FTransform::estimateRot |
( |
const cv::Mat |
K, |
|
|
std::vector< cv::Point2f > & |
p1, |
|
|
std::vector< cv::Point2f > & |
p2, |
|
|
float & |
yaw, |
|
|
float & |
pitch, |
|
|
float & |
roll |
|
) |
| |
|
static |
Definition at line 93 of file F2FTransform.cpp.
103 cv::Mat H = estimateAffinePartial2D(p1, p2);
104 float zrot = (float)atan2(H.at<
double>(1, 0), H.at<
double>(0, 0));
108 for (
int i = 0; i < p1.size(); i++)
110 dx += p2[i].x - p1[i].x;
111 dy += p2[i].y - p1[i].y;
113 dx /= (float)p1.size();
114 dy /= (float)p1.size();
116 Eigen::Vector3f v1(0, 0, 1.0);
117 Eigen::Vector3f vx(dx, 0, (
float)K.at<
double>(0, 0));
118 Eigen::Vector3f vy(0, dy, (
float)K.at<
double>(0, 0));
122 float xrot = -acos(v1.dot(vx));
123 float yrot = -acos(v1.dot(vy));
127 if (vx.dot(Eigen::Vector3f::UnitX()) > 0)
132 if (vy.dot(Eigen::Vector3f::UnitY()) > 0)
◆ estimateRotXY()
bool F2FTransform::estimateRotXY |
( |
const cv::Mat & |
K, |
|
|
const std::vector< cv::Point2f > & |
p1, |
|
|
const std::vector< cv::Point2f > & |
p2, |
|
|
float & |
xAngRAD, |
|
|
float & |
yAngRAD, |
|
|
const float |
zAngRAD, |
|
|
std::vector< uchar > & |
inliers |
|
) |
| |
|
static |
Definition at line 187 of file F2FTransform.cpp.
200 double cx = K.at<
double>(0, 2);
201 double cy = K.at<
double>(1, 2);
204 cv::Point2f c((
float)cx, (
float)cy);
205 std::vector<cv::Point2f> p1C = p1;
206 std::vector<cv::Point2f> p2C = p2;
207 for (
int i = 0; i < p1.size(); i++)
218 cv::Mat aHb = cv::estimateAffinePartial2D(p1C, p2C, inliers);
231 yAngRAD = (float)atan(aHb.at<
double>(0, 2) / K.at<
double>(0, 0));
233 xAngRAD = (float)atan(aHb.at<
double>(1, 2) / K.at<
double>(1, 1));
◆ estimateRotXYZ()
bool F2FTransform::estimateRotXYZ |
( |
const cv::Mat & |
K, |
|
|
const std::vector< cv::Point2f > & |
p1, |
|
|
const std::vector< cv::Point2f > & |
p2, |
|
|
float & |
xAngRAD, |
|
|
float & |
yAngRAD, |
|
|
float & |
zAngRAD, |
|
|
std::vector< uchar > & |
inliers |
|
) |
| |
|
static |
Definition at line 140 of file F2FTransform.cpp.
153 double cx = K.at<
double>(0, 2);
154 double cy = K.at<
double>(1, 2);
156 cv::Point2f c((
float)cx, (
float)cy);
157 std::vector<cv::Point2f> p1C = p1;
158 std::vector<cv::Point2f> p2C = p2;
159 for (
int i = 0; i < p1.size(); i++)
167 cv::Mat aHb = cv::estimateAffinePartial2D(p1C, p2C, inliers);
173 cv::Mat bRa = aHb.rowRange(0, 2).colRange(0, 2).t();
174 cv::Mat aTR = aHb.col(2);
175 cv::Mat bTR = bRa * aTR;
178 zAngRAD = (float)atan2(aHb.at<
double>(1, 0), aHb.at<
double>(0, 0));
180 yAngRAD = (float)atan(bTR.at<
double>(0) / K.at<
double>(0, 0));
182 xAngRAD = (float)atan(bTR.at<
double>(1) / K.at<
double>(1, 1));
◆ eulerToMat()
void F2FTransform::eulerToMat |
( |
float |
xAngRAD, |
|
|
float |
yAngRAD, |
|
|
float |
zAngRAD, |
|
|
cv::Mat & |
Rx, |
|
|
cv::Mat & |
Ry, |
|
|
cv::Mat & |
Rz |
|
) |
| |
|
static |
Definition at line 245 of file F2FTransform.cpp.
247 Eigen::Matrix3f mx, my, mz;
248 mx = Eigen::AngleAxisf(xAngRAD, Eigen::Vector3f::UnitX());
249 my = Eigen::AngleAxisf(yAngRAD, Eigen::Vector3f::UnitY());
250 mz = Eigen::AngleAxisf(zAngRAD, Eigen::Vector3f::UnitZ());
256 Rx = cv::Mat::eye(4, 4, CV_32F);
257 eRx.copyTo(Rx.rowRange(0, 3).colRange(0, 3));
259 Ry = cv::Mat::eye(4, 4, CV_32F);
260 eRy.copyTo(Ry.rowRange(0, 3).colRange(0, 3));
262 Rz = cv::Mat::eye(4, 4, CV_32F);
263 eRz.copyTo(Rz.rowRange(0, 3).colRange(0, 3));
◆ filterPoints()
float F2FTransform::filterPoints |
( |
const std::vector< cv::Point2f > & |
p1, |
|
|
const std::vector< cv::Point2f > & |
p2, |
|
|
std::vector< cv::Point2f > & |
goodP1, |
|
|
std::vector< cv::Point2f > & |
goodP2, |
|
|
std::vector< uchar > & |
inliers, |
|
|
std::vector< float > & |
err |
|
) |
| |
|
static |
Definition at line 66 of file F2FTransform.cpp.
77 goodP1.reserve(p1.size());
78 goodP2.reserve(p1.size());
81 for (
int i = 0; i < p1.size(); i++)
83 if (inliers[i] && err[i] < 10.0)
85 goodP1.push_back(p1[i]);
86 goodP2.push_back(p2[i]);
87 avgMotion += (float)cv::norm(p1[i] - p2[i]);
90 return avgMotion / goodP1.size();
◆ opticalFlowMatch()
void F2FTransform::opticalFlowMatch |
( |
const cv::Mat & |
f1Gray, |
|
|
const cv::Mat & |
f2Gray, |
|
|
std::vector< cv::Point2f > & |
p1, |
|
|
std::vector< cv::Point2f > & |
p2, |
|
|
std::vector< uchar > & |
inliers, |
|
|
std::vector< float > & |
err |
|
) |
| |
|
static |
This file is part of ORB-SLAM2.
Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza) For more information see https://github.com/raulmur/ORB_SLAM2
ORB-SLAM2 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ORB-SLAM2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ORB-SLAM2. If not, see http://www.gnu.org/licenses/.
Definition at line 30 of file F2FTransform.cpp.
40 cv::TermCriteria criteria(cv::TermCriteria::COUNT | cv::TermCriteria::EPS, 10, 0.03);
46 p2.reserve(p1.size());
47 inliers.reserve(p1.size());
48 err.reserve(p1.size());
50 cv::Size winSize(11, 11);
52 cv::calcOpticalFlowPyrLK(
The documentation for this class was generated from the following files: