31 #include <orb_slam/Converter.h>
59 : mVocabulary(frame.mVocabulary),
60 mpORBextractorLeft(frame.mpORBextractorLeft),
61 mTimeStamp(frame.mTimeStamp),
63 mDistCoef(frame.mDistCoef.clone()),
66 mvKeysUn(frame.mvKeysUn),
68 mBowVec(frame.mBowVec),
69 mFeatVec(frame.mFeatVec),
70 mDescriptors(frame.mDescriptors.clone()),
71 mvpMapPoints(frame.mvpMapPoints),
73 mpReferenceKF(frame.mpReferenceKF),
74 mnScaleLevels(frame.mnScaleLevels),
75 mfScaleFactor(frame.mfScaleFactor),
76 mfLogScaleFactor(frame.mfLogScaleFactor),
77 mvScaleFactors(frame.mvScaleFactors),
78 mvInvScaleFactors(frame.mvInvScaleFactors),
79 mvLevelSigma2(frame.mvLevelSigma2),
80 mvInvLevelSigma2(frame.mvInvLevelSigma2)
86 if (!frame.
mTcw.empty())
94 : mpORBextractorLeft(extractor), mTimeStamp(timeStamp),
95 mVocabulary(vocabulary)
99 K.convertTo(
mK, CV_32F);
137 fx =
mK.at<
float>(0, 0);
138 fy =
mK.at<
float>(1, 1);
139 cx =
mK.at<
float>(0, 2);
140 cy =
mK.at<
float>(1, 2);
161 mGrid[i][j].reserve(nReserve);
163 for (
int i = 0; i <
N; i++)
165 const cv::KeyPoint& kp =
mvKeysUn[i];
167 int nGridPosX, nGridPosY;
169 mGrid[nGridPosX][nGridPosY].push_back(i);
186 mRcw =
mTcw.rowRange(0, 3).colRange(0, 3);
201 const float& PcX = Pc.at<
float>(0);
202 const float& PcY = Pc.at<
float>(1);
203 const float& PcZ = Pc.at<
float>(2);
210 const float invz = 1.0f / PcZ;
211 const float u =
fx * PcX * invz +
cx;
212 const float v =
fy * PcY * invz +
cy;
214 if (u < mnMinX || u >
mnMaxX)
216 if (v < mnMinY || v >
mnMaxY)
222 const cv::Mat PO = P -
mOw;
223 const float dist = (float)cv::norm(PO);
225 if (dist < minDistance || dist > maxDistance)
231 const float viewCos = (float)(PO.dot(Pn) / dist);
233 if (viewCos < viewingCosLimit)
237 const int nPredictedLevel = pMP->
PredictScale(dist,
this);
252 vector<size_t> vIndices;
271 const bool bCheckLevels = (minLevel > 0) || (maxLevel >= 0);
273 for (
int ix = nMinCellX; ix <= nMaxCellX; ix++)
275 for (
int iy = nMinCellY; iy <= nMaxCellY; iy++)
277 const vector<size_t> vCell =
mGrid[ix][iy];
281 for (
size_t j = 0, jend = vCell.size(); j < jend; j++)
283 const cv::KeyPoint& kpUn =
mvKeysUn[vCell[j]];
286 if (kpUn.octave < minLevel)
289 if (kpUn.octave > maxLevel)
293 const float distx = kpUn.pt.x - x;
294 const float disty = kpUn.pt.y - y;
296 if (fabs(distx) < r && fabs(disty) < r)
297 vIndices.push_back(vCell[j]);
339 cv::Mat mat(
N, 2, CV_32F);
340 for (
int i = 0; i <
N; i++)
342 mat.at<
float>(i, 0) =
mvKeys[i].pt.x;
343 mat.at<
float>(i, 1) =
mvKeys[i].pt.y;
347 mat = mat.reshape(2);
349 mat = mat.reshape(1);
353 for (
int i = 0; i <
N; i++)
355 cv::KeyPoint kp =
mvKeys[i];
356 kp.pt.x = mat.at<
float>(i, 0);
357 kp.pt.y = mat.at<
float>(i, 1);
366 cv::Mat mat(4, 2, CV_32F);
367 mat.at<
float>(0, 0) = 0.0;
368 mat.at<
float>(0, 1) = 0.0;
369 mat.at<
float>(1, 0) = (
float)imLeft.cols;
370 mat.at<
float>(1, 1) = 0.0;
371 mat.at<
float>(2, 0) = 0.0;
372 mat.at<
float>(2, 1) = (
float)imLeft.rows;
373 mat.at<
float>(3, 0) = (
float)imLeft.cols;
374 mat.at<
float>(3, 1) = (
float)imLeft.rows;
377 mat = mat.reshape(2);
379 mat = mat.reshape(1);
381 mnMinX = (float)min(mat.at<
float>(0, 0), mat.at<
float>(2, 0));
382 mnMaxX = (float)max(mat.at<
float>(1, 0), mat.at<
float>(3, 0));
383 mnMinY = (float)min(mat.at<
float>(0, 1), mat.at<
float>(1, 1));
384 mnMaxY = (float)max(mat.at<
float>(2, 1), mat.at<
float>(3, 1));
389 mnMaxX = (float)imLeft.cols;
391 mnMaxY = (
float)imLeft.rows;
#define AVERAGE_TIMING_STOP(name)
#define AVERAGE_TIMING_START(name)
void UpdatePoseMatrices()
std::vector< float > mvScaleFactors
std::vector< float > mvLevelSigma2
std::vector< WAIMapPoint * > mvpMapPoints
bool isInFrustum(WAIMapPoint *pMP, float viewingCosLimit)
static float mfGridElementHeightInv
std::vector< float > mvInvScaleFactors
std::vector< cv::KeyPoint > mvKeys
std::vector< size_t > GetFeaturesInArea(const float &x, const float &y, const float &r, const int minLevel=-1, const int maxLevel=-1) const
std::vector< std::size_t > mGrid[64][36]
void AssignFeaturesToGrid()
static long unsigned int nNextId
std::vector< float > mvInvLevelSigma2
WAIOrbVocabulary * mVocabulary
KPextractor * mpORBextractorLeft
void ExtractFeaturePoints(const cv::Mat &im)
void UndistortKeyPoints()
static float mfGridElementWidthInv
bool PosInGrid(const cv::KeyPoint &kp, int &posX, int &posY)
std::vector< cv::KeyPoint > mvKeysUn
void ComputeImageBounds(const cv::Mat &imLeft)
void SetPose(cv::Mat Tcw)
static bool mbInitialComputations
float GetMaxDistanceInvariance()
int PredictScale(const float ¤tDist, WAIKeyFrame *pF)
float GetMinDistanceInvariance()
void transform(const cv::Mat &descriptors, WAIBowVector &bow, WAIFeatVector &feat)
void log(const char *tag, const char *format,...)
logs a formatted string platform independently