add default file to load in case sample was run without command line arguments

pull/3582/head
Tzafrir 10 years ago
parent 28833421ae
commit 997dded1ac
  1. 4
      samples/gpu/farneback_optical_flow.cpp
  2. 14
      samples/gpu/hog.cpp
  3. 12
      samples/gpu/opengl.cpp
  4. 19
      samples/gpu/optical_flow.cpp
  5. 4
      samples/gpu/pyrlk_optical_flow.cpp

@ -44,8 +44,8 @@ static void colorizeFlow(const Mat &u, const Mat &v, Mat &dst)
int main(int argc, char **argv)
{
CommandLineParser cmd(argc, argv,
"{ l left | | specify left image }"
"{ r right | | specify right image }"
"{ l left | ../data/basketball1.png | specify left image }"
"{ r right | ../data/basketball2.png | specify right image }"
"{ h help | | print help message }");
cmd.about("Farneback's optical flow sample.");

@ -115,11 +115,19 @@ int main(int argc, char** argv)
{
try
{
Args args;
if (argc < 2)
{
printHelp();
Args args = Args::read(argc, argv);
if (help_showed)
return -1;
args.camera_id = 0;
args.src_is_camera = true;
}
else
{
args = Args::read(argc, argv);
if (help_showed)
return -1;
}
App app(args);
app.run();
}

@ -14,6 +14,9 @@ int main()
#define NOMINMAX 1
#include <windows.h>
#endif
#if defined(_WIN64)
#include <windows.h>
#endif
#if defined(__APPLE__)
#include <OpenGL/gl.h>
@ -55,16 +58,19 @@ void draw(void* userdata)
int main(int argc, char* argv[])
{
string filename;
if (argc < 2)
{
cout << "Usage: " << argv[0] << " image" << endl;
return -1;
filename = "../data/lena.jpg";
}
else
filename = argv[1];
Mat img = imread(argv[1]);
Mat img = imread(filename);
if (img.empty())
{
cerr << "Can't open image " << argv[1] << endl;
cerr << "Can't open image " << filename << endl;
return -1;
}

@ -135,23 +135,30 @@ static void showFlow(const char* name, const GpuMat& d_flowx, const GpuMat& d_fl
int main(int argc, const char* argv[])
{
string filename1, filename2;
if (argc < 3)
{
cerr << "Usage : " << argv[0] << "<frame0> <frame1>" << endl;
return -1;
cerr << "Usage : " << argv[0] << " <frame0> <frame1>" << endl;
filename1 = "../data/basketball1.png";
filename2 = "../data/basketball2.png";
}
else
{
filename1 = argv[1];
filename2 = argv[2];
}
Mat frame0 = imread(argv[1], IMREAD_GRAYSCALE);
Mat frame1 = imread(argv[2], IMREAD_GRAYSCALE);
Mat frame0 = imread(filename1, IMREAD_GRAYSCALE);
Mat frame1 = imread(filename2, IMREAD_GRAYSCALE);
if (frame0.empty())
{
cerr << "Can't open image [" << argv[1] << "]" << endl;
cerr << "Can't open image [" << filename1 << "]" << endl;
return -1;
}
if (frame1.empty())
{
cerr << "Can't open image [" << argv[2] << "]" << endl;
cerr << "Can't open image [" << filename2 << "]" << endl;
return -1;
}

@ -119,8 +119,8 @@ int main(int argc, const char* argv[])
{
const char* keys =
"{ h help | | print help message }"
"{ l left | | specify left image }"
"{ r right | | specify right image }"
"{ l left | ../data/pic1.png | specify left image }"
"{ r right | ../data/pic2.png | specify right image }"
"{ gray | | use grayscale sources [PyrLK Sparse] }"
"{ win_size | 21 | specify windows size [PyrLK] }"
"{ max_level | 3 | specify max level [PyrLK] }"

Loading…
Cancel
Save