slam_calibrator.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2013, Alex Teichman and Stephen Miller (Stanford University)
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the <organization> nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 RTAB-Map integration: Mathieu Labbe
00028 */
00029 
00030 #include "rtabmap/core/clams/slam_calibrator.h"
00031 #include "rtabmap/core/clams/frame_projector.h"
00032 #include <rtabmap/utilite/ULogger.h>
00033 
00034 using namespace std;
00035 using namespace Eigen;
00036 
00037 namespace clams
00038 {
00039 
00040   DiscreteDepthDistortionModel calibrate(
00041                   const std::map<int, rtabmap::SensorData> & sequence,
00042           const std::map<int, rtabmap::Transform> & trajectory,
00043                   const pcl::PointCloud<pcl::PointXYZ>::Ptr & map,
00044                   double coneRadius,
00045                   double coneStdevThresh)
00046 {
00047         DiscreteDepthDistortionModel model;
00048 
00049         if(!sequence.empty())
00050         {
00051                 const cv::Size & imageSize = sequence.begin()->second.cameraModels()[0].imageSize();
00052                 model = DiscreteDepthDistortionModel(imageSize.width, imageSize.height);
00053 
00054                 // -- For all selected frames, accumulate training examples
00055                 //    in the distortion model.
00056                 size_t counts = 0;
00057                 //#pragma omp parallel for // error on linux
00058                 for(std::map<int, rtabmap::Transform>::const_iterator iter = trajectory.begin(); iter != trajectory.end(); ++iter)
00059                 {
00060                   size_t idx = iter->first;
00061                   std::map<int, rtabmap::SensorData>::const_iterator ster = sequence.find(idx);
00062                   if(ster!=sequence.end())
00063                   {
00064                           cv::Mat depthImage;
00065                           ster->second.uncompressDataConst(0, &depthImage);
00066 
00067                           cv::Mat mapDepth;
00068                           FrameProjector projector(ster->second.cameraModels()[0]);
00069                           mapDepth = projector.estimateMapDepth(map, iter->second.inverse(), depthImage, coneRadius, coneStdevThresh);
00070                           counts = model.accumulate(mapDepth, depthImage);
00071                   }
00072                 }
00073                 UINFO("counts=%d", (int)counts);
00074         }
00075         return model;
00076 }
00077 
00078 }  // namespace clams


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:22