All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GTFilter.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/GTFilter.cpp
22 
23  \brief 2D Geometric transformation outliers remotion filter.
24 */
25 
26 // TerraLib
27 #include "../common/PlatformUtils.h"
28 #include "GTFactory.h"
29 #include "GTFilter.h"
30 #include "MultiPoint.h"
31 #include "Point.h"
32 #include "Surface.h"
33 
34 // STL
35 #include <cmath>
36 #include <cstdlib>
37 #include <limits>
38 #include <memory>
39 
40 // boost
41 #include <boost/math/special_functions/binomial.hpp>
42 #include <boost/random.hpp>
43 
44 #define RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations ) \
45  std::max( \
46  (RansacIntegerCounterT)1 \
47  , \
48  ( \
49  (RansacIntegerCounterT)( \
50  ((RansacFloatCounterT)dynamicMaxIterations) \
51  * \
52  ((RansacFloatCounterT)assurance) \
53  ) \
54  ) \
55  ) \
56 
57 #define RANSACGETMAXITERATIONS( goodTPNumber, totalTPNumber, modelRequiredTPNumber, procsNumber, assurance ) \
58  ( \
59  ( \
60  (RansacIntegerCounterT) \
61  ( \
62  std::log( \
63  (RansacFloatCounterT)( 1.0 - ((RansacFloatCounterT)assurance) ) \
64  ) \
65  / \
66  std::log( \
67  ((RansacFloatCounterT)1.0) \
68  - \
69  std::pow( \
70  ( \
71  ((RansacFloatCounterT)goodTPNumber ) \
72  / \
73  ((RansacFloatCounterT)totalTPNumber) \
74  ) \
75  , \
76  ((RansacFloatCounterT)modelRequiredTPNumber) \
77  ) \
78  ) \
79  ) \
80  ) \
81  / \
82  ((RansacIntegerCounterT)procsNumber) \
83  ) \
84 
85  #define RANSACSYNCTHREAD \
86  { \
87  mutex.lock(); \
88  if( bestTransfPtr->initialize( bestParams ) ) \
89  { \
90  if( \
91  ( paramsPtr->m_bestTransformationPtrPtr->get() == 0 ) \
92  || \
93  ( \
94  ( bestTiePoins.size() > \
95  (*paramsPtr->m_bestTransformationPtrPtr)->getParameters().m_tiePoints.size() ) \
96  || \
97  ( \
98  ( bestTiePoins.size() == \
99  (*paramsPtr->m_bestTransformationPtrPtr)->getParameters().m_tiePoints.size() ) \
100  && \
101  ( \
102  ( bestParamsConvexHullArea > (*paramsPtr->m_bestParamsConvexHullAreaPtr) ) \
103  || \
104  ( \
105  ( bestParamsConvexHullArea == (*paramsPtr->m_bestParamsConvexHullAreaPtr) ) \
106  && \
107  ( \
108  ( bestParamsMaxDMapErrorPtr < (*paramsPtr->m_bestParamsMaxDMapErrorPtr) ) \
109  && \
110  ( bestParamsMaxIMapErrorPtr < (*paramsPtr->m_bestParamsMaxIMapErrorPtr) ) \
111  ) \
112  ) \
113  ) \
114  ) \
115  ) \
116  ) \
117  { \
118  (*paramsPtr->m_bestTransformationPtrPtr).reset( \
119  bestTransfPtr->clone() ); \
120  (*paramsPtr->m_bestParamsMaxDMapErrorPtr) = bestParamsMaxDMapErrorPtr; \
121  (*paramsPtr->m_bestParamsMaxIMapErrorPtr) = bestParamsMaxIMapErrorPtr; \
122  (*paramsPtr->m_bestParamsConvexHullAreaPtr) = bestParamsConvexHullArea; \
123  (*paramsPtr->m_bestTiePoinsPtr) = bestTiePoins; \
124  } \
125  } \
126  if( dynamicMaxIterations < globalDynamicMaxIterations ) \
127  globalDynamicMaxIterations = dynamicMaxIterations; \
128  mutex.unlock(); \
129  };
130 
131 // ---------------------------------------------------------------------------
132 
134 {
135  m_transfNamePtr = 0;
136  m_inputGTParamsPtr = 0;
137  m_maxDirectMapError = 0.0;
138  m_maxInverseMapError = 0.0;
139  m_assurance = 0.0;
142  m_procsNumber = 1;
143  m_returnValuePtr = 0;
144  m_mutexPtr = 0;
146  m_tpsMapPtr = 0;
151  m_bestTiePoinsPtr = 0;
152 }
153 
156 {
157  operator=( other );
158 }
159 
161 {
162 }
163 
167 {
168  m_transfNamePtr = other.m_transfNamePtr;
169  m_inputGTParamsPtr = other.m_inputGTParamsPtr;
170  m_maxDirectMapError = other.m_maxDirectMapError;
171  m_maxInverseMapError = other.m_maxInverseMapError;
172  m_assurance = other.m_assurance;
173  m_useDynamicIterationsNumber = other.m_useDynamicIterationsNumber;
174  m_dynamicMaxIterationsPtr = other.m_dynamicMaxIterationsPtr;
175  m_procsNumber = other.m_procsNumber;
176  m_returnValuePtr = other.m_returnValuePtr;
177  m_mutexPtr = other.m_mutexPtr;
178  m_keepRunningFlagPtr = other.m_keepRunningFlagPtr;
179  m_tpsMapPtr = other.m_tpsMapPtr;
180  m_bestTransformationPtrPtr = other.m_bestTransformationPtrPtr;
181  m_bestParamsMaxDMapErrorPtr = other.m_bestParamsMaxDMapErrorPtr;
182  m_bestParamsMaxIMapErrorPtr = other.m_bestParamsMaxIMapErrorPtr;
183  m_bestParamsConvexHullAreaPtr = other.m_bestParamsConvexHullAreaPtr;
184  m_bestTiePoinsPtr = other.m_bestTiePoinsPtr;
185 
186  return other;
187 }
188 
189 // ---------------------------------------------------------------------------
190 
192 {
193 }
194 
196 {
197 }
198 
199 bool te::gm::GTFilter::applyRansac(const std::string& transfName,
200  const GTParameters& inputParams,
201  const double maxDirectMapError,
202  const double maxInverseMapError,
203  const RansacIntegerCounterT& maxIterations,
204  const double& assurance,
205  const bool enableMultiThread,
206  const std::vector<double>& tiePointsWeights,
207  std::vector< te::gm::GTParameters::TiePoint >& outTiePoints,
208  std::auto_ptr< GeometricTransformation >& outTransf
209  )
210 {
211  if(maxDirectMapError < 0)
212  return false;
213 
214  if(maxInverseMapError < 0)
215  return false;
216 
217  if((assurance <= 0.0) || (assurance > 1.0))
218  return false;
219 
220  outTiePoints.clear();
221  outTransf.reset();
222 
223  // generating the tie-points accumulated probabilities map
224  // with positive values between 0 and 1
225  std::map< double, GTParameters::TiePoint > tpsMap;
226  {
227  const unsigned int inputTPNmb = (unsigned int)
228  inputParams.m_tiePoints.size();
229  double tiePointsWeightsSum = 0;
230 
231  if( tiePointsWeights.size() > 0 )
232  {
233  if( tiePointsWeights.size() != inputParams.m_tiePoints.size () )
234  return false;
235 
236  // finding normalization factors
237 
238  unsigned int tpIdx = 0;
239 
240  for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
241  {
242  if( tiePointsWeights[ tpIdx ] < 0.0 ) return false;
243 
244  tiePointsWeightsSum += tiePointsWeights[ tpIdx ];
245  }
246 
247  if( tiePointsWeightsSum <= 0.0 ) return false;
248 
249  // map fill
250 
251  double newWSum = 0.0;
252  double newW = 0.0;
253 
254  for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
255  {
256  newW = tiePointsWeights[ tpIdx ];
257  newW /= tiePointsWeightsSum;
258 
259  newWSum += newW;
260 
261  tpsMap[ newWSum ] = inputParams.m_tiePoints[ tpIdx ];
262  }
263  }
264  else
265  {
266  double wSum = 0;
267  const double increment = 1.0 /
268  ( (double)inputParams.m_tiePoints.size() );
269 
270  for( unsigned int tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
271  {
272  wSum += increment;
273  tpsMap[ wSum ] = inputParams.m_tiePoints[ tpIdx ];
274  }
275  }
276  }
277 
278  // creating global execution parameters
279 
280  std::auto_ptr< GeometricTransformation > bestTransformationPtr(
281  te::gm::GTFactory::make( transfName ) );
282  if( bestTransformationPtr.get() == 0 ) return false;
283 
284  const unsigned int procsNumber = te::common::GetPhysProcNumber();
285  boost::mutex syncMutex;
286  double bestParamsMaxDMapError = maxDirectMapError;
287  double bestParamsMaxIMapError = maxInverseMapError;
288  double bestParamsConvexHullArea = -1.0;
289  bool returnValue = true;
290  bool keepRunningFlag = true;
291  RansacIntegerCounterT dynamicMaxIterations =
292  maxIterations ?
293  (
294  maxIterations
295  /
296  (
297  enableMultiThread ? procsNumber : 1
298  )
299  )
300  :
302  bestTransformationPtr->getMinRequiredTiePoints(),
303  inputParams.m_tiePoints.size(),
304  bestTransformationPtr->getMinRequiredTiePoints(),
305  enableMultiThread ? procsNumber : 1,
306  assurance );
307 
308  ApplyRansacThreadEntryThreadParams baseThreadParams;
309  baseThreadParams.m_transfNamePtr = &transfName;
310  baseThreadParams.m_inputGTParamsPtr = &inputParams;
311  baseThreadParams.m_maxDirectMapError = maxDirectMapError;
312  baseThreadParams.m_maxInverseMapError = maxInverseMapError;
313  baseThreadParams.m_assurance = assurance;
314  baseThreadParams.m_useDynamicIterationsNumber = ( maxIterations == 0 );
315  baseThreadParams.m_dynamicMaxIterationsPtr = &dynamicMaxIterations;
316  baseThreadParams.m_procsNumber = enableMultiThread ?
317  ((RansacIntegerCounterT)procsNumber) : 1;
318  baseThreadParams.m_returnValuePtr = &returnValue;
319  baseThreadParams.m_mutexPtr = &syncMutex;
320  baseThreadParams.m_keepRunningFlagPtr = &keepRunningFlag;
321  baseThreadParams.m_tpsMapPtr = &tpsMap;
322  baseThreadParams.m_bestTransformationPtrPtr = &bestTransformationPtr;
323  baseThreadParams.m_bestParamsMaxDMapErrorPtr = &bestParamsMaxDMapError;
324  baseThreadParams.m_bestParamsMaxIMapErrorPtr = &bestParamsMaxIMapError;
325  baseThreadParams.m_bestParamsConvexHullAreaPtr = &bestParamsConvexHullArea;
326  baseThreadParams.m_bestTiePoinsPtr = &outTiePoints;
327 
328  // Calling the ransac thread entry
329 
330  if( enableMultiThread )
331  {
332  std::vector< ApplyRansacThreadEntryThreadParams > threadsParameters;
333  threadsParameters.resize( procsNumber, baseThreadParams );
334  boost::thread_group threads;
335 
336  for( unsigned int threadIdx = 0 ; threadIdx < procsNumber ;
337  ++threadIdx )
338  {
339  threads.add_thread( new boost::thread( applyRansacThreadEntry,
340  &threadsParameters[ threadIdx ] ) );
341  }
342 
343  threads.join_all();
344  }
345  else
346  {
347  applyRansacThreadEntry( &baseThreadParams );
348  }
349 
350  if( returnValue )
351  {
352  if( bestTransformationPtr.get() )
353  {
354  outTransf.reset( bestTransformationPtr.release() );
355  return true;
356  }
357  else
358  {
359  return false;
360  }
361  }
362  else
363  {
364  return false;
365  }
366 }
367 
369 {
370  assert( paramsPtr->m_procsNumber > 0 );
371 
372  // accessing global shared objects
373 
374  paramsPtr->m_mutexPtr->lock();
375 
376  std::auto_ptr< te::gm::GeometricTransformation > bestTransfPtr(
377  te::gm::GTFactory::make( *paramsPtr->m_transfNamePtr ) );
378  if( bestTransfPtr.get() == 0 )
379  {
380  *(paramsPtr->m_returnValuePtr) = false;
381  *(paramsPtr->m_keepRunningFlagPtr) = false;
382  paramsPtr->m_mutexPtr->unlock();
383  return;
384  }
385 
386  const std::vector< te::gm::GTParameters::TiePoint > tiePoints =
387  paramsPtr->m_inputGTParamsPtr->m_tiePoints;
388  std::map< double, GTParameters::TiePoint > tpsMap = *(paramsPtr->m_tpsMapPtr);
389 
390  // initializing the random number generator to assure that each thread has
391  // a different seed
392  boost::random::mt19937 generator( (boost::random::mt19937::result_type)time(0) );
393 
394  paramsPtr->m_mutexPtr->unlock();
395 
396  // external globals
397 
398  const RansacIntegerCounterT& procsNumber = paramsPtr->m_procsNumber;
399  const double& maxDirectMapError = paramsPtr->m_maxDirectMapError;
400  const double& maxInverseMapError = paramsPtr->m_maxInverseMapError;
401  bool& keepRunningFlag = (*(paramsPtr->m_keepRunningFlagPtr));
402  const double& assurance = paramsPtr->m_assurance;
403  const bool& useDynamicIterationsNumber = paramsPtr->m_useDynamicIterationsNumber;
404  RansacIntegerCounterT& globalDynamicMaxIterations = (*(paramsPtr->m_dynamicMaxIterationsPtr));
405  boost::mutex& mutex = (*(paramsPtr->m_mutexPtr));
406 
407  // Checking the number of required tie-points
408 
409  const unsigned int reqTPsNmb = bestTransfPtr->getMinRequiredTiePoints();
410  const unsigned int inputTPNmb = (unsigned int)tiePoints.size();
411 
412  if( inputTPNmb < reqTPsNmb )
413  {
414  mutex.lock();
415  *(paramsPtr->m_returnValuePtr) = false;
416  *(paramsPtr->m_keepRunningFlagPtr) = false;
417  mutex.unlock();
418  return;
419  }
420 
421  // best parameters found by this thread
422 
423  GTParameters bestParams;
424  double bestParamsMaxDMapErrorPtr = paramsPtr->m_maxDirectMapError;
425  double bestParamsMaxIMapErrorPtr = paramsPtr->m_maxInverseMapError;
426  double bestParamsConvexHullArea = -1.0;
427  std::vector< te::gm::GTParameters::TiePoint > bestTiePoins;
428 
429  // variables used by the ransac loop
430 
431  boost::random::uniform_01< double > distribution;
432 
433  GTParameters consensusSetParams;
434  std::vector< te::gm::GTParameters::TiePoint > consensusSetTiePoints;
435  consensusSetParams.m_tiePoints.reserve( tiePoints.size() );
436  double consensusSetMaxDMapError = 0;
437  double consensusSetMaxIMapError = 0;
438  unsigned int consensusSetSize = 0;
439  double consensusSetConvexHullArea = 0.0;
440  std::vector< Coord2D > consensusSetPt1ConvexHullPoits;
441 
442  double tiePointDMapErr = 0;
443  double tiePointIMapErr = 0;
444 
445  std::map< double, GTParameters::TiePoint >::const_iterator tpsMapIt;
446  unsigned int inputTpIdx = 0;
447 
448  RansacIntegerCounterT selectedTpsCounter = 0;
449  std::vector< GTParameters::TiePoint* > selectedTpsPtrsVec;
450  selectedTpsPtrsVec.resize( reqTPsNmb, 0 );
451  unsigned int selectedTpsPtrsVecIdx = 0;
452  bool selectedTpsNotSelectedBefore = false;
453  RansacIntegerCounterT currentIteration = 0;
454 
455  RansacIntegerCounterT dynamicMaxIterations = globalDynamicMaxIterations;
456  RansacIntegerCounterT dynamicMaxConsecutiveInvalidIterations =
457  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
458  const RansacIntegerCounterT threadSyncMaxIterations = procsNumber;
459  RansacIntegerCounterT threadSyncIteration = 0;
460 
461  RansacIntegerCounterT consecutiveInvalidIterations = 0;
462  double randomValue = 0;
463 
464  while( keepRunningFlag && ( currentIteration < dynamicMaxIterations ) &&
465  ( consecutiveInvalidIterations < dynamicMaxConsecutiveInvalidIterations ) )
466  {
467  // Trying to find a valid base consensus set
468  // with the minimum number of required tie-points
469  // Random selecting n distinc tpoints from the original set
470 
471  consensusSetParams.reset();;
472  selectedTpsCounter = 0;
473 
474  while( selectedTpsCounter < reqTPsNmb )
475  {
476  randomValue = distribution( generator );
477  tpsMapIt = tpsMap.upper_bound( randomValue );
478  assert( tpsMapIt != tpsMap.end() );
479 
480  // Checking if this TP was already selected before
481 
482  selectedTpsNotSelectedBefore = true;
483 
484  for( selectedTpsPtrsVecIdx = 0 ; selectedTpsPtrsVecIdx <
485  selectedTpsCounter ; ++selectedTpsPtrsVecIdx )
486  {
487  if( selectedTpsPtrsVec[ selectedTpsPtrsVecIdx ] ==
488  &(tpsMapIt->second) )
489  {
490  selectedTpsNotSelectedBefore = false;
491  break;
492  }
493  }
494 
495  if( selectedTpsNotSelectedBefore )
496  {
497  consensusSetParams.m_tiePoints.push_back( tpsMapIt->second );
498  }
499 
500  ++selectedTpsCounter;
501  }
502 
503  /* Trying to generate a valid base consensus transformation with the
504  selected points */
505 
506  if( bestTransfPtr->computeParameters( consensusSetParams ) )
507  {
508  // finding those tie-points in agreement with the generated
509  // consensus basic transformation
510 
511  consensusSetTiePoints.clear();
512  consensusSetMaxDMapError = 0;
513  consensusSetMaxIMapError = 0;
514 
515  for( inputTpIdx = 0 ; inputTpIdx < inputTPNmb ; ++inputTpIdx )
516  {
517  const GTParameters::TiePoint& curTP = tiePoints[ inputTpIdx ];
518 
519  tiePointDMapErr = bestTransfPtr->getDirectMappingError( curTP, consensusSetParams );
520  tiePointIMapErr = bestTransfPtr->getInverseMappingError( curTP, consensusSetParams );
521 
522  if( ( tiePointDMapErr <= maxDirectMapError ) &&
523  ( tiePointIMapErr <= maxInverseMapError ) )
524  {
525  consensusSetTiePoints.push_back( curTP );
526 
527  if( tiePointDMapErr > consensusSetMaxDMapError )
528  consensusSetMaxDMapError = tiePointDMapErr;
529  if( tiePointIMapErr > consensusSetMaxIMapError )
530  consensusSetMaxIMapError = tiePointIMapErr;
531  }
532  }
533 
534  consensusSetSize = (unsigned int)consensusSetTiePoints.size();
535  consensusSetConvexHullArea = getPt1ConvexHullArea(
536  consensusSetTiePoints );
537 
538  /* Is this an acceptable consensus set ?? */
539 
540  if(
541  ( consensusSetSize >= reqTPsNmb )
542  &&
543  (
544  ( consensusSetSize > bestTiePoins.size() )
545  ||
546  (
547  ( consensusSetSize == bestTiePoins.size() )
548  &&
549  (
550  ( consensusSetConvexHullArea > bestParamsConvexHullArea )
551  ||
552  (
553  ( consensusSetConvexHullArea == bestParamsConvexHullArea )
554  &&
555  (
556  ( bestParamsMaxDMapErrorPtr > consensusSetMaxDMapError )
557  &&
558  ( bestParamsMaxIMapErrorPtr > consensusSetMaxIMapError )
559  )
560  )
561  )
562  )
563  )
564  )
565  {
566  bestParams = consensusSetParams;
567  bestParamsMaxDMapErrorPtr = consensusSetMaxDMapError;
568  bestParamsMaxIMapErrorPtr = consensusSetMaxIMapError;
569  bestParamsConvexHullArea = consensusSetConvexHullArea;
570  bestTiePoins = consensusSetTiePoints;
571 
572  consecutiveInvalidIterations = 0;
573  }
574  else
575  {
576  ++consecutiveInvalidIterations;
577  }
578  }
579  else
580  {
581  ++consecutiveInvalidIterations;
582  };
583 
584  // Updating iteration related variables
585 
586  if( useDynamicIterationsNumber && ( currentIteration != 0 ) )
587  {
588  if( bestTiePoins.size() == inputTPNmb )
589  {
590  mutex.lock();
591 
592  keepRunningFlag = false;
593 
594  mutex.unlock();
595 
596  break;
597  }
598  else if( ! bestTiePoins.empty() )
599  {
600  const RansacIntegerCounterT dynamicMaxIterationsEstimation = RANSACGETMAXITERATIONS(
601  bestTiePoins.size(),
602  inputTPNmb,
603  reqTPsNmb,
604  procsNumber,
605  assurance );
606 
607  if( dynamicMaxIterationsEstimation < dynamicMaxIterations )
608  {
609  dynamicMaxIterations =
610  ( dynamicMaxIterations - ( ( dynamicMaxIterations - dynamicMaxIterationsEstimation ) / 2 ) );
611 
612  dynamicMaxConsecutiveInvalidIterations =
613  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
614  }
615 
616  if( globalDynamicMaxIterations < dynamicMaxIterations )
617  {
618  dynamicMaxIterations = globalDynamicMaxIterations;
619 
620  dynamicMaxConsecutiveInvalidIterations =
621  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
622  }
623  }
624  }
625 
626  // Sync with the other threads
627 
628  if(
629  ( threadSyncIteration >= threadSyncMaxIterations )
630  ||
631  ( currentIteration >= dynamicMaxIterations )
632  ||
633  ( consecutiveInvalidIterations >= dynamicMaxConsecutiveInvalidIterations )
634  )
635  {
636  threadSyncIteration = 0;
637 
639  }
640 
641  ++threadSyncIteration;
642  ++currentIteration;
643  }
644 
645  // Sync the final result
646 
648 }
649 
650 double te::gm::GTFilter::getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint >& tiePoints)
651 {
652  if( tiePoints.size() < 3 )
653  {
654  return 0;
655  }
656  else
657  {
659 
660  for( unsigned int tiePointsIdx = 0 ; tiePointsIdx < tiePoints.size() ;
661  ++tiePointsIdx )
662  {
663  points.add( new te::gm::Point( tiePoints[ tiePointsIdx ].first.x,
664  tiePoints[ tiePointsIdx ].first.y ) );
665  }
666 
667  std::auto_ptr< te::gm::Geometry > convexHullPtr( points.convexHull() );
668 
669  if( dynamic_cast< te::gm::Surface* >( convexHullPtr.get() ) )
670  {
671  return dynamic_cast< te::gm::Surface* >( convexHullPtr.get() )->getArea();
672  }
673  else
674  {
675  return 0;
676  }
677  }
678 }
static double getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint > &tiePoints)
Returns the tie-points convex hull area (GTParameters::TiePoint::first).
Definition: GTFilter.cpp:650
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
GTFilter()
Default constructor.
Definition: GTFilter.cpp:195
unsigned long int RansacIntegerCounterT
RANSAC integer counter type.
Definition: GTFilter.h:57
A point with x and y coordinate values.
std::map< double, GTParameters::TiePoint > const * m_tpsMapPtr
A map from accumulated probabilities (normalized between 0 and 1) to tie-points data.
Definition: GTFilter.h:120
MultiPoint is a GeometryCollection whose elements are restricted to points.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
bool applyRansac(const std::string &transfName, const GTParameters &inputParams, const double maxDirectMapError, const double maxInverseMapError, const RansacIntegerCounterT &maxIterations, const double &assurance, const bool enableMultiThread, const std::vector< double > &tiePointsWeights, std::vector< te::gm::GTParameters::TiePoint > &outTiePoints, std::auto_ptr< GeometricTransformation > &outTransf)
Apply a RANSAC based outliers remotion strategy.
Definition: GTFilter.cpp:199
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors.
std::vector< te::gm::GTParameters::TiePoint > * m_bestTiePoinsPtr
Definition: GTFilter.h:125
~GTFilter()
Destructor.
Definition: GTFilter.cpp:191
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
#define RANSACGETMAXINVALIDITERATIONS(assurance, dynamicMaxIterations)
Definition: GTFilter.cpp:44
Parameters used by the GTFilter::applyRansacThreadEntry method.
Definition: GTFilter.h:105
A point with x and y coordinate values.
Definition: Point.h:50
#define RANSACGETMAXITERATIONS(goodTPNumber, totalTPNumber, modelRequiredTPNumber, procsNumber, assurance)
Definition: GTFilter.cpp:57
2D Geometric transformation outliers remotion filter.
Surface is an abstract class that represents a 2-dimensional geometric objects.
const ApplyRansacThreadEntryThreadParams & operator=(const ApplyRansacThreadEntryThreadParams &other)
Definition: GTFilter.cpp:165
#define RANSACSYNCTHREAD
Definition: GTFilter.cpp:85
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
static void applyRansacThreadEntry(te::gm::GTFilter::ApplyRansacThreadEntryThreadParams *paramsPtr)
Surf locator thread entry.
Definition: GTFilter.cpp:368
void add(Geometry *g)
It adds the geometry into the collection.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
std::auto_ptr< GeometricTransformation > * m_bestTransformationPtrPtr
Definition: GTFilter.h:121
2D Geometric transformation factory.
virtual Geometry * convexHull() const
This method calculates the Convex Hull of a geometry.
Definition: Geometry.cpp:505
2D Geometric transformation parameters.
Definition: GTParameters.h:50
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54