OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
atp-pax-test.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
6 #include <cmath>
7 #include <memory>
8 #include <sstream>
9 #include <iostream>
10 
11 // ossim includes: These are here just to save time/typing...
14 #include <ossim/init/ossimInit.h>
15 #include <ossim/reg/PhotoBlock.h>
16 #include "../AtpCommon.h"
17 #include "../src/AtpGenerator.h"
18 
19 using namespace std;
20 using namespace ossim;
21 using namespace ATP;
22 
23 int main(int argc, char *argv[])
24 {
25  int returnCode = 0;
26 
27  ossimArgumentParser ap(&argc, argv);
30 
31  if (argc < 2)
32  {
33  cout<<"\nUsage: "<<argv[0]<<"<mensuration-input.json>\n"<<endl;
34  exit(0);
35  }
36 
37  try
38  {
39  ifstream jsonInput (argv[1]);
40  Json::Value root;
41  jsonInput >> root;
42  jsonInput.close();
43 
44  AtpConfig& config = AtpConfig::instance();
45  const Json::Value& parameters = root["parameters"];
46  config.loadJSON(parameters);
47 
48  const Json::Value& pbJson = root["photoblock"];
49  PhotoBlock photoblock (pbJson);
50 
51  vector<shared_ptr<Image> >& imageList = photoblock.getImageList();
52  vector<shared_ptr<TiePoint> >& tpList = photoblock.getTiePointList();
53 
54  shared_ptr<AtpGenerator> generator (new AtpGenerator(AtpGenerator::CROSSCORR));
55  generator->setRefImage(imageList[0]);
56  generator->setCmpImage(imageList[1]);
57  generator->initialize();
58 
59  ossimRefPtr<AtpTileSource> atpTileSource = generator->getAtpTileSource();
60  atpTileSource->setTiePoints(tpList);
61  atpTileSource->filterPoints();
62 
63  //ossimGrect grect (41.9339,12.4563,41.9316,12.4594);
64  //ossimDrect drect;
65  //generator->getRefIVT()->getViewGeometry()->worldToLocal(grect, drect);
66  //generator->m_annotatedRefImage->setAOI(drect);
67  //generator->m_annotatedCmpImage->setAOI(drect);
68 
69  generator->m_annotatedRefImage->write();
70  generator->m_annotatedCmpImage->write();
71 
72  cout<<"\nDone!"<<endl;
73  generator.reset();
74  }
75  catch(const ossimException& e)
76  {
77  CWARN << e.what() << std::endl;
78  returnCode = 1;
79  }
80  catch( ... )
81  {
82  CWARN << "atp-pax-test caught unhandled exception!" << std::endl;
83  returnCode = 1;
84  }
85 
86  return returnCode;
87 }
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
void addOptions(ossimArgumentParser &parser)
Definition: ossimInit.cpp:100
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
Class for representing MSP PhotoBlock.
Definition: PhotoBlock.h:25
ImageList & getImageList()
Definition: PhotoBlock.h:45
void setTiePoints(ossim::TiePointList &atpList)
Used for testing.
virtual const char * what() const
Returns the error message.
Base class for OSSIM-based ATP generators.
Definition: AtpGenerator.h:33
THESE FUNCTIONS REQUIRE OPENCV.
int main(int argc, char *argv[])
TiePointList & getTiePointList()
Definition: PhotoBlock.h:46
static ossimInit * instance()
Definition: ossimInit.cpp:89
#define CWARN
virtual void loadJSON(const Json::Value &params_json_node)
Reads the params controlling the process from the JSON node named "parameters".
Definition: JsonConfig.cpp:403
Singleton class maintaining parameters affecting the automatic tie point generation.
Definition: AtpConfig.h:24