OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
atp-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>
18 #include "../AtpCommon.h"
19 
20 using namespace std;
21 using namespace ossim;
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 
43  const Json::Value& pbJson = root["photoblock"];
44  PhotoBlock photoblock (pbJson);
45 
46  vector<shared_ptr<Image> >& imageList = photoblock.getImageList();
47  vector<shared_ptr<TiePoint> >& tpList = photoblock.getTiePointList();
48 
52  NEWMAT::SymmetricMatrix cov;
53  string imageId;
54  int numImages = imageList.size();
55 
56  // Initialize tuple with image sensor models:
57  for (int i=0; i<numImages; i++)
58  {
59  ossimFilename imageFile (imageList[i]->getFilename());
60  unsigned int index = imageList[i]->getEntryIndex();
61  ossimProjection* proj = factory->createProjection(imageFile, 0);
62  model = dynamic_cast<ossimSensorModel*>(proj);
63  if (!model)
64  {
65  delete proj;
66  continue;
67  }
68  smt.addImage(model.get());
69  }
70 
71  vector<ossimDpt> observations;
72  ossimDpt imagePoint;
74  ossimEcefPoint resultEcf;
75  ossimGpt resultGpt;
76  NEWMAT::Matrix cov3d;
77 
78  // Now perform intersection for each TP entry:
79  for (unsigned int n=0; n<tpList.size(); n++)
80  {
81  for (unsigned int i=0; i<numImages; i++)
82  {
83  tpList[n]->getImagePoint(i, imageId, imagePoint, cov);
84  observations.push_back(imagePoint);
85  }
86 
87  status = smt.intersect(observations, resultEcf, cov3d);
88  resultGpt = ossimGpt(resultEcf);
89  cout <<"\n intersection GPT: "<<resultGpt<<"\n"<<cov3d<<endl;
90  }
91  cout<<"\nDone!"<<endl;
92  }
93  catch(const ossimException& e)
94  {
95  CWARN << e.what() << std::endl;
96  returnCode = 1;
97  }
98  catch( ... )
99  {
100  CWARN << "ossim-foo caught unhandled exception!" << std::endl;
101  returnCode = 1;
102  }
103 
104  return returnCode;
105 }
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
ossimSensorModelTuple::IntersectStatus intersect(const DptSet_t obs, ossimEcefPoint &pt, NEWMAT::Matrix &covMat) const
Multi-image intersection method.
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual const char * what() const
Returns the error message.
int main(int argc, char *argv[])
Definition: atp-test.cpp:23
os2<< "> n<< " > nendobj n
static ossimProjectionFactoryRegistry * instance()
return status
TiePointList & getTiePointList()
Definition: PhotoBlock.h:46
static ossimInit * instance()
Definition: ossimInit.cpp:89
void addImage(ossimSensorModel *image)
Method to add an image to the tuple.
#define CWARN