Update samples
authorSuleyman TURKMEN <sturkmen@hotmail.com>
Mon, 19 Aug 2019 21:40:45 +0000 (00:40 +0300)
committersturkmen72 <sturkmen@hotmail.com>
Fri, 20 Sep 2019 15:03:26 +0000 (18:03 +0300)
samples/cpp/dis_opticalflow.cpp
samples/cpp/ela.cpp
samples/python/squares.py

index e1f905d..3c1c22c 100644 (file)
@@ -2,30 +2,24 @@
 #include "opencv2/core/utility.hpp"
 #include "opencv2/highgui.hpp"
 #include "opencv2/imgproc.hpp"
+#include "opencv2/videoio.hpp"
 #include "opencv2/video.hpp"
 
 using namespace std;
 using namespace cv;
 
-static void help()
-{
-    printf("Usage: dis_optflow <video_file>\n");
-}
-
 int main(int argc, char **argv)
 {
-    VideoCapture cap;
+    CommandLineParser parser(argc, argv, "{ @video  | vtest.avi  | use video as input }");
+    string filename = samples::findFileOrKeep(parser.get<string>("@video"));
 
-    if (argc < 2)
-    {
-        help();
-        exit(1);
-    }
+    VideoCapture cap;
+    cap.open(filename);
 
-    cap.open(argv[1]);
     if(!cap.isOpened())
     {
-        printf("ERROR: Cannot open file %s\n", argv[1]);
+        printf("ERROR: Cannot open file %s\n", filename.c_str());
+        parser.printMessage();
         return -1;
     }
 
@@ -35,9 +29,6 @@ int main(int argc, char **argv)
     Mat hsv_split[3], hsv;
     char ret;
 
-    namedWindow("flow", 1);
-    namedWindow("orig", 1);
-
     Ptr<DenseOpticalFlow> algorithm = DISOpticalFlow::create(DISOpticalFlow::PRESET_MEDIUM);
 
     while(true)
index ca98bf9..ad76ba1 100644 (file)
@@ -5,13 +5,8 @@
   @date Jun 24, 2018
 */
 
-#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/highgui.hpp>
 #include <iostream>
-#include <vector>
-
-const char* keys =
-    "{ help h      | | Print help message. }"
-    "{ input i     | | Input image to calc ELA algorithm. }";
 
 using namespace cv;
 
@@ -48,20 +43,13 @@ static void processImage(int , void*)
 
 int main (int argc, char* argv[])
 {
+    CommandLineParser parser(argc, argv, "{ input i | ela_modified.jpg | Input image to calculate ELA algorithm. }");
+    parser.about("\nJpeg Recompression Example:\n");
+    parser.printMessage();
 
-    CommandLineParser parser(argc, argv, keys);
-    if(argc == 1 || parser.has("help"))
-    {
-        parser.printMessage();
-        std::cout << "\nJpeg Recompression Example:\n\t" << argv[0] << " --input=../../data/ela_modified.jpg\n";
-        return 0;
-    }
+    // Read the new image
+    image = imread(samples::findFile(parser.get<String>("input")));
 
-    if(parser.has("input"))
-    {
-        // Read the new image
-        image = imread(parser.get<String>("input"));
-    }
     // Check image
     if (!image.empty())
     {
index 1e7ffb8..99a69e9 100755 (executable)
@@ -32,7 +32,7 @@ def find_squares(img):
                 bin = cv.dilate(bin, None)
             else:
                 _retval, bin = cv.threshold(gray, thrs, 255, cv.THRESH_BINARY)
-            bin, contours, _hierarchy = cv.findContours(bin, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)
+            contours, _hierarchy = cv.findContours(bin, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)
             for cnt in contours:
                 cnt_len = cv.arcLength(cnt, True)
                 cnt = cv.approxPolyDP(cnt, 0.02*cnt_len, True)