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 = nullptr;
136  m_inputGTParamsPtr = nullptr;
137  m_maxDirectMapError = 0.0;
138  m_maxInverseMapError = 0.0;
139  m_assurance = 0.0;
141  m_dynamicMaxIterationsPtr = nullptr;
142  m_procsNumber = 1;
143  m_returnValuePtr = nullptr;
144  m_mutexPtr = nullptr;
145  m_keepRunningFlagPtr = nullptr;
146  m_tpsMapPtr = nullptr;
147  m_bestTransformationPtrPtr = nullptr;
148  m_bestParamsMaxDMapErrorPtr = nullptr;
149  m_bestParamsMaxIMapErrorPtr = nullptr;
151  m_bestTiePoinsPtr = nullptr;
152 }
153 
156 {
157  operator=( other );
158 }
159 
162 
166 {
171  m_assurance = other.m_assurance;
176  m_mutexPtr = other.m_mutexPtr;
178  m_tpsMapPtr = other.m_tpsMapPtr;
184 
185  return other;
186 }
187 
188 // ---------------------------------------------------------------------------
189 
190 te::gm::GTFilter::~GTFilter() = default;
191 
192 te::gm::GTFilter::GTFilter() = default;
193 
194 bool te::gm::GTFilter::applyRansac(const std::string& transfName,
195  const GTParameters& inputParams,
196  const double maxDirectMapError,
197  const double maxInverseMapError,
198  const RansacIntegerCounterT& maxIterations,
199  const double& assurance,
200  const bool enableMultiThread,
201  const std::vector<double>& tiePointsWeights,
202  std::vector< te::gm::GTParameters::TiePoint >& outTiePoints,
203  std::unique_ptr< GeometricTransformation >& outTransf
204  )
205 {
206  if(maxDirectMapError < 0)
207  return false;
208 
209  if(maxInverseMapError < 0)
210  return false;
211 
212  if((assurance <= 0.0) || (assurance > 1.0))
213  return false;
214 
215  outTiePoints.clear();
216  outTransf.reset();
217 
218  // generating the tie-points accumulated probabilities map
219  // with positive values between 0 and 1
220  std::map< double, GTParameters::TiePoint > tpsMap;
221  {
222  const unsigned int inputTPNmb = (unsigned int)
223  inputParams.m_tiePoints.size();
224  double tiePointsWeightsSum = 0;
225 
226  if( tiePointsWeights.size() > 0 )
227  {
228  if( tiePointsWeights.size() != inputParams.m_tiePoints.size () )
229  return false;
230 
231  // finding normalization factors
232 
233  unsigned int tpIdx = 0;
234 
235  for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
236  {
237  if( tiePointsWeights[ tpIdx ] < 0.0 ) return false;
238 
239  tiePointsWeightsSum += tiePointsWeights[ tpIdx ];
240  }
241 
242  if( tiePointsWeightsSum <= 0.0 ) return false;
243 
244  // map fill
245 
246  double newWSum = 0.0;
247  double newW = 0.0;
248 
249  for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
250  {
251  newW = tiePointsWeights[ tpIdx ];
252  newW /= tiePointsWeightsSum;
253 
254  newWSum += newW;
255 
256  tpsMap[ newWSum ] = inputParams.m_tiePoints[ tpIdx ];
257  }
258  }
259  else
260  {
261  double wSum = 0;
262  const double increment = 1.0 /
263  ( (double)inputParams.m_tiePoints.size() );
264 
265  for( unsigned int tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
266  {
267  wSum += increment;
268  tpsMap[ wSum ] = inputParams.m_tiePoints[ tpIdx ];
269  }
270  }
271  }
272 
273  // creating global execution parameters
274 
275  std::unique_ptr< GeometricTransformation > bestTransformationPtr(
276  te::gm::GTFactory::make( transfName ) );
277  if( bestTransformationPtr.get() == nullptr ) return false;
278 
279  const unsigned int procsNumber = te::common::GetPhysProcNumber();
280  boost::mutex syncMutex;
281  double bestParamsMaxDMapError = maxDirectMapError;
282  double bestParamsMaxIMapError = maxInverseMapError;
283  double bestParamsConvexHullArea = -1.0;
284  bool returnValue = true;
285  bool keepRunningFlag = true;
286  RansacIntegerCounterT dynamicMaxIterations =
287  maxIterations ?
288  (
289  maxIterations
290  /
291  (
292  enableMultiThread ? procsNumber : 1
293  )
294  )
295  :
297  bestTransformationPtr->getMinRequiredTiePoints(),
298  inputParams.m_tiePoints.size(),
299  bestTransformationPtr->getMinRequiredTiePoints(),
300  enableMultiThread ? procsNumber : 1,
301  assurance );
302 
303  ApplyRansacThreadEntryThreadParams baseThreadParams;
304  baseThreadParams.m_transfNamePtr = &transfName;
305  baseThreadParams.m_inputGTParamsPtr = &inputParams;
306  baseThreadParams.m_maxDirectMapError = maxDirectMapError;
307  baseThreadParams.m_maxInverseMapError = maxInverseMapError;
308  baseThreadParams.m_assurance = assurance;
309  baseThreadParams.m_useDynamicIterationsNumber = ( maxIterations == 0 );
310  baseThreadParams.m_dynamicMaxIterationsPtr = &dynamicMaxIterations;
311  baseThreadParams.m_procsNumber = enableMultiThread ?
312  ((RansacIntegerCounterT)procsNumber) : 1;
313  baseThreadParams.m_returnValuePtr = &returnValue;
314  baseThreadParams.m_mutexPtr = &syncMutex;
315  baseThreadParams.m_keepRunningFlagPtr = &keepRunningFlag;
316  baseThreadParams.m_tpsMapPtr = &tpsMap;
317  baseThreadParams.m_bestTransformationPtrPtr = &bestTransformationPtr;
318  baseThreadParams.m_bestParamsMaxDMapErrorPtr = &bestParamsMaxDMapError;
319  baseThreadParams.m_bestParamsMaxIMapErrorPtr = &bestParamsMaxIMapError;
320  baseThreadParams.m_bestParamsConvexHullAreaPtr = &bestParamsConvexHullArea;
321  baseThreadParams.m_bestTiePoinsPtr = &outTiePoints;
322 
323  // Calling the ransac thread entry
324 
325  if( enableMultiThread )
326  {
327  std::vector< ApplyRansacThreadEntryThreadParams > threadsParameters;
328  threadsParameters.resize( procsNumber, baseThreadParams );
329  boost::thread_group threads;
330 
331  for( unsigned int threadIdx = 0 ; threadIdx < procsNumber ;
332  ++threadIdx )
333  {
334  threads.add_thread( new boost::thread( applyRansacThreadEntry,
335  &threadsParameters[ threadIdx ] ) );
336  }
337 
338  threads.join_all();
339  }
340  else
341  {
342  applyRansacThreadEntry( &baseThreadParams );
343  }
344 
345  if( returnValue )
346  {
347  if( bestTransformationPtr.get() )
348  {
349  outTransf.reset( bestTransformationPtr.release() );
350  return true;
351  }
352  else
353  {
354  return false;
355  }
356  }
357  else
358  {
359  return false;
360  }
361 }
362 
364 {
365  assert( paramsPtr->m_procsNumber > 0 );
366 
367  // accessing global shared objects
368 
369  paramsPtr->m_mutexPtr->lock();
370 
371  std::unique_ptr< te::gm::GeometricTransformation > bestTransfPtr(
372  te::gm::GTFactory::make( *paramsPtr->m_transfNamePtr ) );
373  if( bestTransfPtr.get() == nullptr )
374  {
375  *(paramsPtr->m_returnValuePtr) = false;
376  *(paramsPtr->m_keepRunningFlagPtr) = false;
377  paramsPtr->m_mutexPtr->unlock();
378  return;
379  }
380 
381  const std::vector< te::gm::GTParameters::TiePoint > tiePoints =
382  paramsPtr->m_inputGTParamsPtr->m_tiePoints;
383  std::map< double, GTParameters::TiePoint > tpsMap = *(paramsPtr->m_tpsMapPtr);
384 
385  // initializing the random number generator to assure that each thread has
386  // a different seed
387  boost::random::mt19937 generator( (boost::random::mt19937::result_type)time(nullptr) );
388 
389  paramsPtr->m_mutexPtr->unlock();
390 
391  // external globals
392 
393  const RansacIntegerCounterT& procsNumber = paramsPtr->m_procsNumber;
394  const double& maxDirectMapError = paramsPtr->m_maxDirectMapError;
395  const double& maxInverseMapError = paramsPtr->m_maxInverseMapError;
396  bool& keepRunningFlag = (*(paramsPtr->m_keepRunningFlagPtr));
397  const double& assurance = paramsPtr->m_assurance;
398  const bool& useDynamicIterationsNumber = paramsPtr->m_useDynamicIterationsNumber;
399  RansacIntegerCounterT& globalDynamicMaxIterations = (*(paramsPtr->m_dynamicMaxIterationsPtr));
400  boost::mutex& mutex = (*(paramsPtr->m_mutexPtr));
401 
402  // Checking the number of required tie-points
403 
404  const unsigned int reqTPsNmb = bestTransfPtr->getMinRequiredTiePoints();
405  const unsigned int inputTPNmb = (unsigned int)tiePoints.size();
406 
407  if( inputTPNmb < reqTPsNmb )
408  {
409  mutex.lock();
410  *(paramsPtr->m_returnValuePtr) = false;
411  *(paramsPtr->m_keepRunningFlagPtr) = false;
412  mutex.unlock();
413  return;
414  }
415 
416  // best parameters found by this thread
417 
418  GTParameters bestParams;
419  double bestParamsMaxDMapErrorPtr = paramsPtr->m_maxDirectMapError;
420  double bestParamsMaxIMapErrorPtr = paramsPtr->m_maxInverseMapError;
421  double bestParamsConvexHullArea = -1.0;
422  std::vector< te::gm::GTParameters::TiePoint > bestTiePoins;
423 
424  // variables used by the ransac loop
425 
426  boost::random::uniform_01< double > distribution;
427 
428  GTParameters consensusSetParams;
429  std::vector< te::gm::GTParameters::TiePoint > consensusSetTiePoints;
430  consensusSetParams.m_tiePoints.reserve( tiePoints.size() );
431  double consensusSetMaxDMapError = 0;
432  double consensusSetMaxIMapError = 0;
433  unsigned int consensusSetSize = 0;
434  double consensusSetConvexHullArea = 0.0;
435  std::vector< Coord2D > consensusSetPt1ConvexHullPoits;
436 
437  double tiePointDMapErr = 0;
438  double tiePointIMapErr = 0;
439 
440  std::map< double, GTParameters::TiePoint >::const_iterator tpsMapIt;
441  unsigned int inputTpIdx = 0;
442 
443  RansacIntegerCounterT selectedTpsCounter = 0;
444  std::vector< GTParameters::TiePoint* > selectedTpsPtrsVec;
445  selectedTpsPtrsVec.resize( reqTPsNmb, nullptr );
446  unsigned int selectedTpsPtrsVecIdx = 0;
447  bool selectedTpsNotSelectedBefore = false;
448  RansacIntegerCounterT currentIteration = 0;
449 
450  RansacIntegerCounterT dynamicMaxIterations = globalDynamicMaxIterations;
451  RansacIntegerCounterT dynamicMaxConsecutiveInvalidIterations =
452  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
453  const RansacIntegerCounterT threadSyncMaxIterations = procsNumber;
454  RansacIntegerCounterT threadSyncIteration = 0;
455 
456  RansacIntegerCounterT consecutiveInvalidIterations = 0;
457  double randomValue = 0;
458 
459  while( keepRunningFlag && ( currentIteration < dynamicMaxIterations ) &&
460  ( consecutiveInvalidIterations < dynamicMaxConsecutiveInvalidIterations ) )
461  {
462  // Trying to find a valid base consensus set
463  // with the minimum number of required tie-points
464  // Random selecting n distinc tpoints from the original set
465 
466  consensusSetParams.reset();;
467  selectedTpsCounter = 0;
468 
469  while( selectedTpsCounter < reqTPsNmb )
470  {
471  randomValue = distribution( generator );
472  tpsMapIt = tpsMap.upper_bound( randomValue );
473  assert( tpsMapIt != tpsMap.end() );
474 
475  // Checking if this TP was already selected before
476 
477  selectedTpsNotSelectedBefore = true;
478 
479  for( selectedTpsPtrsVecIdx = 0 ; selectedTpsPtrsVecIdx <
480  selectedTpsCounter ; ++selectedTpsPtrsVecIdx )
481  {
482  if( selectedTpsPtrsVec[ selectedTpsPtrsVecIdx ] ==
483  &(tpsMapIt->second) )
484  {
485  selectedTpsNotSelectedBefore = false;
486  break;
487  }
488  }
489 
490  if( selectedTpsNotSelectedBefore )
491  {
492  consensusSetParams.m_tiePoints.push_back( tpsMapIt->second );
493  }
494 
495  ++selectedTpsCounter;
496  }
497 
498  /* Trying to generate a valid base consensus transformation with the
499  selected points */
500 
501  if( bestTransfPtr->computeParameters( consensusSetParams ) )
502  {
503  // finding those tie-points in agreement with the generated
504  // consensus basic transformation
505 
506  consensusSetTiePoints.clear();
507  consensusSetMaxDMapError = 0;
508  consensusSetMaxIMapError = 0;
509 
510  for( inputTpIdx = 0 ; inputTpIdx < inputTPNmb ; ++inputTpIdx )
511  {
512  const GTParameters::TiePoint& curTP = tiePoints[ inputTpIdx ];
513 
514  tiePointDMapErr = bestTransfPtr->getDirectMappingError( curTP, consensusSetParams );
515  tiePointIMapErr = bestTransfPtr->getInverseMappingError( curTP, consensusSetParams );
516 
517  if( ( tiePointDMapErr <= maxDirectMapError ) &&
518  ( tiePointIMapErr <= maxInverseMapError ) )
519  {
520  consensusSetTiePoints.push_back( curTP );
521 
522  if( tiePointDMapErr > consensusSetMaxDMapError )
523  consensusSetMaxDMapError = tiePointDMapErr;
524  if( tiePointIMapErr > consensusSetMaxIMapError )
525  consensusSetMaxIMapError = tiePointIMapErr;
526  }
527  }
528 
529  consensusSetSize = (unsigned int)consensusSetTiePoints.size();
530  consensusSetConvexHullArea = getPt1ConvexHullArea(
531  consensusSetTiePoints );
532 
533  /* Is this an acceptable consensus set ?? */
534 
535  if(
536  ( consensusSetSize >= reqTPsNmb )
537  &&
538  (
539  ( consensusSetSize > bestTiePoins.size() )
540  ||
541  (
542  ( consensusSetSize == bestTiePoins.size() )
543  &&
544  (
545  ( consensusSetConvexHullArea > bestParamsConvexHullArea )
546  ||
547  (
548  ( consensusSetConvexHullArea == bestParamsConvexHullArea )
549  &&
550  (
551  ( bestParamsMaxDMapErrorPtr > consensusSetMaxDMapError )
552  &&
553  ( bestParamsMaxIMapErrorPtr > consensusSetMaxIMapError )
554  )
555  )
556  )
557  )
558  )
559  )
560  {
561  bestParams = consensusSetParams;
562  bestParamsMaxDMapErrorPtr = consensusSetMaxDMapError;
563  bestParamsMaxIMapErrorPtr = consensusSetMaxIMapError;
564  bestParamsConvexHullArea = consensusSetConvexHullArea;
565  bestTiePoins = consensusSetTiePoints;
566 
567  consecutiveInvalidIterations = 0;
568  }
569  else
570  {
571  ++consecutiveInvalidIterations;
572  }
573  }
574  else
575  {
576  ++consecutiveInvalidIterations;
577  };
578 
579  // Updating iteration related variables
580 
581  if( useDynamicIterationsNumber && ( currentIteration != 0 ) )
582  {
583  if( bestTiePoins.size() == inputTPNmb )
584  {
585  mutex.lock();
586 
587  keepRunningFlag = false;
588 
589  mutex.unlock();
590 
591  break;
592  }
593  else if( ! bestTiePoins.empty() )
594  {
595  const RansacIntegerCounterT dynamicMaxIterationsEstimation = RANSACGETMAXITERATIONS(
596  bestTiePoins.size(),
597  inputTPNmb,
598  reqTPsNmb,
599  procsNumber,
600  assurance );
601 
602  if( dynamicMaxIterationsEstimation < dynamicMaxIterations )
603  {
604  dynamicMaxIterations =
605  ( dynamicMaxIterations - ( ( dynamicMaxIterations - dynamicMaxIterationsEstimation ) / 2 ) );
606 
607  dynamicMaxConsecutiveInvalidIterations =
608  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
609  }
610 
611  if( globalDynamicMaxIterations < dynamicMaxIterations )
612  {
613  dynamicMaxIterations = globalDynamicMaxIterations;
614 
615  dynamicMaxConsecutiveInvalidIterations =
616  RANSACGETMAXINVALIDITERATIONS( assurance, dynamicMaxIterations );
617  }
618  }
619  }
620 
621  // Sync with the other threads
622 
623  if(
624  ( threadSyncIteration >= threadSyncMaxIterations )
625  ||
626  ( currentIteration >= dynamicMaxIterations )
627  ||
628  ( consecutiveInvalidIterations >= dynamicMaxConsecutiveInvalidIterations )
629  )
630  {
631  threadSyncIteration = 0;
632 
634  }
635 
636  ++threadSyncIteration;
637  ++currentIteration;
638  }
639 
640  // Sync the final result
641 
643 }
644 
645 double te::gm::GTFilter::getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint >& tiePoints)
646 {
647  if( tiePoints.size() < 3 )
648  {
649  return 0;
650  }
651  else
652  {
654 
655  for( unsigned int tiePointsIdx = 0 ; tiePointsIdx < tiePoints.size() ;
656  ++tiePointsIdx )
657  {
658  points.add(new te::gm::Point(tiePoints[tiePointsIdx].first.x,
659  tiePoints[ tiePointsIdx ].first.y ) );
660  }
661 
662  std::unique_ptr< te::gm::Geometry > convexHullPtr( points.convexHull() );
663 
664  if( dynamic_cast< te::gm::Surface* >( convexHullPtr.get() ) )
665  {
666  return dynamic_cast< te::gm::Surface* >( convexHullPtr.get() )->getArea();
667  }
668  else
669  {
670  return 0;
671  }
672  }
673 }
static double getPt1ConvexHullArea(const std::vector< GTParameters::TiePoint > &tiePoints)
Returns the tie-points convex hull area (GTParameters::TiePoint::first).
Definition: GTFilter.cpp:645
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
GTFilter()
Default constructor.
unsigned long int RansacIntegerCounterT
RANSAC integer counter type.
Definition: GTFilter.h:57
std::unique_ptr< GeometricTransformation > * m_bestTransformationPtrPtr
Definition: GTFilter.h:121
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
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors.
std::vector< te::gm::GTParameters::TiePoint > * m_bestTiePoinsPtr
Definition: GTFilter.h:125
~GTFilter()
Destructor.
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:164
#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:363
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...
2D Geometric transformation factory.
2D Geometric transformation parameters.
Definition: GTParameters.h:50
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::unique_ptr< GeometricTransformation > &outTransf)
Apply a RANSAC based outliers remotion strategy.
Definition: GTFilter.cpp:194
virtual Geometry * convexHull() const _NOEXCEPT_OP(false)
This method calculates the Convex Hull of a geometry.
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54