From 997dded1ac5c145e982e24da36bb10ec9a04a294 Mon Sep 17 00:00:00 2001 From: Tzafrir Date: Tue, 6 Jan 2015 16:13:46 +0200 Subject: [PATCH] add default file to load in case sample was run without command line arguments --- samples/gpu/farneback_optical_flow.cpp | 4 ++-- samples/gpu/hog.cpp | 14 +++++++++++--- samples/gpu/opengl.cpp | 12 +++++++++--- samples/gpu/optical_flow.cpp | 19 +++++++++++++------ samples/gpu/pyrlk_optical_flow.cpp | 4 ++-- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/samples/gpu/farneback_optical_flow.cpp b/samples/gpu/farneback_optical_flow.cpp index 6fc3f93..b8ed55e 100644 --- a/samples/gpu/farneback_optical_flow.cpp +++ b/samples/gpu/farneback_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."); diff --git a/samples/gpu/hog.cpp b/samples/gpu/hog.cpp index 59ea44f..4b963d3 100644 --- a/samples/gpu/hog.cpp +++ b/samples/gpu/hog.cpp @@ -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(); } diff --git a/samples/gpu/opengl.cpp b/samples/gpu/opengl.cpp index eef8e1a..e3e3ddc 100644 --- a/samples/gpu/opengl.cpp +++ b/samples/gpu/opengl.cpp @@ -14,6 +14,9 @@ int main() #define NOMINMAX 1 #include #endif +#if defined(_WIN64) + #include +#endif #if defined(__APPLE__) #include @@ -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; } diff --git a/samples/gpu/optical_flow.cpp b/samples/gpu/optical_flow.cpp index 8c6bc74..7d625de 100644 --- a/samples/gpu/optical_flow.cpp +++ b/samples/gpu/optical_flow.cpp @@ -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] << " " << endl; - return -1; + cerr << "Usage : " << argv[0] << " " << 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; } diff --git a/samples/gpu/pyrlk_optical_flow.cpp b/samples/gpu/pyrlk_optical_flow.cpp index dc5de6c..febc28f 100644 --- a/samples/gpu/pyrlk_optical_flow.cpp +++ b/samples/gpu/pyrlk_optical_flow.cpp @@ -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] }" -- 2.7.4