9 #include "../AtpCommon.h" 17 using namespace ossim;
21 const char* ossimAtpTool::DESCRIPTION =
22 "Provides automatic tiepoint generation functionality. This tool uses JSON format to " 23 "communicate requests and results.";
25 ossimAtpTool::ossimAtpTool()
28 m_featureBased (
true),
30 m_method (METHOD_UNASSIGNED)
46 usageString +=
" atp [options] \n\n";
48 "Accesses automatic tiepoint generation functionality given JSON request on stdin (or input file if\n" 49 "-i specified). The response JSON is output to stdout unless -o option is specified.\n";
54 "List available auto-tie-point algorithms");
56 "Reads request JSON from the input file specified instead of stdin.");
58 "Outputs response JSON to the output file instead of stdout.");
60 "List all ATP parameters with default values.");
62 "Verbose. All non-response (debug) output to stdout is enabled.");
79 if ( ap.
read(
"--algorithms"))
82 if ( ap.
read(
"--parameters"))
85 if ( ap.
read(
"-i", sp1))
90 CFATAL<<__FILE__<<
" Could not open input file <"<<ts1<<
">";
95 Json::Value queryJson;
101 CFATAL<<__FILE__<<
" Could not parse input JSON <"<<ts1<<
">";
106 if ( ap.
read(
"-o", sp1))
111 CFATAL<<__FILE__<<
" Could not open output file <"<<ts1<<
">";
125 xmsg<<
"ossimAtpTool::loadJSON() ";
129 string method = queryRoot[
"method"].asString();
130 if (method ==
"getAlgorithms")
132 else if (method ==
"getParameters")
137 string algorithm = queryRoot[
"algorithm"].asString();
138 if (algorithm.empty())
147 xmsg <<
"Fatal error trying to read default ATP configuration for selected " 157 xmsg <<
"Fatal error trying to read default ATP configuration for selected algorithm <" 163 if (algorithm ==
"crosscorr")
165 else if (algorithm ==
"descriptor")
167 else if (algorithm ==
"nasa")
173 const Json::Value& parameters = queryRoot[
"parameters"];
174 if (!parameters.isNull())
178 CINFO<<
"\nATP configuration after loading:\n"<<config<<endl;
185 if (queryRoot.isMember(
"photoblock"))
210 xmsg <<
"Fatal: No method selected prior to execute being called. I don't know what to do!";
244 Json::Value algoList;
245 algoList[0][
"name"] =
"crosscorr";
246 algoList[0][
"description"] =
"Matching by cross-correlation of raster patches";
247 algoList[0][
"label"] =
"Cross Correlation";
248 algoList[1][
"name"] =
"descriptor";
249 algoList[1][
"description"] =
"Matching by feature descriptors";
250 algoList[1][
"label"] =
"Descriptor";
272 xmsg<<
"ossimAtpTool::generate() ";
281 xmsg <<
"NASA Algorithm not yet implemented!";
286 xmsg <<
"Fatal: No algorithm selected prior to execute being called. I don't know what to do!";
293 static const char* MODULE =
"ossimAtpTool::doPairwiseMatching() ";
299 xmsg <<
"No photoblock has been declared or it has less than two images. Cannot perform ATP.";
303 shared_ptr<AtpGenerator> generator;
306 std::vector<shared_ptr<Image> >& imageList =
m_photoBlock->getImageList();
307 int numImages = (int) imageList.size();
308 for (
int i=0; i<(numImages-1); i++)
310 shared_ptr<Image> imageA = imageList[i];
311 for (
int j=i+1; j<numImages; j++)
313 shared_ptr<Image> imageB = imageList[j];
319 generator->setRefImage(imageA);
320 generator->setCmpImage(imageB);
322 generator->generateTiePointList(tpList);
326 CINFO<<
"Completed pairwise match for pair "<<i<<
"-"<<j<<endl;
332 generator->setRefImage(imageB);
333 generator->setCmpImage(imageA);
335 generator->generateTiePointList(tpList);
339 CINFO<<
"Completed pairwise match for pair "<<j<<
"-"<<i<<endl;
350 CINFO<<
"\n"<<MODULE<<
"Total TPs found = "<<
m_photoBlock->getTiePointList().size()<<endl;
std::string getApplicationName() const
return the application name, as specified by argv[0]
JsonParam & getParameter(const char *paramName)
Returns a parameter (might be a null parameter if paramName not found in the configuration.
void addCommandLineOption(const ossimString &option, const ossimString &explanation)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
bool read(const std::string &str)
search for an occurance of a string in the argument list, on sucess remove that occurance from the li...
This code was derived from https://gist.github.com/mshockwave.
Class for representing MSP PhotoBlock.
void setCommandLineUsage(const ossimString &explanation)
ossimApplicationUsage * getApplicationUsage()
virtual void saveJSON(Json::Value ¶ms_json_node) const
Reads the params controlling the process from the JSON node named "parameters".
std::string asString() const
std::vector< std::shared_ptr< TiePoint > > TiePointList
virtual const char * what() const
Returns the error message.
Base class for OSSIM-based ATP generators.
THESE FUNCTIONS REQUIRE OPENCV.
bool diagnosticLevel(unsigned int level) const
Convenience method returns TRUE if the currently set diagnostic level is <= level.
static AtpConfig & instance()
Singleton implementation.
std::basic_ofstream< char > ofstream
Class for char output file streams.
virtual void loadJSON(const Json::Value ¶ms_json_node)
Reads the params controlling the process from the JSON node named "parameters".
bool readConfig(const std::string &configName="")
Singleton class maintaining parameters affecting the automatic tie point generation.