I bought Practical Python and OpenCV a couple of years ago during one of its authors Kickstarters. I started reading it and then got busy with other things. The past couple of weeks, I decided to give the book another go and was able to finish it. Note that I started reading the 3rd edition of the book without realizing there was a 4th edition. After finished the 3rd edition, I compared it to the 4th side by side and it looks like they are nearly identical, so I don’t think it matters all that much.
Quick Review
- Why I picked it up: Computer vision / machine learning sounds interesting to me and the author has a fun blog
- Why I finished it: It’s short and the writing style is engaging
- I’d give it to: Anyone looking to get started with OpenCV in Python
Book Formats
You can get this book as a hard cover, PDF, or Mobi.
Book Contents
This book contains 11 chapters across 169 pages. It covers Python 3 and OpenCV 4 in the 4th edition.
Full Review
Practical Python and OpenCV is an interesting book. It’s shorter than your normal technical book, but it covers a lot of ground. This is kind of an anomaly as a lot of technical books seem to be much longer. Anyway, let’s go over the book piece by piece.
Chapter one is just an introduction. It describes what computer vision is an gives some examples. Then chapter two jumps in and teaches you how to install the packages you need to use the book effectively. Personally I think these two chapters could have been combined or the installation chapter could have been an appendix. But no matter.
Chapter three is where you will finally get into some code. Here you learn how to load images into OpenCV and display them to the user. You will also learn how to save the image. This is useful for converting between different image formats, but more importantly it is helpful for saving off your data when you need to.
In the fourth chapter, you learn the basics of images from the point of view of OpenCV. You will learn its coordinate system, as well as how to access and manipulate individual pixels in an image.
Then in chapter five, you discover how to draw lines, rectangles and circles. You can change the width, position, and color of each of these shapes. You can also stack the shapes on each other.
Chapter six covers the topic of image processing. Here you will learn all about image transformations (translation, rotation, resizing, etc), image arithmetic, bitwise operations, masking, splitting, merging and the importance of color spaces (RGB vs BGR and HSV).
For chapter seven, you will learn how to use histograms effectively in OpenCV. The histogram will help you determine the contrast, brightness and intensity distributions of the images that you are working with. OpenCV supports working with grayscale and color histograms. You will also learn about histogram equalization and masks.
Chapter eight explains the different types of blurring and smoothing that OpenCV can do. Here you will learn about Gaussian, Median and Bilateral blurring. Adrian doesn’t go into a lot of depth explaining these topics. He instead opts to show the reader how to do each of them using small code snippets.
Chapter nine covers the topic of thresholding, which is the binarization of images. Thresholding is the term used to describe focusing on objects or areas of interest within an image. Adrian uses a photo of some coins for this chapter and the rest of the book. You end up using thresholding to find the coins in the photos.
Then in chapter ten, you learn how to use gradients and edge detection to refine what you learned in chapter nine. This will allow you to find the edges of the coins in the photo. This chapter focuses on using the Laplacian and Sobel methods for gradients. Then you learn about using the Canny Edge detection technique.
To wrap up the book, Adrian uses OpenCV to find the contours of the coins so that he can count the coins in the image. He also talks about the differences that exist between OpenCV versions when it comes to finding contours.
This book covers a lot of different topics very quickly. There are some minor layout issues in my mind in that sometimes he refers to an image that either doesn’t appear soon or was inexplicably shown earlier in the chapter. There are also a couple of occasions where he is explaining some code that is not on the page. However these things don’t affect the quality of the code examples themselves. You also get a Case Studies PDF that has more information.
Overall, I think this is a pretty good book. The examples are fun and fast paced and seeing dinosaurs in a Python book is always fun. The book is kind of pricey though.
Practical Python and OpenCVby Dr. Adrian Rosebrock |
Other Book Reviews
- Mission Python by Sean McManus
- Serious Python: Black-Belt Advice on Deployment, Scalability, Testing, and More by Julien Danjou
- Python Testing with pytest by Brian Okken
- Module Programming with Python by Erik Westra
- Python Playground – Geeky Projects for the Curious Programmer by Mahesh Venkitachalam
- IPython Notebook Essentials by L. Felipe Martins
Pingback: Links 6/6/2019: Zorin OS 15, Krita 4.2.1, NetBSD 8.1 Released; Fedora 30 Elections | Techrights