Review of Packt Publishing’s ‘Instant OpenCV Starter’ book

A few weeks ago I got a request from a Marketing Research Executive Mr. Dyson D’Souza, who works for Packt Publishing for reviewing a book titled “Instant OpenCV Starter“. He approached me seeing my LinkedIn profile, which you may visit via the widget on the right sidebar of this page. I was quite delighted by the opportunity. He said he was not looking for a detailed review, just a few lines mentioning my honest thoughts on the book with a link to the book page was sufficient.  He was quite honest in mentioning that I would not be paid for it and neither would my name appear in the book. Nevertheless, because I love OpenCV, I went ahead. He also offered me one complimentary eBook of my choice for free!

He sent me a link to download the ebook. I downloaded the book and started reviewing it. I could not help being a little more detailed than he expected, me being a detail-oriented person! :p

I’m including specific points to what could improve the book w.r.t. each page number and will also be writing an overall conclusion about the current state of this book. At some places, I check if the actual program is working as expected (shown), while on others I went by the semantics of the codes. Same is true for the installation steps. But I did check the veracity of everything that went into the book.

P.S. : I am new to book reviewing. So, any justified suggestions, comments, improvements and pointing out mistakes are always welcome. And I also issue here a spoiler alert to avoid your premature exposure to the climax of the book! 😉

Without much ado, here it goes:

The good things first:

The best thing about this book is the fact that it takes a yet-to-walk-baby in OpenCV that a beginner is, systematically from crawling (What is OpenCV? and Image basics) to standing up (Installation) to walking (reading images) to running in OpenCV (Pixel manipulation and Image conversions) to eventually flying (Steganography, Edge detection and Real-time video processing using webcam), all in a few pages of this small book. This is a no non-sense quickest starting guide for OpenCV I have seen till date. I wish I had used it when I was a beginner.

It steps through each word or keyword of each line of code of each code block. Making it very lucid for a starter.

Now the could-be-better things:

Page-wise review comments: OpenCV Installation

Page no.Comment
3Link to BSD license should have been included Free BSD and Modified BSD
6-7Which things to check/uncheck on the CMake window. What do do if it shows things in red? How to resolve the dependencies? Some details on what are "Configure", "Generate", "make", "make install" in the context of CMake may help because the reader may not have any idea on what they do.
8What to do if the OpenCV compilation does not complete successfully, but with errors? How to debug them? What are the most common errors and what are their solutions?
9What exactly is happening when we are configuring Linux? Why is it necessary?

There are some more issues in the installation part of OpenCV in the book that I would like to be addressed viz. :

  1. Installation process for Microsoft Visual Studio is missing and is necessary as many software companies and students use it.
  2. All installation steps need to address: “Why we are doing what we are doing?”
  3. All installation links are subject to change, so instead of specific links could we know generic way to find out things and download them. e.g. Link to download OpenCV in this book is for OpenCV version 2.4.2 while the current version while I write this is: 2.4.6.

Page-wise review comments: Image Basics

Page No.Comments
17Why grey images have range from 0-255?
17-18Would be good if can see the actual visualizations of the image matrices shown on these pages as shown below.


Now, lets turn to the programming tasks illustrated in the book.

Page-wise review comments: OpenCV Programs

Page No.Comments
20Actual example for "image=imread("/lena.jpg");" would be better like "C: \openCV_Projects\lena.jpg"
23resize(org, resized, Size(), 0.5, 0.5, INTER_LINEAR); -> A one line description of Bilinear Interpolation would do good to the user. Also, good links to explore concepts in more depth would be helpful too, bilinear interpolation being a case under view here.
Also, here what happens when the size is left to Size() or '0' isn't told. So, how does the function calculate what size the output image should be if we don't give an explicit size?
26-27Could elaborate on how RGB images are 3 channeled and how they come together to form the color image we see.
27What's Vec3b exactly?
Here, the numbers [0], [1], [2]are used to access the blue, green, and red components respectively. Why the sequence BGR when we call color images as RGB images? What are other methods to access pixels in OpenCV? [In case of color images we have three uchar items per column. This may be considered a short vector of uchar items, that has been baptized in OpenCV with the Vec3b name. To access the n-th sub column we use simple operator[] access. It’s important to remember that OpenCV iterators go through the columns and automatically skip to the next row. Therefore in case of color images if you use a simple uchar iterator you’ll be able to access only the blue channel values.]
28How to convert the thresholded output image on page 28 back to color (RGB) image?
29What exactly is CV_8UC1? What is CV_BGR2GRAY, HSV, CIELAB? What is color space model?
36Mistake on line 2 : 0x0F should be 0xF0.

The recovered hidden image cannot be so smooth as it consists of only the MSB of the steganographed image. This result is misleading. Kindly put up the correct result or disprove me.
37There is no need to use arguments for main function if you are not passing them explicitly as you seem to be getting the image path hardcoded in the code.
int main( int argc, char** argv )

These comments could add more value in the code:

After the code line: Canny(gray, edge, edgeThresh, edgeThresh*3, 3);
Add this: // The edges detected by Canny on the grayscale image renders a binary image "edge".

After the code line: cedge = Scalar::all(0);
Add this: // While the image.copyTo function renders the detected edges in color in the image "cedge". Here only the non-zero pixels i.e. edges detected in the "edge" image from the "image" image are copied to cedge.

More info on Canny function and Canny Edge Detector
39Sometimes for some computers the default VideoCapture device ID '0' will show blank/black screen. In those cases try using:

VideoCapture capture(1);

or other numbers for your webcam device ID.

Overall this book is an excellent starting point for beginners to start programming in Image Processing and Computer Vision using OpenCV. This book will surely generate a lot of interest in students who I’m quite sure will get hooked to the enormous possibilities presented by the OpenCV library.

There is a real-time video processing tutorial in the book using webcam which converts a color (RGB) video to a Gray video in real time. I wrote something similar to convert your real-time color (RGB) video to an edge-detected video that shows you the edges of the ghost you might look like! 😉 You can find out if you have any wrinkles too using this code snippet! 😛

Here’s the code:

#include <opencv2/opencv.hpp>

using namespace cv;

int main(int, char**)
    VideoCapture cap(1); // open the default camera;
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    Mat edges, smooth;
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); // Smoothen for noise
	// bilateralFilter(edges, smooth, -1, 20, 7); 
        // Edge-detection slows down in this filter as it smoothens the
        // image, while preserving the edges
        Canny(smooth, smooth, 0, 30, 3);
        imshow("edges", smooth);
        if(waitKey(30) >= 0) break;
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;

The result looks like below. Hope to post a video too.



I hope you find my review useful. 🙂 Try your hand at the book. Or better, learn OpenCV from the free tutorials at  (which are absolutely awwwwsm! 🙂 ).

As always, thanks for reading!

  • Packt just sucks. They do not have any method or process in place. The Editors what do I say are just plain incompetent. God save those who work with them.

    Stay Away would be my advice in two words.

  • Is there any info about OpenCV 2.3 + releases. A lot has changed and they now release packages for mobile platforms.

    • Yes Sagar, a lot has changed since 2.3.x releases. Major improvements include full Java bindings support, complete library functionality support in Python too, support for CUDA 5.5 and OpenCL now, support for QT 5, supported on ARM architectures. Support for iOS and Android is driving the development of new OpenCV powered apps on these platforms due to better stability. Its truly exciting times to be using OpenCV.

      The 2.4.6 version was released day before yesterday. Changelog for it is here:

      And detailed changelogs for all previous versions can be seen here: