Merge remote-tracking branch 'origin/2.4' into merge-2.4
[profile/ivi/opencv.git] / samples / cpp / distrans.cpp
index e10a963..706f506 100644 (file)
@@ -1,14 +1,16 @@
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/highgui/highgui.hpp"
+#include <opencv2/core/utility.hpp>
+#include "opencv2/imgproc.hpp"
+#include "opencv2/highgui.hpp"
 
 #include <stdio.h>
 
+using namespace std;
 using namespace cv;
 
-int maskSize0 = CV_DIST_MASK_5;
+int maskSize0 = DIST_MASK_5;
 int voronoiType = -1;
 int edgeThresh = 100;
-int distType0 = CV_DIST_L1;
+int distType0 = DIST_L1;
 
 // The output and temporary images
 Mat gray;
@@ -29,8 +31,8 @@ static void onTrackbar( int, void* )
         Scalar(255,0,255)
     };
 
-    int maskSize = voronoiType >= 0 ? CV_DIST_MASK_5 : maskSize0;
-    int distType = voronoiType >= 0 ? CV_DIST_L2 : distType0;
+    int maskSize = voronoiType >= 0 ? DIST_MASK_5 : maskSize0;
+    int distType = voronoiType >= 0 ? DIST_L2 : distType0;
 
     Mat edge = gray >= edgeThresh, dist, labels, dist8u;
 
@@ -104,14 +106,14 @@ static void help()
 
 const char* keys =
 {
-    "{1| |stuff.jpg|input image file}"
+    "{@image |stuff.jpg|input image file}"
 };
 
 int main( int argc, const char** argv )
 {
     help();
     CommandLineParser parser(argc, argv, keys);
-    string filename = parser.get<string>("1");
+    string filename = parser.get<string>(0);
     gray = imread(filename.c_str(), 0);
     if(gray.empty())
     {
@@ -138,17 +140,17 @@ int main( int argc, const char** argv )
             voronoiType = -1;
 
         if( c == 'c' || c == 'C' )
-            distType0 = CV_DIST_C;
+            distType0 = DIST_C;
         else if( c == '1' )
-            distType0 = CV_DIST_L1;
+            distType0 = DIST_L1;
         else if( c == '2' )
-            distType0 = CV_DIST_L2;
+            distType0 = DIST_L2;
         else if( c == '3' )
-            maskSize0 = CV_DIST_MASK_3;
+            maskSize0 = DIST_MASK_3;
         else if( c == '5' )
-            maskSize0 = CV_DIST_MASK_5;
+            maskSize0 = DIST_MASK_5;
         else if( c == '0' )
-            maskSize0 = CV_DIST_MASK_PRECISE;
+            maskSize0 = DIST_MASK_PRECISE;
         else if( c == 'v' )
             voronoiType = 0;
         else if( c == 'p' )
@@ -160,18 +162,18 @@ int main( int argc, const char** argv )
             else if( voronoiType == 1 )
             {
                 voronoiType = -1;
-                maskSize0 = CV_DIST_MASK_3;
-                distType0 = CV_DIST_C;
+                maskSize0 = DIST_MASK_3;
+                distType0 = DIST_C;
             }
-            else if( distType0 == CV_DIST_C )
-                distType0 = CV_DIST_L1;
-            else if( distType0 == CV_DIST_L1 )
-                distType0 = CV_DIST_L2;
-            else if( maskSize0 == CV_DIST_MASK_3 )
-                maskSize0 = CV_DIST_MASK_5;
-            else if( maskSize0 == CV_DIST_MASK_5 )
-                maskSize0 = CV_DIST_MASK_PRECISE;
-            else if( maskSize0 == CV_DIST_MASK_PRECISE )
+            else if( distType0 == DIST_C )
+                distType0 = DIST_L1;
+            else if( distType0 == DIST_L1 )
+                distType0 = DIST_L2;
+            else if( maskSize0 == DIST_MASK_3 )
+                maskSize0 = DIST_MASK_5;
+            else if( maskSize0 == DIST_MASK_5 )
+                maskSize0 = DIST_MASK_PRECISE;
+            else if( maskSize0 == DIST_MASK_PRECISE )
                 voronoiType = 0;
         }
     }