Skip to Content

OpenCV 2 Computer Vision Application Programming Cookbook

$44.99
List Price: $0.00
Sub Title: 
<p>Over 50 recipes to master this library of programming functions for real-time computer vision</p>
Price: $44.99
Over 50 recipes to master this library of programming functions for real-time computer vision
ISBN: 
1849513244
ISBN 13: 
9781849513241
OpenCV 2 Computer Vision Application Programming Cookbook
Cover photo: 
Banner Image: 
3241OS.jpg
Available: 
Available
Rank: 
1000
Sales Rank: 
654
Language: 
English
Title Set Up Date: 
March 2011
Public Visibility Date: 
March 2011
Date Of Publication: 
May 2011
Out Of Print Date: 
March 2011
Page Count: 
304
Height: 
235
Width: 
191
Weight: 
0.50

A step-by-step guide to computer vision programming using the C++ Interface of the OpenCV 2 library including advanced concepts

Detailed Description: 

In today's digital world, images are everywhere, and with the advent of powerful and affordable computing devices, it has become possible to create sophisticated applications manipulating images and videos. Adding special effects, enhancing image features, performing object recognition, and reconstructing 3D information are tasks that can be programmed easily with the OpenCV library, which is a widely used open source library that offers a rich set of advanced computer vision algorithms.

OpenCV 2 Computer Vision Application Programming Cookbook will introduce you to numerous computer vision algorithms included in the OpenCV library. You will learn how to read, write, create and manipulate images. You will explore different techniques commonly used in image analysis and how they can be effectively implemented in C++. The book provides a complete introduction to the OpenCV library and explains how to build your first computer vision program. You will be presented with a variety of computer vision algorithms and be exposed to important concepts in image analysis that will enable you to build your own computer vision applications.

The book helps you to get started with the library, showing you how to install and deploy the OpenCV library to write effective computer vision applications following good programming practices. The techniques to process an image and its pixels using the data structures offered by the library are explained in detail. You will learn how to build and manipulate an image histogram; how to detect lines and contours. You will be introduced to the concept of mathematical morphology and image filtering. The detection and use of interest points in computer vision is presented with applications for image matching and object recognition. Techniques to achieve camera calibration and 3D reconstruction are presented.

OpenCV 2 Computer Vision Application Programming Cookbook is your guide to the development of computer vision applications. It is a comprehensive reference that exposes you to computer vision concepts illustrated with extensive examples.

  • Teaches you how to program computer vision applications in C++ using the different features of the OpenCV library
  • Demonstrates the important structures and functions of OpenCV in detail with complete working examples
  • Describes fundamental concepts in computer vision and image processing
  • Gives you advice and tips to create more effective object-oriented computer vision programs
  • Contains examples with source code and shows results obtained on real images with detailed explanations and the required screenshots

Images

Learn: 
  • Create advanced computer vision applications using sound object-oriented programming practices
  • Iterate over an image to process each of its pixels
  • Enhance an image or interesting parts of an image using histograms
  • Use mathematical morphology to process binary images and to segment images into homogenous regions
  • Filter images by modifying their frequency content
  • Detect the lines, contours , and objects contained in an image
  • Apply different interest point operators in order to characterize an image content
  • Exploit the image geometry in order to match different views of a pictured scene
  • Calibrate the camera from different image observations
  • Reconstruct selected image elements in 3D
Approach: 

This is a cookbook that shows results obtained on real images with detailed explanations and the relevant screenshots. The recipes contain code accompanied with suitable explanations that will facilitate your learning.

Audience: 

If you are a novice C++ programmer who wants to learn how to use the OpenCV library to build computer vision applications, then this cookbook is appropriate for you. It is also suitable for professional software developers wishing to be introduced to the concepts of computer vision programming. It can be used as a companion book in university-level computer vision courses. It constitutes an excellent reference for graduate students and researchers in image processing and computer vision. The book provides a good combination of basic to advanced recipes. Basic knowledge of C++ is required.

keywords: 
<p>OpenCV, OpenCV 2.2, OpenCV 2.1, computer vision book, image processing book, computer vision programming, OpenCV library, computer vision programs, computer vision algorithms, computer vision applications</p>
Special offer section
Display discount offers: 
Display discount offers
Buy 2 eBooks and Get 50% Off +
Buy OpenCV 2 Computer Vision Application Programming Cookbook with Processing 2: Creative Programming Cookbook and get 50% off both the eBooks.
 
Just add both the eBooks to your shopping cart and enter st21ot in the 'Enter Promotion Code' field. Click 'Add Promotion Code' and the discount will be applied.
View Best Selling eBook offers
Author Profile(s): 

Robert Laganière

Robert Laganière is a professor at the University of Ottawa, Canada. He received his Ph.D. degree from INRS-Telecommunications in Montreal in 1996. Dr. Laganière is a researcher in computer vision with an interest in video analysis, intelligent visual surveillance, and imagebased modeling. He is a co-founding member of the VIVA research lab. He is also a Chief Scientist at iWatchLife.com, a company offering a cloud-based solution for remote monitoring. Dr. Laganière is the co-author of Object-oriented Software Engineering published by McGraw
Hill in 2001.

Visit the author's website at http://www.laganiere.name.

Code Downloads: 
Discounted price: 
$44.99
Errata: 

Errata type: Others | Page number: 44 | Errata date: 03 Aug 2011

second paragraph: "number of pixel values per rows" should be "number of pixel values per row" p. 64, 2nd paragraph: "the ROI will determined" s/b "the ROI will be determined" p. 85, 3rd para: "the concept of the concept of" s/b "the concept of" p. 94, 3rd para: "both which are" s/b "both of which are" p. 105 2nd para: "This later is" s/b "This latter is" p. 141 1st para: "theory in details here" s/b "theory in detail here" p. 141 2nd para: "Images differ from each others" s/b "Images differ from each other" p. 169 1st para: "Therefore, do not need" s/b "Therefore, you do not need"

 

Errata type: Others | Page number: 42 | Errata date: 26 July 2011

In the second paragraph on the third line (word number 4 on the line) the word 'remainder' is misspelt as 'reminder'.

 

<p><strong>Errata Type: Grammar Page No:37 </strong></p> <p><strong></strong></p> <p>On the second paragraph line number 4 The order of the words is inverted: "... 0 corresponds to black and corresponds 255 to white." should be "... 0 corresponds to black and 255 corresponds to white."</p>
<p><strong>Errata Type:Grammar Page No:Multiple </strong></p> <p><strong></strong></p> <p>p.g 30, second paragraph: "deprecate data structure" should be "deprecated data structure"</p> <p>p.g 44, second paragraph: "number of pixel values per rows" should be "number of pixel values per row"</p> <p>p.g 44, last code sample: "div2" should be "div / 2" p.g 48, third paragraph: "contained into a memory block" should be "contained in a memory block"</p> <p>p.g 50, last paragraph: "specify larger step size" should be "specify a larger step size"</p> <p>p.g 64, 2nd paragraph: "the ROI will determined" s/b "the ROI will be determined"</p> <p>p.g 71, 2nd paragraph: "Vec3d" s/b "Vec3b"</p> <p>p.g 85, 3rd para: "the concept of the concept of" s/b "the concept of"</p> <p>p.g 90 1st para: "such that sum" s/b "such that the sum"</p> <p>p.g 94, 3rd para: "both which are" s/b "both of which are"</p> <p>p.g 95 1st code sample: "BRG" in comment s/b "BGR"</p> <p>p.g 99 1st para: "with less than" s/b "with fewer than"</p> <p>p.g 104 1st para: "consists in replacing" s/b "consists of replacing"</p> <p>p.g 105 1st &amp; 2nd para: "cv::calBackProject" s/b "cv::calcBackProject"</p> <p>p.g 105 2nd para: "This later is" s/b "This latter is"</p> <p>p.g 112 6th para: "proposes few" s/b "proposes a few"</p> <p>p.g 131 1st para: "The left square is then obtained" s/b "The right square is then obtained"</p> <p>p.g 137 2nd para: "The next recipe which presents" s/b "The next recipe presents"</p> <p>p.g 141 1st para: "theory in details here" s/b "theory in detail here"</p> <p>p.g 141 2nd para: "Images differ from each others" s/b "Images differ from each other"</p> <p>p.g 153 2nd para: "variation is and it is normally computed" s/b "variation is and is normally computed"</p> <p>p.g 156 2nd para: "since these ones are by definition" s/b "since these are by definition"</p> <p>p.g 168 &amp; p. 174 first argument to HoughLines should be "contours", not "test"</p> <p>p.g 169 1st para: "Therefore, do not need" s/b "Therefore, you do not need"</p> <p>p.g 175 2nd para: "transform adds few modifications" s/b "transform adds a few modifications"</p>
<p><strong>Errata Type:50 Page No:Code </strong></p> <p><strong></strong></p> <p>If you wish to start at the second row ... image.begin<cv::vec3b>()+image.rows SHOULD be ... image.begin<cv::vec3b>()+image.cols </cv::vec3b></cv::vec3b></p>
<p><strong>Errata Type: 50 Page No:</strong></p> <p><strong></strong></p> <p>"image.begin<cv::vec3b>()+image.rows" should be "image.begin<cv::vec3b>()+image.cols" and "end<cv::vec3b>()-image.rows" should be "end<cv::vec3b>()-image.cols" </cv::vec3b></cv::vec3b></cv::vec3b></cv::vec3b></p>
<p><strong>Errata Type: Code Page No:269</strong></p> <p><strong></strong></p> <p>On the 4th line from below, it appears "processor.etDelayetDelay(...", it should be "processor.setDelay(..."</p>
<p><strong>Errata Type: Typo Page No:42 </strong></p> <p><strong></strong></p> <p>In the second paragraph on the third line (word number 4 on the line) the word 'remainder' is misspelt as 'reminder'</p>
<p><strong>Errata Type: Code Page No: 184</strong></p> <p>On page 184: a const_iterator is used while a regular iterator should have been used since we are calling the erase method on it. You should make that change in the corresponding source file blobs.cpp. <br /> Here the updated file: <br /> #include <iostream> <br /> #include <vector> <br /> #include <opencv2> <br /> #include <opencv2> <br /> #include <opencv2> <br /> int main() <br /> { <br /> // Read input binary image <br /> cv::Mat image= cv::imread("../binaryGroup.bmp",0); <br /> if (!image.data) <br /> return 0; <br /> cv::namedWindow("Binary Image"); <br /> cv::imshow("Binary Image",image); <br /> // Get the contours of the connected components <br /> std::vector<std::vector><cv::point>&gt; contours; <br /> cv::findContours(image, <br /> contours, // a vector of contours <br /> CV_RETR_EXTERNAL, // retrieve the external contours <br /> CV_CHAIN_APPROX_NONE); // retrieve all pixels of each contours <br /> // Print contours' length <br /> std::cout &lt;&lt; "Contours: " &lt;&lt; contours.size() &lt;&lt; std::endl; <br /> std::vector<std::vector><cv::point>&gt;::const_iterator itContours= contours.begin(); <br /> for ( ; itContours!=contours.end(); ++itContours) { <br /> std::cout &lt;&lt; "Size: " &lt;&lt; itContours-&gt;size() &lt;&lt; std::endl; <br /> } <br /> // draw black contours on white image <br /> cv::Mat result(image.size(),CV_8U,cv::Scalar(255)); <br /> cv::drawContours(result,contours, <br /> -1, // draw all contours <br /> cv::Scalar(0), // in black <br /> 2); // with a thickness of 2 <br /> cv::namedWindow("Contours"); <br /> cv::imshow("Contours",result); <br /> // Eliminate too short or too long contours <br /> int cmin= 100; // minimum contour length <br /> int cmax= 1000; // maximum contour length <br /> std::vector<std::vector><cv::point>&gt;::iterator itc= contours.begin(); <br /> while (itc!=contours.end()) { <br /> if (itc-&gt;size() &lt; cmin || itc-&gt;size() &gt; cmax) <br /> itc= contours.erase(itc); <br /> else <br /> ++itc; <br /> } <br /> // draw contours on the original image <br /> cv::Mat original= cv::imread("../group.jpg"); <br /> cv::drawContours(original,contours, <br /> -1, // draw all contours <br /> cv::Scalar(255,255,255), // in white <br /> 2); // with a thickness of 2 <br /> cv::namedWindow("Contours on Animals"); <br /> cv::imshow("Contours on Animals",original); <br /> // Let's now draw black contours on white image <br /> result.setTo(cv::Scalar(255)); <br /> cv::drawContours(result,contours, <br /> -1, // draw all contours <br /> cv::Scalar(0), // in black <br /> 1); // with a thickness of 1 <br /> image= cv::imread("../binaryGroup.bmp",0); <br /> // testing the bounding box <br /> cv::Rect r0= cv::boundingRect(cv::Mat(contours[0])); <br /> cv::rectangle(result,r0,cv::Scalar(0),2); <br /> // testing the enclosing circle <br /> float radius; <br /> cv::Point2f center; <br /> cv::minEnclosingCircle(cv::Mat(contours[1]),center,radius); <br /> cv::circle(result,cv::Point(center),static_cast<int>(radius),cv::Scalar(0),2); <br /> // cv::RotatedRect rrect= cv::fitEllipse(cv::Mat(contours[1])); <br /> // cv::ellipse(result,rrect,cv::Scalar(0),2); <br /> // testing the approximate polygon <br /> std::vector<cv::point> poly; <br /> cv::approxPolyDP(cv::Mat(contours[2]),poly,5,true); <br /> std::cout &lt;&lt; "Polygon size: " &lt;&lt; poly.size() &lt;&lt; std::endl; <br /> // Iterate over each segment and draw it std::vector<cv::point>::const_iterator itp= poly.begin(); <br /> while (itp!=(poly.end()-1)) { <br /> cv::line(result,*itp,*(itp+1),cv::Scalar(0),2); <br /> ++itp; <br /> } // last point linked to first point <br /> cv::line(result,*(poly.begin()),*(poly.end()-1),cv::Scalar(20),2); <br /> // testing the convex hull <br /> std::vector<cv::point> hull; <br /> cv::convexHull(cv::Mat(contours[3]),hull); <br /> // Iterate over each segment and draw it <br /> std::vector<cv::point>::const_iterator it= hull.begin(); while (it!=(hull.end()-1)) { cv::line(result,*it,*(it+1),cv::Scalar(0),2); <br /> ++it; <br /> } // last point linked to first point <br /> cv::line(result,*(hull.begin()),*(hull.end()-1),cv::Scalar(20),2); <br /> // testing the moments <br /> // iterate over all contours <br /> itc= contours.begin(); <br /> while (itc!=contours.end()) { <br /> // compute all moments <br /> cv::Moments mom= cv::moments(cv::Mat(*itc++)); <br /> // draw mass center <br /> cv::circle(result, <br /> // position of mass center converted to integer <br /> cv::Point(mom.m10/mom.m00,mom.m01/mom.m00), <br /> 2,cv::Scalar(0),2); // draw black dot <br /> } <br /> cv::namedWindow("Some Shape descriptors"); <br /> cv::imshow("Some Shape descriptors",result); <br /> // New call to findContours but with CV_RETR_LIST flag <br /> image= cv::imread("../binaryGroup.bmp",0); <br /> // Get the contours of the connected components cv::findContours(image, <br /> contours, // a vector of contours <br /> CV_RETR_LIST, // retrieve the external and internal contours <br /> CV_CHAIN_APPROX_NONE); // retrieve all pixels of each contours <br /> // draw black contours on white image <br /> result.setTo(cv::Scalar(255)); <br /> cv::drawContours(result,contours , <br /> -1, // draw all contours <br /> cv::Scalar(0), // in black <br /> 2); // with a thickness of 2 <br /> cv::namedWindow("All Contours"); <br /> cv::imshow("All Contours",result); <br /> cv::waitKey(); <br /> return 0; <br /> } </cv::point></cv::point></cv::point></cv::point></int></cv::point></std::vector></cv::point></std::vector></cv::point></std::vector></opencv2></opencv2></opencv2></vector></iostream></p>
<p><strong>Errata Type: code Chapter 4</strong></p> <p><strong></strong></p> <p>In Chapter 4, the class ContentFinder.h is not present in the sample code. The solution to this can be found at <a target="_Blank" href="site-url">http://www.laganiere.name/opencvCookbook/</a></p>
<p><strong>Errata type: Typo | Page number: 37</strong></p> <p>The order of the words is inverted: "... 0 corresponds to black and corresponds 255 to white." should be "... 0 corresponds to black and 255 corresponds to white."</p> <p>&nbsp;</p>
<p><span><strong>Errata type: Typo | Page number: 219 |&nbsp;</strong></span><strong>Second paragraph:</strong></p> <p>This relation allows the position of the image of a 3D scene point <strong>to be predicted</strong> onto the image plane of a camera.</p> <p><strong>should be:</strong></p> <p>This relation allows <strong>to predict what will be</strong> the position of the image of a 3D scene point onto the image plane of a camera.</p>
Sample Chapter: 
http://packtlib.packtpub.com/sites/default/files/3241-chpater-5-transforming-images-with-morphological-operations.pdf
Brand: 
Open Source
Publishing division: 
OS
Pre-publication Band: 
B
Product Format: 
PB
Book Type: 
Normal
RAW: 
Normal
In PacktLib: 
Enabled
Lite Edition parent book: 
Miscellaneous Settings
Enable Google Ads conversion: 
Disabled
Upgrade authentication question: 
<p>In Chapter 7: Extracting Lines, Contours, and Components, what is the fourth-last word of the final paragraph in the section <strong>before</strong> the section: Extracting the components' contours</p>
Upgrade authentication answer: 
draw
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us