some improvements on tutorials

This commit is contained in:
Suleyman TURKMEN
2017-07-26 08:39:53 +03:00
parent 8e6e05ed3f
commit 89480801b8
41 changed files with 261 additions and 188 deletions
+17 -15
View File
@@ -2,6 +2,7 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <stdio.h>
using namespace cv;
static void help()
@@ -16,14 +17,9 @@ static Scalar randomColor(RNG& rng)
return Scalar(icolor&255, (icolor>>8)&255, (icolor>>16)&255);
}
int main(int argc, char** argv)
int main()
{
cv::CommandLineParser parser(argc, argv, "{help h||}");
if (parser.has("help"))
{
help();
return 0;
}
help();
char wndname[] = "Drawing Demo";
const int NUMBER = 100;
const int DELAY = 5;
@@ -36,7 +32,7 @@ int main(int argc, char** argv)
imshow(wndname, image);
waitKey(DELAY);
for (i = 0; i < NUMBER; i++)
for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -44,14 +40,19 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
int arrowed = rng.uniform(0, 6);
if( arrowed < 3 )
line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
else
arrowedLine(image, pt1, pt2, randomColor(rng), rng.uniform(1, 10), lineType);
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
return 0;
}
for (i = 0; i < NUMBER; i++)
for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -59,8 +60,13 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
int thickness = rng.uniform(-3, 10);
int marker = rng.uniform(0, 10);
int marker_size = rng.uniform(30, 80);
rectangle( image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType );
if (marker > 5)
rectangle(image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType);
else
drawMarker(image, pt1, randomColor(rng), marker, marker_size );
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
@@ -181,7 +187,3 @@ int main(int argc, char** argv)
waitKey();
return 0;
}
#ifdef _EiC
main(1,"drawing.c");
#endif