Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Raspberry Pi Computer Vision Programming. - Second Edition
Raspberry Pi Computer Vision Programming. - Second Edition

Raspberry Pi Computer Vision Programming.: Design and implement computer vision applications with Raspberry Pi, OpenCV, and Python 3, Second Edition

By Ashwin Pajankar
$38.99
Book Jun 2020 306 pages 2nd Edition
eBook
$26.99 $17.99
Print
$38.99
Subscription
$15.99 Monthly
eBook
$26.99 $17.99
Print
$38.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 29, 2020
Length 306 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781800207219
Category :
Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi Computer Vision Programming. - Second Edition

Chapter 2: Preparing the Raspberry Pi for Computer Vision

In the previous chapter, we learned the fundamentals of single-board computers, computer vision, and OpenCV. We learned the detailed specifications of the Raspberry Pi (RPi) 4B and the RPi Zero W. We also learned how to set up Raspbian OS on all the RPi boards models in detail.

In this chapter, we will learn how to prepare our RPi board for computer vision. Continuing from where we left off in the previous chapter, we will start by installing the OpenCV library for computer vision and the other necessary software for remotely accessing the desktop, as well as Command Prompt. We will learn how to transfer files between an RPi and a Windows PC. We will also learn how to exploit the computation power of the RPi by overclocking it and installing a heatsink on it to reduce the temperature of the processor.

The topics that we'll cover in this chapter are as follows:

  • Remotely logging into the RPi with SSH
  • Remote...

Remotely logging into the RPi with SSH

We can remotely access the Command Prompt of the RPi board using various software from Windows. We can run all the Linux commands that do not involve the GUI remotely from Windows. As you may recall, we discussed how to enable SSH with the Raspberry Pi Configuration tool in Chapter 1, Introduction to Computer Vision and Raspberry Pi. It enables remote login through SSH.

In order to get started, follow these steps:

  1. First, we need to install any SSH software available for free. The most popular is PuTTY (https://www.putty.org/). I prefer to use another popular SSH client that comes with SFTP known as the Bitvise SSH client. You can download the installation file for Windows from https://www.bitvise.com/ssh-client-download and install it. After doing that, open the Bitvise SSH client. The following window will appear:

    Figure 2.1 – Bitwise Connection window

    Enter a hostname, username, and password. The hostname is nothing but the...

Remote desktop access

The Bitvise SSH client is great for file transfers and accessing the Command Prompt terminal of RPi. However, we need to use another piece of software to access the desktop of RPi remotely. There are two methods we can follow. The first one is VNC (we learned how to enable it in Chapter 1, Introduction to Computer Vision and Raspberry Pi, using the Raspberry Pi Configuration tool), while the other is using Windows' built-in Remote Desktop Connection utility. We can find it in the Windows search bar, as follows:


Figure 2.5 – Remote Desktop Connection option in the Windows search bar

But before we can use it, we need to install xrdp on the RPi. Installing it is very easy. We just need to run the following command at LXTerminal on the RPi:

sudo apt-get install xrdp -y

Information

You might want to read more about xrdp at http://xrdp.org/.

Once xrdp has been installed on the RPi, you need to follow these steps...

Installing OpenCV on an RPi board

Follow these steps to install OpenCV on the RPi:

  1. First, we need to install a few dependencies. Run the following command to install all these dependencies:
    sudo apt-get install -y libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev libqtgui4 libqt4-test
  2. Once the installation is successful, we can install OpenCV on the RPi:
    pip3 install opencv-python==4.0.1.24
  3. Once the installation of OpenCV is successful, we can verify it by running the following command:
    python3 -c "import cv2; print(cv2.__version__)"

    The following should be the output:

    4.0.1

This means that the installation is completed and that we can import OpenCV in our Python 3 programs.

Next, we will learn how to overclock the RPi 4B and how to install heatsink on it.

Heatsinks and overclocking RPi 4B

Overclocking means running the processors at higher speeds than those that are intended. When we overclock the processors, their temperature tends to rise and they radiate more heat. Raspberry Pi board models do not come with any built-in coolers. You can buy passive heatsinks from many online shops such as Amazon. The following is an example of a heatsink with a fan:

Figure 2.9 – Small heatsink for RPi

The heatsink fan can be powered by connecting it to a 5V or 3.3V power supply. The speed of the fan depends on the voltage, and we can connect it to the RPi power pins. We will learn more about the GPIO and the power pins of RPi in the next chapter. The best and the most effective heatsink that I found was the ICE Tower fan for the RPi 4B (https://www.seeedstudio.com/ICE-Tower-CPU-Cooling-Fan-for-Raspberry-pi-Support-Pi-4-p-4097.html).

The following is my own Pi with the ICE Tower mounted on it:

...

Summary

In this chapter, we learned how to remotely log into the RPi and how to access the RPi desktop remotely with RDP. We also learned how to install OpenCV and how to verify it. Also, we learned how to overclock an RPi board.

We will be using all the skills we learned in this chapter throughout this book for accessing the Command Prompt and desktop of Raspbian OS remotely while writing programs for computer vision. We will also use file transfer quite a few times, as well as the OpenCV library in most programs.

In the next chapter, we will learn the basics of Python, NumPy, matplotlib, and the RPi GPIO library. We will also learn about the SciPy ecosystem.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the potential of computer vision with Raspberry Pi and Python programming
  • Perform computer vision tasks such as image processing and manipulation using OpenCV and Raspberry Pi
  • Discover easy-to-follow examples and screenshots to implement popular computer vision techniques and applications

Description

Raspberry Pi is one of the popular single-board computers of our generation. All the major image processing and computer vision algorithms and operations can be implemented easily with OpenCV on Raspberry Pi. This updated second edition is packed with cutting-edge examples and new topics, and covers the latest versions of key technologies such as Python 3, Raspberry Pi, and OpenCV. This book will equip you with the skills required to successfully design and implement your own OpenCV, Raspberry Pi, and Python-based computer vision projects. At the start, you'll learn the basics of Python 3, and the fundamentals of single-board computers and NumPy. Next, you'll discover how to install OpenCV 4 for Python 3 on Raspberry Pi, before covering major techniques and algorithms in image processing, manipulation, and computer vision. By working through the steps in each chapter, you'll understand essential OpenCV features. Later sections will take you through creating graphical user interface (GUI) apps with GPIO and OpenCV. You'll also learn to use the new computer vision library, Mahotas, to perform various image processing operations. Finally, you'll explore the Jupyter Notebook and how to set up a Windows computer and Ubuntu for computer vision. By the end of this book, you'll be able to confidently build and deploy computer vision apps.

What you will learn

Set up a Raspberry Pi for computer vision applications Perform basic image processing with libraries such as NumPy, Matplotlib, and OpenCV Demonstrate arithmetical, logical, and other operations on images Work with a USB webcam and the Raspberry Pi Camera Module Implement low-pass and high-pass filters and understand their applications in image processing Cover advanced techniques such as histogram equalization and morphological transformations Create GUI apps with Python 3 and OpenCV Perform machine learning with K-means clustering and image quantization

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 29, 2020
Length 306 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781800207219
Category :

Table of Contents

15 Chapters
Preface Chevron down icon Chevron up icon
Chapter 1: Introduction to Computer Vision and the Raspberry Pi Chevron down icon Chevron up icon
Chapter 2: Preparing the Raspberry Pi for Computer Vision Chevron down icon Chevron up icon
Chapter 3: Introduction to Python Programming Chevron down icon Chevron up icon
Chapter 4: Getting Started with Computer Vision Chevron down icon Chevron up icon
Chapter 5: Basics of Image Processing Chevron down icon Chevron up icon
Chapter 6: Colorspaces, Transformations, and Thresholding Chevron down icon Chevron up icon
Chapter 7: Let's Make Some Noise Chevron down icon Chevron up icon
Chapter 8: High-Pass Filters and Feature Detection Chevron down icon Chevron up icon
Chapter 9: Image Restoration, Segmentation, and Depth Maps Chevron down icon Chevron up icon
Chapter 10: Histograms, Contours, and Morphological Transformations Chevron down icon Chevron up icon
Chapter 11: Real-Life Applications of Computer Vision Chevron down icon Chevron up icon
Chapter 12: Working with Mahotas and Jupyter Chevron down icon Chevron up icon
Chapter 13: Appendix Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela