From 6aa7ec64bf797a089fdeea0e3ea1b1d80ae3f269 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Sun, 2 Jul 2017 01:42:09 -0700 Subject: [PATCH 1/6] Update example_14-01.cpp --- example_14-01.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example_14-01.cpp b/example_14-01.cpp index 08dffca..3c71726 100644 --- a/example_14-01.cpp +++ b/example_14-01.cpp @@ -28,8 +28,8 @@ void on_trackbar( int, void* ) { int main( int argc, char** argv ) { if( argc != 2 || ( g_gray = cv::imread(argv[1], 0)).empty() ) { - cout << "Find threshold dependent contours\nUsage: " < Date: Sun, 2 Jul 2017 01:43:36 -0700 Subject: [PATCH 2/6] Update example_14-02.cpp --- example_14-02.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_14-02.cpp b/example_14-02.cpp index 7d1454d..18e68fc 100644 --- a/example_14-02.cpp +++ b/example_14-02.cpp @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) { // load image or show help if no image was provided // if( argc != 2 || (img = cv::imread(argv[1],cv::IMREAD_GRAYSCALE)).empty() ) { - cout << "\nExample 14_2 Drawing Contours\nCall is:\n" << argv[0] << " image\n\n"; + cout << "\nExample 14_2: Drawing Contours\nCall is:\n" << argv[0] << " image\n\n"; return -1; } From 037a3b4400e41f5220dec0907fbf97e863a52d0e Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Sun, 2 Jul 2017 01:44:58 -0700 Subject: [PATCH 3/6] Update example_14-03.cpp --- example_14-03.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_14-03.cpp b/example_14-03.cpp index 1dd3d23..8674aef 100644 --- a/example_14-03.cpp +++ b/example_14-03.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { if( argc != 2 || (img = cv::imread( argv[1], cv::IMREAD_GRAYSCALE )).empty() ) { - cout << "\nExample 8_3 Drawing Connected componnents\n" \ + cout << "\nExample 14-3: Drawing labeled connected componnents\n" \ << "Call is:\n" < Date: Sun, 2 Jul 2017 01:59:37 -0700 Subject: [PATCH 4/6] Better text output --- example_14-04.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/example_14-04.cpp b/example_14-04.cpp index c2b148f..1a71d03 100644 --- a/example_14-04.cpp +++ b/example_14-04.cpp @@ -33,8 +33,19 @@ static vector sampleContour( const Mat& image, int n=300 ) { } } -int main(int argc, char** argv) { +void help(char** argv) { + cout << "\nExample 14-4. Using the shape context distance extractor" + << "\nNOTE: See images to try in ../shape_sample/\n" + << "\nCall:\n" << argv[0] << " \n" + << "\nExample:\n" << argv[0] << " ../shape1.jpg ../shape2.jpg\n" + << endl; +} + +int main(int argc, char** argv) { + if(argc != 3) + cout << "\nERROR: you need 2 parameters, you had " << argc << " parameters.\n" << endl; + help(argv); string path = "../data/shape_sample/"; int indexQuery = 1; From f7b1a9d69f8adad96ee1e4a62d297a66305c3bdf Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Mon, 3 Jul 2017 02:18:03 +0000 Subject: [PATCH 5/6] 14, 15 --- README.md | 12 ++++++------ example_14-01.cpp | 2 +- example_14-02.cpp | 4 +++- example_14-03.cpp | 16 ++++++++++------ example_14-04.cpp | 12 +++++++++--- example_15-01.cpp | 5 +++-- example_15-BackgroundSubtractor.cpp | 4 +++- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0466b2a..166b7fb 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ This is the example code that accompanies Learning OpenCV 3 by Adrian Kaehler and Gary Bradski (9781491937990). -~~In progress May 24, 2017~~ -~~In progress June 13, 2017~~ -~~In progress June 20, 2017~~ -~~In progress June 22, 2017~~ -In progress June 30, 2017 +* ~~In progress May 24, 2017~~ +* ~~In progress June 13, 2017~~ +* ~~In progress June 20, 2017~~ +* ~~In progress June 22, 2017~~ +* ~~In progress July 02, 2017~~ **To do:** * ~~Chapter 15~~ @@ -20,7 +20,7 @@ In progress June 30, 2017 * ~~Chapter 22~~ Checking Chapters -~~2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,~~ 14, 15 16 17 18 19 20 ~~21 22 23~~ +~~2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15~~ 16 17 18 19 20 ~~21 22 23~~ * Submit associated errata for ~~15 16~~ 17 18 19 20 21 22 * Throw in some bonus material diff --git a/example_14-01.cpp b/example_14-01.cpp index 3c71726..766aa38 100644 --- a/example_14-01.cpp +++ b/example_14-01.cpp @@ -29,7 +29,7 @@ void on_trackbar( int, void* ) { int main( int argc, char** argv ) { if( argc != 2 || ( g_gray = cv::imread(argv[1], 0)).empty() ) { cout << "\nExample 14-1: Find threshold dependent contours\nUsage:\n" <\n\n" + << "Example:\n" << argv[0] << " ../box.png\n" << endl; return -1; } diff --git a/example_14-03.cpp b/example_14-03.cpp index 8674aef..b4cc36c 100644 --- a/example_14-03.cpp +++ b/example_14-03.cpp @@ -8,14 +8,16 @@ using namespace std; int main(int argc, char* argv[]) { - cv::Mat img, img_edge, labels, img_color, stats; + cv::Mat img, img_edge, labels, centroids, img_color, stats; // load image or show help if no image was provided - if( argc != 2 + if( (argc != 2) || (img = cv::imread( argv[1], cv::IMREAD_GRAYSCALE )).empty() ) { - cout << "\nExample 14-3: Drawing labeled connected componnents\n" \ - << "Call is:\n" <\n" + << "\nExample:\n" << argv[0] << " ../HandIndoorColor.jpg\n" << endl; return -1; } @@ -23,8 +25,10 @@ int main(int argc, char* argv[]) { cv::imshow("Image after threshold", img_edge); int i, nccomps = cv::connectedComponentsWithStats ( - img_edge, labels, - stats, cv::noArray() + img_edge, + labels, + stats, + centroids ); cout << "Total Connected Components Detected: " << nccomps << endl; diff --git a/example_14-04.cpp b/example_14-04.cpp index 1a71d03..5c37d5b 100644 --- a/example_14-04.cpp +++ b/example_14-04.cpp @@ -37,15 +37,18 @@ void help(char** argv) { cout << "\nExample 14-4. Using the shape context distance extractor" << "\nNOTE: See images to try in ../shape_sample/\n" << "\nCall:\n" << argv[0] << " \n" - << "\nExample:\n" << argv[0] << " ../shape1.jpg ../shape2.jpg\n" + << "\nMISSMATCH Example:\n" << argv[0] << " ../shape_sample/1.png ../shape_sample/3.png\n" + << "\MATCH Example:\n" << argv[0] << " ../shape_sample/3.png ../shape_sample/4.png\n" << endl; } int main(int argc, char** argv) { - if(argc != 3) + help(argv); + if(argc != 3) { cout << "\nERROR: you need 2 parameters, you had " << argc << " parameters.\n" << endl; - help(argv); + return -1; + } string path = "../data/shape_sample/"; int indexQuery = 1; @@ -59,6 +62,9 @@ int main(int argc, char** argv) { float dis = mysc->computeDistance( c1, c2 ); cout << "shape context distance between " << argv[1] << " and " << argv[2] << " is: " << dis << endl; + cv::imshow("SHAPE #1", img1); + cv::imshow("SHAPE #2",img2); + cv::waitKey(); return 0; diff --git a/example_15-01.cpp b/example_15-01.cpp index 06a34cf..a8ac75d 100644 --- a/example_15-01.cpp +++ b/example_15-01.cpp @@ -9,8 +9,9 @@ using namespace std; void help(char** argv ) { cout << "\n" - << "Read out RGB pixel values and store them to disk\nCall:\n" - << argv[0] <<" avi_file\n" + << "Example: 15-1: Read out RGB pixel values and store them to disk\nCall:\n" + << argv[0] <<" \n" + << "\nExample:\n" << argv[0] << " ../tree.avi" << "\n This will store to files blines.csv, glines.csv and rlines.csv\n\n" << endl; } diff --git a/example_15-BackgroundSubtractor.cpp b/example_15-BackgroundSubtractor.cpp index 2841f57..0fcbf8b 100644 --- a/example_15-BackgroundSubtractor.cpp +++ b/example_15-BackgroundSubtractor.cpp @@ -33,7 +33,7 @@ void help() << endl << "Usage:" << endl << "./example_15-BackgroundSubtractor {<#framesTraining> -vid