Reader small image

You're reading from  Raspberry Pi Computer Vision Programming. - Second Edition

Product typeBook
Published inJun 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800207219
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Ashwin Pajankar
Ashwin Pajankar
author image
Ashwin Pajankar

Ashwin Pajankar is an author, a YouTuber, and an instructor. He graduated from the International Institute of Information Technology, Hyderabad, with an MTech in Computer Science and Engineering. He has been writing programs for over two and a half decades. He is proficient in Linux, Unix shell scripting, C, C++, Java, JavaScript, Python, PowerShell, Golang, HTML, and assembly language. He has worked on single-board computers such as Raspberry Pi and Banana Pro. He is also proficient with microcontroller boards such as Arduino and the BBC Micro:bit. He is currently self-employed and teaches on Udemy and YouTube. He also organizes programming boot camps for working professionals and software companies.
Read more about Ashwin Pajankar

Right arrow

Preface

Computer vision and image processing have extended from being a field of niche research to everyday usage. However, despite this revolution, one of the key challenges faced in computer vision development and application development is a lack of a well-designed guide that teaches you how it works step by step. This book addresses this key challenge.

We will start with the basics of Raspberry Pi and Python and explore Python 3 programming with various supporting libraries, such as NumPy, SciPy, and Matplotlib. Next, we will understand the basics of General-Purpose Input Output (GPIO) pins on Raspberry Pi and learn about its programming with Python 3. We will look at a lot of examples of Raspberry Pi and computer vision programming with Python and GPIO throughout the entirety of this book.

Then, we will move on to the installation of OpenCV on Raspberry Pi. We will look at the basics of OpenCV programming and explore the concepts of advanced image processing and computer vision. We will learn about and demonstrate concepts such as thresholding, segmentation, image quantization, image restoration, mathematical morphology, and contours. Then, we will implement a few real-life applications with OpenCV, Python, and GPIO.

We will also learn how to use another library—Mahotas—and the Jupyter Notebook. Additionally, we will learn how to install all the libraries that we will discuss on a Windows computer. Finally, the Appendix section has a range of useful topics relating to Raspberry Pi that are not included in other chapters.

Who this book is for

This book is for Python 3 developers, computer vision professionals, and Raspberry Pi enthusiasts who are looking to implement computer vision applications on a low-cost platform. Basic knowledge of programming, mathematics, and electronics will be beneficial. However, even beginners in this area will be comfortable with covering the contents of the book as they are presented in a step-by-step manner.

What this book covers

Chapter 1, Introduction to Computer Vision and Raspberry Pi, illustrates the concept of single-board computers, OpenCV, and Raspberry Pi. We will also learn how to set up Raspbian OS on Raspberry Pi.

Chapter 2, Preparing Raspberry Pi for Computer Vision, teaches us how to set up Raspberry Pi for demonstrations of computer vision.

Chapter 3, Introduction to Python Programming, introduces us to Python 3 programming. We will learn about libraries such as NumPy and Matplotlib. We will also demonstrate the use of a few programs with LEDs and push buttons in detail.

Chapter 4, Getting Started with Computer Vision, focuses on the basics of computer vision programming and interfacing various camera modules with Raspberry Pi. We will also learn how to work with images and the GUI in this chapter in detail.

Chapter 5, Basics of Image Processing, looks at basic operations on images, such as bitwise arithmetic and bitwise logical operations.

Chapter 6, Colorspaces, Transformations, and Thresholding, is where we will analyze the concept of basic segmentation and thresholding. We will learn about various geometric and perspective transformations. We will also learn about colorspaces and their application in detail.

Chapter 7, Let's Make Some Noise, explores the concept of filters and how to use low-pass filters to reduce noise in images. We will learn about concepts such as kernels and convolution in detail.

Chapter 8, High-Pass Filters and Feature Detection, goes into the aspects of detecting various features, such as lines, circles, edges, and corners, using high-pass filtering techniques.

Chapter 9, Image Restoration, Segmentation, and Depth Map, investigates restoring degraded and damaged images, segmenting with Python's implementation of the k-means and mean-shift algorithms, and estimating depth maps.

Chapter 10, Histograms, Contours, and Morphological Transformations, analyzes images with histograms, and we will learn how to enhance images by equalizing histograms. We will also dig deeper into contours and mathematical morphological operations.

Chapter 11, Real-Life Applications of Computer Vision, demonstrates applications in the real world with OpenCV, Python 3, and Raspberry Pi.

Chapter 12, Working with Mahotas and Jupyter, delves into the brief usage of another scientific image processing library known as Mahotas. We will also understand how to work with the Jupyter Notebook for Python 3 programming.

Chapter 13, Appendix, is a collection of assorted topics relating to Python, Raspberry Pi, and computer vision that did not fit in to earlier chapters.

To get the most out of this book

All of the programs included in all of the chapters in this book are executed on Raspberry Pi with Raspbian OS. You will need a Windows PC and an internet connection to set up Raspbian OS on the Raspberry Pi board. The instructions for setting up on Windows are included in the Appendix section. You are encouraged to use the latest revision of Raspberry Pi (at the time of writing, it is Raspberry Pi 4B); however, the programs will also run on any generation of the boards in the Raspberry Pi family. These programs are written for the Python 3 interpreter and they may not work with Python 2. Apart from the Raspberry Pi board and a Windows PC for the setup, you will also need a Raspberry Pi camera module and a USB webcam. Also, some electronic components, such as push buttons, LEDs, breadboards, and jumper cables, are needed to work with the Python 3 GPIO library.

If you are using the digital version of this book, we advise you to type the code in yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying/pasting of code.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/raspberry-pi-computer-vision-programming. In case there's an update to the code, it will.3 be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Code in Action

Code in Action videos for this book can be viewed at (https://bit.ly/3evn0ln).

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781800207219_ColorImages.pdf

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Just like lxterminal, we can run Linux commands from here too."

A block of code is set as follows:

p2 = Person()
p2.name = 'Jane'
p2.age = 20
print(p2.name)
print(p2.age)

Any command-line input or output is written as follows:

sudo apt-get install xrdp -y

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Open the Remote Desktop Connection application on your Windows PC."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Computer Vision Programming. - Second Edition
Published in: Jun 2020Publisher: PacktISBN-13: 9781800207219
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Ashwin Pajankar

Ashwin Pajankar is an author, a YouTuber, and an instructor. He graduated from the International Institute of Information Technology, Hyderabad, with an MTech in Computer Science and Engineering. He has been writing programs for over two and a half decades. He is proficient in Linux, Unix shell scripting, C, C++, Java, JavaScript, Python, PowerShell, Golang, HTML, and assembly language. He has worked on single-board computers such as Raspberry Pi and Banana Pro. He is also proficient with microcontroller boards such as Arduino and the BBC Micro:bit. He is currently self-employed and teaches on Udemy and YouTube. He also organizes programming boot camps for working professionals and software companies.
Read more about Ashwin Pajankar