From 1b37e8a954fd781fe7c2e7a6866479b815149763 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Fri, 30 Jun 2017 18:24:00 +0000 Subject: [PATCH] adding headers and output --- example_02-02.cpp | 18 ++++++++++++++++++ example_02-03.cpp | 18 +++++++++++++++++- example_02-04.cpp | 20 ++++++++++++++++++++ example_02-05.cpp | 19 +++++++++++++++++++ example_02-06.cpp | 18 ++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) diff --git a/example_02-02.cpp b/example_02-02.cpp index af07832..e126d7c 100644 --- a/example_02-02.cpp +++ b/example_02-02.cpp @@ -1,8 +1,26 @@ +// Example 2-2. Same as Example 2-1 but employing the “using namespace” directive + #include "opencv2/highgui/highgui.hpp" +#include using namespace cv; +void help(char** argv ) { + std::cout << "\n" + << "2.2: Like 2.1, but 'using namespace cv: \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; + } Mat img = imread( argv[1], -1 ); diff --git a/example_02-03.cpp b/example_02-03.cpp index 528331f..0d9f479 100644 --- a/example_02-03.cpp +++ b/example_02-03.cpp @@ -1,10 +1,26 @@ +// Example 2-3. A simple OpenCV program for playing a video file from disk + #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include using namespace std; +void help(char** argv ) { + std::cout << "\n" + << "2-03: play video from disk \n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../tree.avi\n" + << std::endl; +} + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } cv::namedWindow( "Example 2-3", cv::WINDOW_AUTOSIZE ); @@ -30,7 +46,7 @@ int main( int argc, char** argv ) { // cout <<((c&(0x1<<(31-i)))?1:0); // } // cout <= 0 ) { // break; // } diff --git a/example_02-04.cpp b/example_02-04.cpp index ced80fa..12e1ee2 100644 --- a/example_02-04.cpp +++ b/example_02-04.cpp @@ -1,3 +1,6 @@ +//Example 2-4. Adding a trackbar slider to the basic viewer window for moving around +//within the video file + #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include @@ -18,7 +21,24 @@ void onTrackbarSlide( int pos, void *) { g_dontset = 0; } + + +void help(char** argv ) { + std::cout << "\n" + << "2-04: Addeing a trackbar to a basic viewer for moving w/in the video file \n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../tree.avi\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } cv::namedWindow( "Example 2-4", cv::WINDOW_AUTOSIZE ); diff --git a/example_02-05.cpp b/example_02-05.cpp index 082d133..4de0605 100644 --- a/example_02-05.cpp +++ b/example_02-05.cpp @@ -1,6 +1,25 @@ +// Example 2-5. Loading and then smoothing an image before it is displayed on the screen + #include + + +void help(char** argv ) { + std::cout << "\n" + << "2-05: load and smooth an image before displaying \n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../tree.avi\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } // Load an image specified on the command line. // diff --git a/example_02-06.cpp b/example_02-06.cpp index 46f39bd..dc25a12 100644 --- a/example_02-06.cpp +++ b/example_02-06.cpp @@ -1,6 +1,24 @@ +// Example 2-6. Using cv::pyrDown() to create a new image that is half the width and +// height of the input image #include +void help(char** argv ) { + std::cout << "\n" + << "2-06: AUsing cv::pyrDown() to create a new image that is half the width and" + << " height of the input image\n" + << argv[0] <<" \n" + << "For example:\n" + << argv[0] << " ../faces.png\n" + << std::endl; +} + + int main( int argc, char** argv ) { + + if (argc != 2) { + help(argv); + return 0; + } cv::Mat img1,img2;