Skip to content

Commit

Permalink
using argv[0] represent binary executable files' name in help() function
Browse files Browse the repository at this point in the history
in sample codes instead of cpp files' name.
  • Loading branch information
MoonChasing committed Feb 28, 2020
1 parent 8b5efc6 commit 98db891
Show file tree
Hide file tree
Showing 30 changed files with 218 additions and 207 deletions.
10 changes: 5 additions & 5 deletions samples/cpp/3calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ using namespace std;

enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 };

static void help()
static void help(char** argv)
{
printf( "\nThis is a camera calibration sample that calibrates 3 horizontally placed cameras together.\n"
"Usage: 3calibration\n"
"Usage: %s\n"
" -w=<board_width> # the number of inner corners per one of board dimension\n"
" -h=<board_height> # the number of inner corners per another board dimension\n"
" [-s=<squareSize>] # square size in some user-defined units (1 by default)\n"
Expand All @@ -29,7 +29,7 @@ static void help()
" [-a=<aspectRatio>] # fix aspect ratio (fx/fy)\n"
" [-p] # fix the principal point at the center\n"
" [input_data] # input data - text file with a list of the images of the board\n"
"\n" );
"\n", argv[0] );

}

Expand Down Expand Up @@ -190,7 +190,7 @@ int main( int argc, char** argv )
"{zt||}{a|1|}{p||}{@input||}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
boardSize.width = parser.get<int>("w");
Expand All @@ -207,7 +207,7 @@ int main( int argc, char** argv )
inputFilename = parser.get<string>("@input");
if (!parser.check())
{
help();
help(argv);
parser.printErrors();
return -1;
}
Expand Down
10 changes: 5 additions & 5 deletions samples/cpp/calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const char* liveCaptureHelp =
" 'g' - start capturing images\n"
" 'u' - switch undistortion on/off\n";

static void help()
static void help(char** argv)
{
printf( "This is a camera calibration sample.\n"
"Usage: calibration\n"
"Usage: %s\n"
" -w=<board_width> # the number of inner corners per one of board dimension\n"
" -h=<board_height> # the number of inner corners per another board dimension\n"
" [-pt=<pattern>] # the type of pattern: chessboard or circles' grid\n"
Expand All @@ -74,7 +74,7 @@ static void help()
" # the text file can be generated with imagelist_creator\n"
" # - name of video file with a video of the board\n"
" # if input_data not specified, a live view from the camera is used\n"
"\n" );
"\n", argv[0] );
printf("\n%s",usage);
printf( "\n%s", liveCaptureHelp );
}
Expand Down Expand Up @@ -343,7 +343,7 @@ int main( int argc, char** argv )
"{@input_data|0|}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
boardSize.width = parser.get<int>( "w" );
Expand Down Expand Up @@ -383,7 +383,7 @@ int main( int argc, char** argv )
inputFilename = parser.get<string>("@input_data");
if (!parser.check())
{
help();
help(argv);
parser.printErrors();
return -1;
}
Expand Down
12 changes: 6 additions & 6 deletions samples/cpp/camshiftdemo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <opencv2/core/utility.hpp>
#include "opencv2/core/utility.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
Expand Down Expand Up @@ -57,13 +57,13 @@ string hot_keys =
"\tp - pause video\n"
"To initialize tracking, select the object with mouse\n";

static void help()
static void help(const char** argv)
{
cout << "\nThis is a demo that shows mean-shift based tracking\n"
"You select a color objects such as your face and it tracks it.\n"
"This reads from video camera (0 by default, or the camera number the user enters\n"
"Usage: \n"
" ./camshiftdemo [camera number]\n";
"Usage: \n\t";
cout << argv[0] << " [camera number]\n";
cout << hot_keys;
}

Expand All @@ -82,15 +82,15 @@ int main( int argc, const char** argv )
CommandLineParser parser(argc, argv, keys);
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
int camNum = parser.get<int>(0);
cap.open(camNum);

if( !cap.isOpened() )
{
help();
help(argv);
cout << "***Could not initialize capturing...***\n";
cout << "Current parameter's value: \n";
parser.printMessage();
Expand Down
17 changes: 9 additions & 8 deletions samples/cpp/contours2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
using namespace cv;
using namespace std;

static void help()
static void help(char** argv)
{
cout
<< "\nThis program illustrates the use of findContours and drawContours\n"
<< "The original image is put up along with the image of drawn contours\n"
<< "Usage:\n"
<< "./contours2\n"
<< "\nA trackbar is put up which controls the contour level from -3 to 3\n"
<< endl;
<< "\nThis program illustrates the use of findContours and drawContours\n"
<< "The original image is put up along with the image of drawn contours\n"
<< "Usage:\n";
cout
<< argv[0]
<< "\nA trackbar is put up which controls the contour level from -3 to 3\n"
<< endl;
}

const int w = 500;
Expand All @@ -38,7 +39,7 @@ int main( int argc, char** argv)
cv::CommandLineParser parser(argc, argv, "{help h||}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
Mat img = Mat::zeros(w, w, CV_8UC1);
Expand Down
6 changes: 3 additions & 3 deletions samples/cpp/convexhull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
using namespace cv;
using namespace std;

static void help()
static void help(char** argv)
{
cout << "\nThis sample program demonstrates the use of the convexHull() function\n"
<< "Call:\n"
<< "./convexhull\n" << endl;
<< argv[0] << endl;
}

int main( int argc, char** argv )
{
CommandLineParser parser(argc, argv, "{help h||}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
Mat img(500, 500, CV_8UC3);
Expand Down
8 changes: 4 additions & 4 deletions samples/cpp/cout_mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
using namespace std;
using namespace cv;

static void help()
static void help(char** argv)
{
cout
<< "\n------------------------------------------------------------------\n"
<< " This program shows the serial out capabilities of cv::Mat\n"
<< "That is, cv::Mat M(...); cout << M; Now works.\n"
<< "Output can be formatted to OpenCV, matlab, python, numpy, csv and \n"
<< "C styles Usage:\n"
<< "./cvout_sample\n"
<< "------------------------------------------------------------------\n\n"
<< argv[0]
<< "\n------------------------------------------------------------------\n\n"
<< endl;
}

Expand All @@ -30,7 +30,7 @@ int main(int argc, char** argv)
cv::CommandLineParser parser(argc, argv, "{help h||}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}
Mat I = Mat::eye(4, 4, CV_64F);
Expand Down
16 changes: 8 additions & 8 deletions samples/cpp/delaunay2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
using namespace cv;
using namespace std;

static void help()
static void help(char** argv)
{
cout << "\nThis program demonstrates iterative construction of\n"
"delaunay triangulation and voronoi tessellation.\n"
"It draws a random set of points in an image and then delaunay triangulates them.\n"
"Usage: \n"
"./delaunay \n"
"\nThis program builds the triangulation interactively, you may stop this process by\n"
"hitting any key.\n";
"delaunay triangulation and voronoi tessellation.\n"
"It draws a random set of points in an image and then delaunay triangulates them.\n"
"Usage: \n";
cout << argv[0];
cout << "\n\nThis program builds the triangulation interactively, you may stop this process by\n"
"hitting any key.\n";
}

static void draw_subdiv_point( Mat& img, Point2f fp, Scalar color )
Expand Down Expand Up @@ -108,7 +108,7 @@ int main( int argc, char** argv )
cv::CommandLineParser parser(argc, argv, "{help h||}");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}

Expand Down
13 changes: 7 additions & 6 deletions samples/cpp/detect_blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ using namespace std;
using namespace cv;


static void help()
static void help(char** argv)
{
cout << "\n This program demonstrates how to use BLOB to detect and filter region \n"
"Usage: \n"
" ./detect_blob <image1(detect_blob.png as default)>\n"
"Press a key when image window is active to change descriptor";
<< "Usage: \n"
<< argv[0]
<< " <image1(detect_blob.png as default)>\n"
<< "Press a key when image window is active to change descriptor";
}


Expand Down Expand Up @@ -74,7 +75,7 @@ int main(int argc, char *argv[])
cv::CommandLineParser parser(argc, argv, "{@input |detect_blob.png| }{h help | | }");
if (parser.has("h"))
{
help();
help(argv);
return 0;
}
fileName = parser.get<string>("@input");
Expand Down Expand Up @@ -120,7 +121,7 @@ int main(int argc, char *argv[])
uchar c3 = (uchar)rand();
palette.push_back(Vec3b(c1, c2, c3));
}
help();
help(argv);


// These descriptors are going to be detecting and computing BLOBS with 6 different params
Expand Down
14 changes: 7 additions & 7 deletions samples/cpp/detect_mser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ using namespace std;
using namespace cv;


static void help()
static void help(char** argv)
{
cout << "\nThis program demonstrates how to use MSER to detect extremal regions\n"
"Usage:\n"
" ./detect_mser <image1(without parameter a synthetic image is used as default)>\n"
"Press esc key when image window is active to change descriptor parameter\n"
"Press 2, 8, 4, 6, +, -, or 5 keys in openGL windows to change view or use mouse\n";
"Usage:\n"
<< argv[0] << " <image1(without parameter a synthetic image is used as default)>\n"
"Press esc key when image window is active to change descriptor parameter\n"
"Press 2, 8, 4, 6, +, -, or 5 keys in openGL windows to change view or use mouse\n";
}

struct MSERParams
Expand Down Expand Up @@ -405,7 +405,7 @@ int main(int argc, char *argv[])
cv::CommandLineParser parser(argc, argv, "{ help h | | }{ @input | | }");
if (parser.has("help"))
{
help();
help(argv);
return 0;
}

Expand All @@ -431,7 +431,7 @@ int main(int argc, char *argv[])
for (int i = 0; i<=numeric_limits<uint16_t>::max(); i++)
palette.push_back(Vec3b((uchar)rand(), (uchar)rand(), (uchar)rand()));

help();
help(argv);

MSERParams params;

Expand Down
8 changes: 4 additions & 4 deletions samples/cpp/digits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const int SZ = 20; // size of each digit is SZ x SZ
const int CLASS_N = 10;
const char* DIGITS_FN = "digits.png";

static void help()
static void help(char** argv)
{
cout <<
"\n"
Expand All @@ -38,7 +38,7 @@ static void help()
" http://www.robots.ox.ac.uk/~vgg/publications/2012/Arandjelovic12/arandjelovic12.pdf\n"
"\n"
"Usage:\n"
" ./digits\n" << endl;
<< argv[0] << endl;
}

static void split2d(const Mat& image, const Size cell_size, vector<Mat>& cells)
Expand Down Expand Up @@ -299,9 +299,9 @@ static void shuffle(vector<Mat>& digits, vector<int>& labels)
labels = shuffled_labels;
}

int main()
int main(int /* argc */, char* argv[])
{
help();
help(argv);

vector<Mat> digits;
vector<int> labels;
Expand Down
10 changes: 5 additions & 5 deletions samples/cpp/distrans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ static void onTrackbar( int, void* )
imshow("Distance Map", dist8u );
}

static void help()
static void help(const char** argv)
{
printf("\nProgram to demonstrate the use of the distance transform function between edge images.\n"
"Usage:\n"
"./distrans [image_name -- default image is stuff.jpg]\n"
"%s [image_name -- default image is stuff.jpg]\n"
"\nHot keys: \n"
"\tESC - quit the program\n"
"\tC - use C/Inf metric\n"
Expand All @@ -102,7 +102,7 @@ static void help()
"\t0 - use precise distance transform\n"
"\tv - switch to Voronoi diagram mode\n"
"\tp - switch to pixel-based Voronoi diagram mode\n"
"\tSPACE - loop through all the modes\n\n");
"\tSPACE - loop through all the modes\n\n", argv[0]);
}

const char* keys =
Expand All @@ -113,15 +113,15 @@ const char* keys =
int main( int argc, const char** argv )
{
CommandLineParser parser(argc, argv, keys);
help();
help(argv);
if (parser.has("help"))
return 0;
string filename = parser.get<string>(0);
gray = imread(samples::findFile(filename), 0);
if(gray.empty())
{
printf("Cannot read image file: %s\n", filename.c_str());
help();
help(argv);
return -1;
}

Expand Down
Loading

0 comments on commit 98db891

Please sign in to comment.