本文整理汇总了C++中KeyFrame::GetRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyFrame::GetRotation方法的具体用法?C++ KeyFrame::GetRotation怎么用?C++ KeyFrame::GetRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyFrame
的用法示例。
在下文中一共展示了KeyFrame::GetRotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matcher
//.........这里部分代码省略.........
cv::Mat Scm = pSolver->iterate(5,bNoMore,vbInliers,nInliers);
// If Ransac reachs max. iterations discard keyframe
if(bNoMore)
{
vbDiscarded[i]=true;
nCandidates--;
}
// If RANSAC returns a Sim3, perform a guided matching and optimize with all correspondences
if(!Scm.empty())
{
vector<MapPoint*> vpMapPointMatches(vvpMapPointMatches[i].size(), static_cast<MapPoint*>(NULL));
for(size_t j=0, jend=vbInliers.size(); j<jend; j++)
{
if(vbInliers[j])
vpMapPointMatches[j]=vvpMapPointMatches[i][j];
}
cv::Mat R = pSolver->GetEstimatedRotation();
cv::Mat t = pSolver->GetEstimatedTranslation();
const float s = pSolver->GetEstimatedScale();
matcher.SearchBySim3(mpCurrentKF,pKF,vpMapPointMatches,s,R,t,7.5);
g2o::Sim3 gScm(Converter::toMatrix3d(R),Converter::toVector3d(t),s);
const int nInliers = Optimizer::OptimizeSim3(mpCurrentKF, pKF, vpMapPointMatches, gScm, 10);
// If optimization is succesful stop ransacs and continue
if(nInliers>=20)
{
bMatch = true;
mpMatchedKF = pKF;
g2o::Sim3 gSmw(Converter::toMatrix3d(pKF->GetRotation()),Converter::toVector3d(pKF->GetTranslation()),1.0);
mg2oScw = gScm*gSmw;
mScw = Converter::toCvMat(mg2oScw);
mvpCurrentMatchedPoints = vpMapPointMatches;
break;
}
}
}
}
if(!bMatch)
{
for(int i=0; i<nInitialCandidates; i++)
mvpEnoughConsistentCandidates[i]->SetErase();
mpCurrentKF->SetErase();
return false;
}
// Retrieve MapPoints seen in Loop Keyframe and neighbors
vector<KeyFrame*> vpLoopConnectedKFs = mpMatchedKF->GetVectorCovisibleKeyFrames();
vpLoopConnectedKFs.push_back(mpMatchedKF);
mvpLoopMapPoints.clear();
for(vector<KeyFrame*>::iterator vit=vpLoopConnectedKFs.begin(); vit!=vpLoopConnectedKFs.end(); vit++)
{
KeyFrame* pKF = *vit;
vector<MapPoint*> vpMapPoints = pKF->GetMapPointMatches();
for(size_t i=0, iend=vpMapPoints.size(); i<iend; i++)
{
MapPoint* pMP = vpMapPoints[i];
if(pMP)
{
if(!pMP->isBad() && pMP->mnLoopPointForKF!=mpCurrentKF->mnId)
示例2: main
int main(int argc, char** argv)
{
VideoCapture cap(string(KAI_PATH).append("shield_vid.mp4"));
// VideoCapture cap(string(KAI_PATH).append("indoor.mov"));
// VideoCapture cap(string(MOHIT_PATH).append("indoor.avi"));
// VideoCapture cap("/Users/MohitSridhar/Downloads/kitti_youtube.avi");
// VideoCapture cap("/Users/MohitSridhar/Downloads/VID_20150530_120719.mp4");
if (!cap.isOpened())
{
cout << "failed to open video file" << endl;
return -1;
}
// Initialize visualizer and load initial map
Ptr<VisualizerListener> visualizerListener = new VisualizerListener;
InitializeVisualizer();
RunVisualizationOnly();
// Initialize SLAM
Mat frame;
Size size(640, 480);
vslam::VSlam slam = vslam::VSlam();
while (true) {
cap >> frame;
if (frame.empty()) {
break;
}
resize(frame, frame, size);
clock_t start = clock();
slam.ProcessFrame(frame);
clock_t end = clock();
double processFrameDuration = (end - start) / (double) CLOCKS_PER_SEC;
cout << "processFrameDuration: " << processFrameDuration << endl;
if (waitKey(30) == 27) {
break;
}
// Update visualizer
visualizerListener->update(slam.GetKeyFrames(), slam.GetCameraRot().back(), slam.
GetCameraPose().back());
RunVisualizationOnly();
// Draw translation and rotation information
Augmentor augmentor;
KeyFrame currKeyFrame = slam.GetCurrKeyFrame();
Mat translationMatrix = currKeyFrame.GetTranslation();
augmentor.DisplayTranslation(frame, translationMatrix);
Mat rotationMatrix = currKeyFrame.GetRotation();
augmentor.DisplayRotation(frame, rotationMatrix);
// Draw keypoints
KeypointArray keypoints = currKeyFrame.GetTrackedKeypoints();
Mat trackedFeatures;
Scalar kpColor = Scalar(255, 0, 0);
drawKeypoints(frame, keypoints, trackedFeatures, kpColor);
imshow("Tracked Features", trackedFeatures);
}
waitKey(0);
WaitForVisualizationThread();
return 0;
}