Update samples
authorSuleyman TURKMEN <sturkmen@hotmail.com>
Wed, 22 Jul 2020 04:29:56 +0000 (07:29 +0300)
committerSuleyman TURKMEN <sturkmen@hotmail.com>
Thu, 23 Jul 2020 17:09:37 +0000 (20:09 +0300)
samples/cpp/create_mask.cpp
samples/cpp/intersectExample.cpp
samples/cpp/squares.cpp

index dc54953..67b0ec9 100644 (file)
@@ -74,9 +74,7 @@ void mouseHandler(int event, int x, int y, int, void*)
         final = Mat::zeros(src.size(), CV_8UC3);
         mask = Mat::zeros(src.size(), CV_8UC1);
 
-        vector<vector<Point> > vpts;
-        vpts.push_back(pts);
-        fillPoly(mask, vpts, Scalar(255, 255, 255), 8, 0);
+        fillPoly(mask, pts, Scalar(255, 255, 255), 8, 0);
         bitwise_and(src, src, final, mask);
         imshow("Mask", mask);
         imshow("Result", final);
index a8a8972..187aebb 100644 (file)
@@ -50,9 +50,7 @@ static float drawIntersection(Mat &image, vector<Point> polygon1, vector<Point>
         {
             fillColor = Scalar(0, 0, 255);
         }
-        vector<vector<Point> > pp;
-        pp.push_back(intersectionPolygon);
-        fillPoly(image, pp, fillColor);
+        fillPoly(image, intersectionPolygon, fillColor);
     }
     polylines(image, polygons, true, Scalar(0, 0, 0));
 
index 36535d1..042a716 100644 (file)
@@ -121,21 +121,6 @@ static void findSquares( const Mat& image, vector<vector<Point> >& squares )
     }
 }
 
-
-// the function draws all the squares in the image
-static void drawSquares( Mat& image, const vector<vector<Point> >& squares )
-{
-    for( size_t i = 0; i < squares.size(); i++ )
-    {
-        const Point* p = &squares[i][0];
-        int n = (int)squares[i].size();
-        polylines(image, &p, &n, 1, true, Scalar(0,255,0), 3, LINE_AA);
-    }
-
-    imshow(wndname, image);
-}
-
-
 int main(int argc, char** argv)
 {
     static const char* names[] = { "pic1.png", "pic2.png", "pic3.png",
@@ -148,8 +133,6 @@ int main(int argc, char** argv)
      names[1] =  "0";
     }
 
-    vector<vector<Point> > squares;
-
     for( int i = 0; names[i] != 0; i++ )
     {
         string filename = samples::findFile(names[i]);
@@ -160,8 +143,11 @@ int main(int argc, char** argv)
             continue;
         }
 
+        vector<vector<Point> > squares;
         findSquares(image, squares);
-        drawSquares(image, squares);
+
+        polylines(image, squares, true, Scalar(0, 255, 0), 3, LINE_AA);
+        imshow(wndname, image);
 
         int c = waitKey();
         if( c == 27 )