| 2718 | |
| 2719 | |
| 2720 | bool Tracking::TrackReferenceKeyFrame() |
| 2721 | { |
| 2722 | // Compute Bag of Words vector |
| 2723 | mCurrentFrame.ComputeBoW(); |
| 2724 | |
| 2725 | // We perform first an ORB matching with the reference keyframe |
| 2726 | // If enough matches are found we setup a PnP solver |
| 2727 | ORBmatcher matcher(0.7,true); |
| 2728 | vector<MapPoint*> vpMapPointMatches; |
| 2729 | |
| 2730 | int nmatches = matcher.SearchByBoW(mpReferenceKF,mCurrentFrame,vpMapPointMatches); |
| 2731 | |
| 2732 | if(nmatches<15) |
| 2733 | { |
| 2734 | cout << "TRACK_REF_KF: Less than 15 matches!!\n"; |
| 2735 | return false; |
| 2736 | } |
| 2737 | |
| 2738 | mCurrentFrame.mvpMapPoints = vpMapPointMatches; |
| 2739 | mCurrentFrame.SetPose(mLastFrame.GetPose()); |
| 2740 | |
| 2741 | //mCurrentFrame.PrintPointDistribution(); |
| 2742 | |
| 2743 | |
| 2744 | // cout << " TrackReferenceKeyFrame mLastFrame.mTcw: " << mLastFrame.mTcw << endl; |
| 2745 | Optimizer::PoseOptimization(&mCurrentFrame); |
| 2746 | |
| 2747 | // Discard outliers |
| 2748 | int nmatchesMap = 0; |
| 2749 | for(int i =0; i<mCurrentFrame.N; i++) |
| 2750 | { |
| 2751 | //if(i >= mCurrentFrame.Nleft) break; |
| 2752 | if(mCurrentFrame.mvpMapPoints[i]) |
| 2753 | { |
| 2754 | if(mCurrentFrame.mvbOutlier[i]) |
| 2755 | { |
| 2756 | MapPoint* pMP = mCurrentFrame.mvpMapPoints[i]; |
| 2757 | |
| 2758 | mCurrentFrame.mvpMapPoints[i]=static_cast<MapPoint*>(NULL); |
| 2759 | mCurrentFrame.mvbOutlier[i]=false; |
| 2760 | if(i < mCurrentFrame.Nleft){ |
| 2761 | pMP->mbTrackInView = false; |
| 2762 | } |
| 2763 | else{ |
| 2764 | pMP->mbTrackInViewR = false; |
| 2765 | } |
| 2766 | pMP->mbTrackInView = false; |
| 2767 | pMP->mnLastFrameSeen = mCurrentFrame.mnId; |
| 2768 | nmatches--; |
| 2769 | } |
| 2770 | else if(mCurrentFrame.mvpMapPoints[i]->Observations()>0) |
| 2771 | nmatchesMap++; |
| 2772 | } |
| 2773 | } |
| 2774 | |
| 2775 | if (mSensor == System::IMU_MONOCULAR || mSensor == System::IMU_STEREO || mSensor == System::IMU_RGBD) |
| 2776 | return true; |
| 2777 | else |
nothing calls this directly
no test coverage detected