From 31d5af7b92f9306b37ecb0dda0674bfb02fdb3e9 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Sat, 1 Jul 2017 04:36:43 +0000 Subject: [PATCH] finished adding headers and output to the program examples in ch2 --- example_02-07.cpp | 16 ++++++++++++++++ example_02-08.cpp | 20 +++++++++++++++++++- example_02-09.cpp | 19 +++++++++++++++++++ example_02-10.cpp | 17 +++++++++++++++++ example_02-11.cpp | 1 + example_08-02.cpp | 2 +- 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/example_02-07.cpp b/example_02-07.cpp index 1000af5..e7f3a28 100644 --- a/example_02-07.cpp +++ b/example_02-07.cpp @@ -2,7 +2,23 @@ // 2 #include +void help(char** argv ) { + std::cout << "\n" + << "\nExample 2-7. The Canny edge detector writes its output to a single-channel (grayscale) image" + << "\nCall:\n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../fruits.jpg\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } cv::Mat img_rgb, img_gry, img_cny; diff --git a/example_02-08.cpp b/example_02-08.cpp index 616cec3..a8fc46f 100644 --- a/example_02-08.cpp +++ b/example_02-08.cpp @@ -1,8 +1,26 @@ -// In Example 2-9, we show a simple way to read and write pixel values from Example 2-8. +// Example 2-8. Combining the pyramid down operator (twice) and the Canny +// subroutine in a simple image pipeline //2 #include +void help(char** argv ) { + std::cout << "\n" + << "\nExample 2-8. Combining the pyramid down operator (twice) and the Canny" + << "\n subroutine in a simple image pipeline" + << "\nCall:\n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../fruits.jpg\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } cv::Mat img_rgb, img_gry, img_cny, img_pyr, img_pyr2; diff --git a/example_02-09.cpp b/example_02-09.cpp index d1d0e9d..0405754 100644 --- a/example_02-09.cpp +++ b/example_02-09.cpp @@ -1,6 +1,25 @@ +// Example 2-9. Getting and setting pixels in Example 2-8 + #include +void help(char** argv ) { + std::cout << "\n" + << "\nExample 2-9. Getting and setting pixels in Example 2-8" + << "\nCall:\n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../fruits.jpg\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } + cv::Mat img_rgb, img_gry, img_cny, img_pyr, img_pyr2; diff --git a/example_02-10.cpp b/example_02-10.cpp index 2fe8aea..77fc2b1 100644 --- a/example_02-10.cpp +++ b/example_02-10.cpp @@ -3,7 +3,24 @@ #include #include +void help(char** argv ) { + std::cout << "\n" + << "\nxample 2-10. The same object can load videos from a camera or a file" + << "\nCall:\n" + << argv[0] <<" [path/image]\n" + << "\nor, read from camera:\n" + << argv[0] + << "\nFor example:\n" + << argv[0] << " ../tree.avi\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + help(argv); + + cv::namedWindow( "Example 2-10", cv::WINDOW_AUTOSIZE ); cv::VideoCapture cap; diff --git a/example_02-11.cpp b/example_02-11.cpp index dc7df2f..14416b7 100644 --- a/example_02-11.cpp +++ b/example_02-11.cpp @@ -11,6 +11,7 @@ void help(char** argv ) { << argv[0] <<" \n" << "For example:\n" << argv[0] << " ../tree.avi ../vout.avi\n" + << "\nThen read it with:\n ./example_02-10 ../vout.avi\n" << std::endl; } diff --git a/example_08-02.cpp b/example_08-02.cpp index de51b9e..b7ce3bc 100644 --- a/example_08-02.cpp +++ b/example_08-02.cpp @@ -9,7 +9,7 @@ using namespace std; int main(int argc, char** argv) { cout << "\nExample 8-2. Using cv::FileStorage to create a .yml data file\n" - << argv[0] << endl + << argv[0] << endl; cv::FileStorage fs("test.yml", cv::FileStorage::WRITE);