9 #include "../AtpCommon.h" 20 double AtpTileSource::s_minVectorResDiff = 0;
21 double AtpTileSource::s_maxDiffRatio = 1.0;
22 double AtpTileSource::s_cosMaxAngleDiff = 0;
23 double AtpTileSource::s_maxPaxDev = 1.0;
24 double AtpTileSource::s_maxPaxPix = 2.0;
25 unsigned int AtpTileSource::s_minNumConsistent = 3;
26 unsigned int AtpTileSource::s_percentConsistent = 50;
27 unsigned int AtpTileSource::s_numTpsPerTile = 2;
28 unsigned int AtpTileSource::s_numFilterIterations = 0;
29 bool AtpTileSource::s_useRasterMode =
false;
30 bool AtpTileSource::s_initialized =
false;
32 AtpTileSource::AtpTileSource()
33 : m_considerParallax (
true)
39 m_considerParallax (
true)
45 : m_generator(generator),
46 m_considerParallax (
true)
60 const char* MODULE =
"AtpTileSource::initialize() -- ";
86 const char* MODULE =
"AtpTileSource::filterPoints() -- ";
93 if ((*tiePoint) && (*tiePoint)->hasValidMatch())
130 CINFO << MODULE <<
"Insignificant parallax, falling back to non-parallax filtering." 154 CINFO<<MODULE<<
"After filtering & pruning: num TPs in tile = "<<
m_tiePoints.size()<<endl;
169 const char* MODULE =
"AtpTileSource::filterWithParallax() ";
185 CINFO << MODULE <<
"Could not establish good parallax statistics for this set. " 186 <<
"Removing all points for this tile." << endl;
193 bool statsChanged =
false;
212 if (!(*tiePoint)->bumpActiveMatch())
216 CINFO << MODULE <<
"Removing TP " << (*tiePoint)->getTiePointId() << endl;
224 CINFO << MODULE <<
"Bumping active match for TP " << (*tiePoint)->getTiePointId()
230 (*tiePoint)->getVectorResidual(residual);
254 CINFO << MODULE <<
"Iterating filterWithParallax after ATP list change (N = " 264 static const double DELTA_HEIGHT = 500.0;
278 gpt1.
hgt += DELTA_HEIGHT;
284 double dx_ref = (ipt1.
x - ipt0.
x);
285 double dy_ref = (ipt1.
y - ipt0.
y);
291 double dx_cmp = (ipt1.
x - ipt0.
x);
292 double dy_cmp = (ipt1.
y - ipt0.
y);
326 tiePoint->getVectorResidual(residual);
337 tiePoint->getVectorResidual(residual);
351 double sigmaDistance = sqrt(sumDistance2/(
m_tiePoints.size()-1));
362 const char* MODULE =
"AtpTileSource::filterWithoutParallax() ";
371 (*tiePoint)->getVectorResidual(r_atp);
376 (*tiePoint)->getRefImagePoint(refPt);
377 CINFO<<
"AutoTiePoint::checkConsistency() -- Processing TP "<<(*tiePoint)->getTiePointId()
378 <<
" at REF image pt: ("<<refPt.
x<<
", "<<refPt.
y<<
")"<<endl;
382 unsigned int num_consistent_neighbors = 0;
385 if ((*tiePoint)->getTiePointId() == neighbor->getTiePointId())
389 neighbor->getVectorResidual(r_nbr);
390 double diff = (r_nbr - r_atp).length();
393 num_consistent_neighbors++;;
398 double cos_theta=1.0, mag_ratio=0;
399 double r0 = r_atp.
length();
400 double r1 = r_nbr.
length();
401 mag_ratio = 2.0*fabs(r1-r0)/(r0+r1);
402 if ((r1 > 0.0) && (r0 > 0.0))
403 cos_theta = (r_atp.
x*r_nbr.
x + r_atp.
y*r_nbr.
y)/(r0*r1);
407 num_consistent_neighbors++;;
414 if (num_consistent_neighbors < minConsistent)
417 if (!(*tiePoint)->bumpActiveMatch())
420 CINFO << MODULE <<
"Removing TP " << (*tiePoint)->getTiePointId() << endl;
437 const char* MODULE =
"AtpTileSource::pruneList() ";
441 multimap<double, shared_ptr<AutoTiePoint> > atpMap;
448 CWARN<<MODULE<<
"WARNING: Null AutoTiePoint encountred in list. Skipping point."<<endl;
454 bool hasValidMatch = (*atp)->getConfidenceMeasure(confidence);
456 atpMap.emplace(1.0/confidence, *atp);
463 multimap<double, shared_ptr<AutoTiePoint> >::iterator tp = atpMap.begin();
464 while (tp != atpMap.end())
475 static const char* MODULE =
"AtpTileSource::initializeStaticMembers() -- ";
481 CWARN<<MODULE<<
"Bad or missing parameter in config: " 482 "maxResMagDiffRatio = "<<
s_maxDiffRatio<<
". Defaulting to 0.1."<<endl;
489 CWARN<<MODULE<<
"Bad or missing parameter in config: " 490 "maxAngleDiff = "<<theta<<
". Defaulting to 10 deg."<<endl;
498 CWARN<<MODULE<<
"Bad or missing parameter in config: " 506 CWARN<<MODULE<<
"Bad or missing parameter in config: " 514 CWARN<<MODULE<<
"Bad or missing parameter in config: " 522 CWARN<<MODULE<<
"Bad or missing parameter in config: " 530 CWARN<<MODULE<<
"Bad or missing parameter in config: " 531 "maxResParallaxDev = "<<
s_maxPaxDev<<
". Defaulting to 1.0."<<endl;
538 CWARN<<MODULE<<
"Bad or missing parameter in config: " 539 "maxResParallaxPix = "<<
s_maxPaxPix<<
". Defaulting to 1.0."<<endl;
554 NEWMAT::SymmetricMatrix cov;
556 for (
auto &tp : tpList)
559 tp->getImagePoint(0,
id,rip,cov);
560 tp->getImagePoint(1,
id,cip,cov);
561 atp->setRefImagePt(rip);
562 atp->addImageMatch(cip);
virtual bool addListener(ossimListener *listener)
void filterWithoutParallax()
JsonParam & getParameter(const char *paramName)
Returns a parameter (might be a null parameter if paramName not found in the configuration.
Base class for all automatic tiepoints.
This will be a base for all combiners.
std::shared_ptr< AtpGenerator > m_generator
double nan()
Method to return ieee floating point double precision NAN.
std::map< std::string, double > distanceMap
unsigned int asUint() const
virtual ossimDataObjectStatus getDataObjectStatus() const
ossim_float64 hgt
Height in meters above the ellipsiod.
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
static bool s_useRasterMode
bool paramExists(const char *paramName) const
virtual void initialize()
Initialize the data buffer.
static unsigned int s_minNumConsistent
virtual void initialize()
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
static ossimImageDataFactory * instance()
static double s_maxDiffRatio
std::vector< std::shared_ptr< TiePoint > > TiePointList
bool localToWorld(const ossimDpt &local_pt, ossimGpt &world_pt) const
Exposes the 3D projection from image to world coordinates.
void setTiePoints(ossim::TiePointList &atpList)
Used for testing.
virtual double getHeightAboveEllipsoid(const ossimGpt &gpt)
virtual void initialize()
Base class for OSSIM-based ATP generators.
static unsigned int s_percentConsistent
virtual ossimIrect getImageRectangle() const
static double s_minVectorResDiff
void initializeStaticMembers()
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
void pruneList()
Caps the max number of TPs given the list, which is the list of filtered TPs for the tile...
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
THESE FUNCTIONS REQUIRE OPENCV.
ossimRefPtr< ossimImageData > m_tile
bool diagnosticLevel(unsigned int level) const
Convenience method returns TRUE if the currently set diagnostic level is <= level.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ConnectableObjectList theInputObjectList
Holds a list of input objects.
static unsigned int s_numFilterIterations
static unsigned int s_numTpsPerTile
static double s_cosMaxAngleDiff
bool theComputeFullResBoundsFlag
void computeParallaxStatistics()
virtual ossim_uint32 getNumberOfInputs() const
Returns the number of input objects.
void filterWithParallax()
static AtpConfig & instance()
Singleton implementation.
static double s_maxPaxPix
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
static bool s_initialized
float distance(double lat1, double lon1, double lat2, double lon2, int units)
static double s_maxPaxDev
void getCenter(ossimDpt ¢er_point) const
Singleton class maintaining parameters affecting the automatic tie point generation.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.