FernPoseEstimator.cpp
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #include "FernPoseEstimator.h"
00025 
00026 namespace alvar {
00027 
00028 FernPoseEstimator::FernPoseEstimator()
00029     : mPose()
00030     , mCamera()
00031     , mCameraEC()
00032 {
00033 }
00034 
00035 FernPoseEstimator::~FernPoseEstimator()
00036 {
00037 }
00038 
00039 Pose FernPoseEstimator::pose() const
00040 {
00041         return mPose;
00042 }
00043 
00044 Camera FernPoseEstimator::camera() const
00045 {
00046         return mCamera;
00047 }
00048 
00049 bool FernPoseEstimator::setCalibration(const std::string &filename, int width, int height)
00050 {
00051     bool r1 = mCamera.SetCalib(filename.c_str(), width, height);
00052         bool r2 = mCameraEC.SetCalib(filename.c_str(), width, height);
00053     return r1 && r2;
00054 }
00055 
00056 void FernPoseEstimator::setResolution(int width, int height)
00057 {
00058     mCamera.SetRes(width, height);
00059         mCameraEC.SetRes(width, height);
00060 }
00061 
00062 void FernPoseEstimator::calculateFromPointCorrespondences(FernPoseEstimator::ModelPointVector &mpts, FernPoseEstimator::ImagePointVector &ipts)
00063 {
00064         mCamera.CalcExteriorOrientation(mpts, ipts, &mPose); // TODO replace camera->cameraec
00065 }
00066 
00067 void FernPoseEstimator::updateFromTrackedPoints(FernPoseEstimator::ExternalContainerMap &container)
00068 {
00069         mCameraEC.UpdatePose(container, &mPose);
00070 }
00071 
00072 void FernPoseEstimator::extractPlaneCoordinates(FernPoseEstimator::ExternalContainerMap &container)
00073 {
00074         ExternalContainerMap::iterator iter = container.begin();
00075         ExternalContainerMap::iterator iter_end = container.end();
00076         for(; iter != iter_end; ++iter) {
00077                 alvar::ExternalContainer &f = iter->second;
00078                 mCameraEC.Get3dOnPlane(&mPose, f.p2d, f.p3d);
00079                 f.has_p3d = true;
00080         }
00081 }
00082 
00083 } // namespace alvar


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Thu Jun 6 2019 21:12:54