1010#include < string>
1111#include < vector>
1212
13+ #include " argh.h"
1314#include < DaqReader.h>
1415#ifdef DNN_READ_ONNX
1516#include < OnnxReader.h>
@@ -33,20 +34,21 @@ bool hasEnding(std::string const &fullString, std::string const &ending) {
3334 }
3435}
3536
36- // ./dnn_retrieve_result daqName quant_input? quant_output? [input1 ..]
37+ // ./dnn_retrieve_result daqName [-- quant_input] [-- quant_output] [input1 ..]
3738int main (int argc, char **argv) {
39+ argh::parser cmdl (argc, argv);
3840 google::InitGoogleLogging (argv[0 ]);
3941 FLAGS_log_dir = " /data/local/tmp/log" ;
4042 FLAGS_logbuflevel = -1 ;
4143 FLAGS_alsologtostderr = true ;
42- FLAGS_v = 5 ;
43- if (argc < 5 || argc > 6 ) {
44+ FLAGS_v = cmdl ( " v " , 5 ) ;
45+ if (! cmdl ( 2 ) ) {
4446 return -1 ;
4547 }
4648 string daqName = argv[1 ];
47- bool quant_input = std::atoi (argv[ 2 ]) != 0 ;
48- bool quant_output = std::atoi (argv[ 3 ]) != 0 ;
49- bool use_external_input = argc >= 5 ;
49+ bool quant_input = cmdl[ " quant_input " ] ;
50+ bool quant_output = cmdl[ " quant_output " ] ;
51+ bool use_external_input = cmdl ( 2 ) ;
5052
5153 std::unique_ptr<Model> model;
5254 ModelBuilder builder;
@@ -71,7 +73,7 @@ int main(int argc, char **argv) {
7173 DNN_ASSERT (model->GetOutputs ().size () == 1 , " the number of outputs can only be 1 here" );
7274 const auto outputLen = model->GetSize (model->GetOutputs ()[0 ]);
7375 std::vector<std::vector<float >> inputs;
74- for (int i = 4 , n = 0 ; i < argc ; i++, n++) {
76+ for (size_t i = 2 , n = 0 ; i < cmdl. size () ; i++, n++) {
7577 const auto &input_name = model->GetInputs ()[n];
7678 const auto input_size = model->GetSize (input_name);
7779 std::vector<float > input_data;
0 commit comments