From 142ba6900bd2ae2dcf9bc29f0465c8d87474aee4 Mon Sep 17 00:00:00 2001
From: Victor Poughon <victor.poughon@cnes.fr>
Date: Mon, 17 Dec 2018 15:32:32 +0100
Subject: [PATCH] REFAC: update examples argv parsing

---
 .../FeatureExtraction/LineSegmentDetectorExample.cxx   |  6 ++++++
 .../FeatureExtraction/RightAngleDetectionExample.cxx   | 10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
index b6e96789b7..45457bf862 100644
--- a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
+++ b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
@@ -46,6 +46,12 @@
 
 int main(int argc, char * argv[])
 {
+  if (argc != 3)
+  {
+    std::cerr << "Usage: ./LineSegmentDetectorExample input output\n";
+    return EXIT_FAILURE;
+  }
+
   const char* infname  = argv[1];
   const char* outfname = argv[2];
 
diff --git a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
index 3a059bbfb4..29c80c5426 100644
--- a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
+++ b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
@@ -52,11 +52,17 @@
 
 int main(int argc, char * argv[])
 {
+  if (argc != 6)
+  {
+    std::cerr << "Usage: ./RightAngleDetectionExample input lsdOutput rightAngleOutput angleThreshold distanceThreshold\n";
+    return EXIT_FAILURE;
+  }
+
   const char* infname                  = argv[1];
   const char* lsdOutputFilename        = argv[2];
   const char* rightAngleOutputFilename = argv[3];
-  double      angleThreshold           = atof(argv[5]);
-  double      distanceThreshold        = atof(argv[6]);
+  double      angleThreshold           = atof(argv[4]);
+  double      distanceThreshold        = atof(argv[5]);
 
   const unsigned int Dimension = 2;
   typedef unsigned char PixelType;
-- 
GitLab