All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GTFilter.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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  (RansacItCounterT)1 \
47  , \
48  ( \
49  (RansacItCounterT)( \
50  ((long double)dynamicMaxIterations) \
51  * \
52  ((long double)assurance) \
53  ) \
54  ) \
55  ) \
56 
57 #define RANSACGETMAXITERATIONS( goodTPNumber, totalTPNumber, modelRequiredTPNumber, procsNumber, assurance ) \
58  ( \
59  ( \
60  (RansacItCounterT) \
61  ( \
62  std::log( \
63  (long double)( 1.0 - ((long double)assurance) ) \
64  ) \
65  / \
66  std::log( \
67  ((long double)1.0) \
68  - \
69  std::pow( \
70  ( \
71  ((long double)goodTPNumber ) \
72  / \
73  ((long double)totalTPNumber) \
74  ) \
75  , \
76  ((long double)modelRequiredTPNumber) \
77  ) \
78  ) \
79  ) \
80  ) \
81  / \
82  ((RansacItCounterT)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 RansacItCounterT& 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  RansacItCounterT 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  ((RansacItCounterT)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 RansacItCounterT& 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  RansacItCounterT& 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  RansacItCounterT selectedTpsCounter = 0;
449  std::vector< GTParameters::TiePoint* > selectedTpsPtrsVec;
450  selectedTpsPtrsVec.resize( reqTPsNmb, 0 );
451  unsigned int selectedTpsPtrsVecIdx = 0;
452  bool selectedTpsNotSelectedBefore = false;
453  RansacItCounterT currentIteration = 0;
454 
455  RansacItCounterT dynamicMaxIterations = globalDynamicMaxIterations;
456  RansacItCounterT dynamicMaxIterationsEstimation = 0;
457  RansacItCounterT dynamicMaxConsecutiveInvalidIterations =
458  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
459  const RansacItCounterT threadSyncMaxIterations = procsNumber;
460  RansacItCounterT threadSyncIteration = 0;
461 
462  RansacItCounterT consecutiveInvalidIterations = 0;
463  double randomValue = 0;
464 
465  while( keepRunningFlag && ( currentIteration < dynamicMaxIterations ) &&
466  ( consecutiveInvalidIterations < dynamicMaxConsecutiveInvalidIterations ) )
467  {
468  // Trying to find a valid base consensus set
469  // with the minimum number of required tie-points
470  // Random selecting n distinc tpoints from the original set
471 
472  consensusSetParams.reset();;
473  selectedTpsCounter = 0;
474 
475  while( selectedTpsCounter < reqTPsNmb )
476  {
477  randomValue = distribution( generator );
478  tpsMapIt = tpsMap.upper_bound( randomValue );
479  assert( tpsMapIt != tpsMap.end() );
480 
481  // Checking if this TP was already selected before
482 
483  selectedTpsNotSelectedBefore = true;
484 
485  for( selectedTpsPtrsVecIdx = 0 ; selectedTpsPtrsVecIdx <
486  selectedTpsCounter ; ++selectedTpsPtrsVecIdx )
487  {
488  if( selectedTpsPtrsVec[ selectedTpsPtrsVecIdx ] ==
489  &(tpsMapIt->second) )
490  {
491  selectedTpsNotSelectedBefore = false;
492  break;
493  }
494  }
495 
496  if( selectedTpsNotSelectedBefore )
497  {
498  consensusSetParams.m_tiePoints.push_back( tpsMapIt->second );
499  }
500 
501  ++selectedTpsCounter;
502  }
503 
504  /* Trying to generate a valid base consensus transformation with the
505  selected points */
506 
507  if( bestTransfPtr->computeParameters( consensusSetParams ) )
508  {
509  // finding those tie-points in agreement with the generated
510  // consensus basic transformation
511 
512  consensusSetTiePoints.clear();
513  consensusSetMaxDMapError = 0;
514  consensusSetMaxIMapError = 0;
515 
516  for( inputTpIdx = 0 ; inputTpIdx < inputTPNmb ; ++inputTpIdx )
517  {
518  const GTParameters::TiePoint& curTP = tiePoints[ inputTpIdx ];
519 
520  tiePointDMapErr = bestTransfPtr->getDirectMappingError( curTP, consensusSetParams );
521  tiePointIMapErr = bestTransfPtr->getInverseMappingError( curTP, consensusSetParams );
522 
523  if( ( tiePointDMapErr <= maxDirectMapError ) &&
524  ( tiePointIMapErr <= maxInverseMapError ) )
525  {
526  consensusSetTiePoints.push_back( curTP );
527 
528  if( tiePointDMapErr > consensusSetMaxDMapError )
529  consensusSetMaxDMapError = tiePointDMapErr;
530  if( tiePointIMapErr > consensusSetMaxIMapError )
531  consensusSetMaxIMapError = tiePointIMapErr;
532  }
533  }
534 
535  consensusSetSize = (unsigned int)consensusSetTiePoints.size();
536  consensusSetConvexHullArea = getPt1ConvexHullArea(
537  consensusSetTiePoints );
538 
539  /* Is this an acceptable consensus set ?? */
540 
541  if(
542  ( consensusSetSize >= reqTPsNmb )
543  &&
544  (
545  ( consensusSetSize > bestTiePoins.size() )
546  ||
547  (
548  ( consensusSetSize == bestTiePoins.size() )
549  &&
550  (
551  ( consensusSetConvexHullArea > bestParamsConvexHullArea )
552  ||
553  (
554  ( consensusSetConvexHullArea == bestParamsConvexHullArea )
555  &&
556  (
557  ( bestParamsMaxDMapErrorPtr > consensusSetMaxDMapError )
558  &&
559  ( bestParamsMaxIMapErrorPtr > consensusSetMaxIMapError )
560  )
561  )
562  )
563  )
564  )
565  )
566  {
567  bestParams = consensusSetParams;
568  bestParamsMaxDMapErrorPtr = consensusSetMaxDMapError;
569  bestParamsMaxIMapErrorPtr = consensusSetMaxIMapError;
570  bestParamsConvexHullArea = consensusSetConvexHullArea;
571  bestTiePoins = consensusSetTiePoints;
572 
573  consecutiveInvalidIterations = 0;
574  }
575  else
576  {
577  ++consecutiveInvalidIterations;
578  }
579  }
580  else
581  {
582  ++consecutiveInvalidIterations;
583  };
584 
585  // Updating iteration related variables
586 
587  if( useDynamicIterationsNumber && ( currentIteration != 0 ) )
588  {
589  if( bestTiePoins.size() == inputTPNmb )
590  {
591  mutex.lock();
592 
593  keepRunningFlag = false;
594 
595  mutex.unlock();
596 
597  break;
598  }
599  else if( ! bestTiePoins.empty() )
600  {
601  const RansacItCounterT dynamicMaxIterationsEstimation = RANSACGETMAXITERATIONS(
602  bestTiePoins.size(),
603  inputTPNmb,
604  reqTPsNmb,
605  procsNumber,
606  assurance );
607 
608  if( dynamicMaxIterationsEstimation < dynamicMaxIterations )
609  {
610  dynamicMaxIterations =
611  ( dynamicMaxIterations - ( ( dynamicMaxIterations - dynamicMaxIterationsEstimation ) / 2 ) );
612 
613  dynamicMaxConsecutiveInvalidIterations =
614  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
615  }
616 
617  if( globalDynamicMaxIterations < dynamicMaxIterations )
618  {
619  dynamicMaxIterations = globalDynamicMaxIterations;
620 
621  dynamicMaxConsecutiveInvalidIterations =
622  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
623  }
624  }
625  }
626 
627  // Sync with the other threads
628 
629  if(
630  ( threadSyncIteration >= threadSyncMaxIterations )
631  ||
632  ( currentIteration >= dynamicMaxIterations )
633  ||
634  ( consecutiveInvalidIterations >= dynamicMaxConsecutiveInvalidIterations )
635  )
636  {
637  threadSyncIteration = 0;
638 
640  }
641 
642  ++threadSyncIteration;
643  ++currentIteration;
644  }
645 
646  // Sync the final result
647 
649 }
650 
651 double te::gm::GTFilter::getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint >& tiePoints)
652 {
653  if( tiePoints.size() < 3 )
654  {
655  return 0;
656  }
657  else
658  {
660 
661  for( unsigned int tiePointsIdx = 0 ; tiePointsIdx < tiePoints.size() ;
662  ++tiePointsIdx )
663  {
664  points.add( new te::gm::Point( tiePoints[ tiePointsIdx ].first.x,
665  tiePoints[ tiePointsIdx ].first.y ) );
666  }
667 
668  std::auto_ptr< te::gm::Surface > convexHullPtr(
669  (te::gm::Surface*)points.convexHull() );
670 
671  if( convexHullPtr.get() )
672  return convexHullPtr->getArea();
673  else
674  return 0;
675  }
676 }
static void applyRansacThreadEntry(te::gm::GTFilter::ApplyRansacThreadEntryThreadParams *paramsPtr)
Surf locator thread entry.
Definition: GTFilter.cpp:368
virtual Geometry * convexHull() const
This method calculates the Convex Hull of a geometry.
Definition: Geometry.cpp:439
#define RANSACGETMAXITERATIONS(goodTPNumber, totalTPNumber, modelRequiredTPNumber, procsNumber, assurance)
Definition: GTFilter.cpp:57
unsigned int GetPhysProcNumber()
Returns the number of physical processors.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
MultiPoint is a GeometryCollection whose elements are restricted to points.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
const ApplyRansacThreadEntryThreadParams & operator=(const ApplyRansacThreadEntryThreadParams &other)
Definition: GTFilter.cpp:165
Parameters used by the GTFilter::applyRansacThreadEntry method.
Definition: GTFilter.h:102
void add(Geometry *g)
It adds the geometry into the collection.
std::vector< te::gm::GTParameters::TiePoint > * m_bestTiePoinsPtr
Definition: GTFilter.h:122
unsigned long long int RansacItCounterT
RANSAC iterations counter type.
Definition: GTFilter.h:57
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
A point with x and y coordinate values.
bool applyRansac(const std::string &transfName, const GTParameters &inputParams, const double maxDirectMapError, const double maxInverseMapError, const RansacItCounterT &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
A point with x and y coordinate values.
Definition: Point.h:50
#define RANSACSYNCTHREAD
Definition: GTFilter.cpp:85
GTFilter()
Default constructor.
Definition: GTFilter.cpp:195
#define RANSACGETMAXINVALIDITERATIONS(assurance, dynamicMaxIterations)
Definition: GTFilter.cpp:44
2D Geometric transformation factory.
~GTFilter()
Destructor.
Definition: GTFilter.cpp:191
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:117
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
std::auto_ptr< GeometricTransformation > * m_bestTransformationPtrPtr
Definition: GTFilter.h:118
2D Geometric transformation parameters.
Definition: GTParameters.h:50
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
static double getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint > &tiePoints)
Returns the tie-points convex hull area (GTParameters::TiePoint::first).
Definition: GTFilter.cpp:651
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54
Surface is an abstract class that represents a 2-dimensional geometric objects.
2D Geometric transformation outliers remotion filter.