| 2779 | } |
| 2780 | |
| 2781 | void Tracking::UpdateLastFrame() |
| 2782 | { |
| 2783 | // Update pose according to reference keyframe |
| 2784 | KeyFrame* pRef = mLastFrame.mpReferenceKF; |
| 2785 | Sophus::SE3f Tlr = mlRelativeFramePoses.back(); |
| 2786 | mLastFrame.SetPose(Tlr * pRef->GetPose()); |
| 2787 | |
| 2788 | if(mnLastKeyFrameId==mLastFrame.mnId || mSensor==System::MONOCULAR || mSensor==System::IMU_MONOCULAR || !mbOnlyTracking) |
| 2789 | return; |
| 2790 | |
| 2791 | // Create "visual odometry" MapPoints |
| 2792 | // We sort points according to their measured depth by the stereo/RGB-D sensor |
| 2793 | vector<pair<float,int> > vDepthIdx; |
| 2794 | const int Nfeat = mLastFrame.Nleft == -1? mLastFrame.N : mLastFrame.Nleft; |
| 2795 | vDepthIdx.reserve(Nfeat); |
| 2796 | for(int i=0; i<Nfeat;i++) |
| 2797 | { |
| 2798 | float z = mLastFrame.mvDepth[i]; |
| 2799 | if(z>0) |
| 2800 | { |
| 2801 | vDepthIdx.push_back(make_pair(z,i)); |
| 2802 | } |
| 2803 | } |
| 2804 | |
| 2805 | if(vDepthIdx.empty()) |
| 2806 | return; |
| 2807 | |
| 2808 | sort(vDepthIdx.begin(),vDepthIdx.end()); |
| 2809 | |
| 2810 | // We insert all close points (depth<mThDepth) |
| 2811 | // If less than 100 close points, we insert the 100 closest ones. |
| 2812 | int nPoints = 0; |
| 2813 | for(size_t j=0; j<vDepthIdx.size();j++) |
| 2814 | { |
| 2815 | int i = vDepthIdx[j].second; |
| 2816 | |
| 2817 | bool bCreateNew = false; |
| 2818 | |
| 2819 | MapPoint* pMP = mLastFrame.mvpMapPoints[i]; |
| 2820 | |
| 2821 | if(!pMP) |
| 2822 | bCreateNew = true; |
| 2823 | else if(pMP->Observations()<1) |
| 2824 | bCreateNew = true; |
| 2825 | |
| 2826 | if(bCreateNew) |
| 2827 | { |
| 2828 | Eigen::Vector3f x3D; |
| 2829 | |
| 2830 | if(mLastFrame.Nleft == -1){ |
| 2831 | mLastFrame.UnprojectStereo(i, x3D); |
| 2832 | } |
| 2833 | else{ |
| 2834 | x3D = mLastFrame.UnprojectStereoFishEye(i); |
| 2835 | } |
| 2836 | |
| 2837 | MapPoint* pNewMP = new MapPoint(x3D,mpAtlas->GetCurrentMap(),&mLastFrame,i); |
| 2838 | mLastFrame.mvpMapPoints[i]=pNewMP; |
nothing calls this directly
no test coverage detected