Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenCV 4 with Python Blueprints
  • Toc
  • feedback
OpenCV 4 with Python Blueprints

OpenCV 4 with Python Blueprints

By : Dr. Menua Gevorgyan , Michael Beyeler (USD), Mamikonyan, Michael Beyeler
5 (4)
close
OpenCV 4 with Python Blueprints

OpenCV 4 with Python Blueprints

5 (4)
By: Dr. Menua Gevorgyan , Michael Beyeler (USD), Mamikonyan, Michael Beyeler

Overview of this book

OpenCV is a native cross-platform C++ library for computer vision, machine learning, and image processing. It is increasingly being adopted in Python for development. This book will get you hands-on with a wide range of intermediate to advanced projects using the latest version of the framework and language, OpenCV 4 and Python 3.8, instead of only covering the core concepts of OpenCV in theoretical lessons. This updated second edition will guide you through working on independent hands-on projects that focus on essential OpenCV concepts such as image processing, object detection, image manipulation, object tracking, and 3D scene reconstruction, in addition to statistical learning and neural networks. You’ll begin with concepts such as image filters, Kinect depth sensor, and feature matching. As you advance, you’ll not only get hands-on with reconstructing and visualizing a scene in 3D but also learn to track visually salient objects. The book will help you further build on your skills by demonstrating how to recognize traffic signs and emotions on faces. Later, you’ll understand how to align images, and detect and track objects using neural networks. By the end of this OpenCV Python book, you’ll have gained hands-on experience and become proficient at developing advanced computer vision apps according to specific business needs.
Table of Contents (14 chapters)
close
11
Profiling and Accelerating Your Apps
12
Setting Up a Docker Container

To get the most out of this book

All of our code use Python 3.8, which is available on a variety of operating systems, such as Windows, GNU Linux, macOS, and others. We have made an effort to use only libraries that are available on these three operating systems. We will go over the exact versions of each of the dependencies we have used, which can be installed using pip (Python's dependency management system). If you have trouble getting any of these working, we have Dockerfiles available with which we have tested all the code in this book, which we cover in Appendix B, Setting Up a Docker Container.

Here is a list of dependencies that we have used, with the chapters they were used in:

Software required

Version

Chapter number

Download links to the software

Python

3.8

All

https://www.python.org/downloads/

OpenCV

4.2

All

https://opencv.org/releases/

NumPy

1.18.1

All

http://www.scipy.org/scipylib/download.html

wxPython

4.0

1, 4, 8

http://www.wxpython.org/download.php

matplotlib

3.1

4, 5, 6, 7

http://matplotlib.org/downloads.html

SciPy

1.4

1, 10

http://www.scipy.org/scipylib/download.html

rawpy

0.14

5

https://pypi.org/project/rawpy/

ExifRead 2.1.2 5 https://pypi.org/project/ExifRead/
TensorFlow 2.0 7, 9 https://www.tensorflow.org/install

In order to run the codes, you will need a regular laptop or Personal Computer (PC). Some chapters require a webcam, which can be either an embedded laptop camera or an external one. Chapter 2, Hand Gesture Recognition Using a Kinect Depth Sensor also requires a depth sensor that can be either a Microsoft 3D Kinect sensor or any other sensor, which is supported either by the libfreenect library or OpenCV, such as ASUS Xtion.

We have tested this using Python 3.8 and Python 3.7, on Ubuntu 18.04.

If you already have Python on your computer, you can just get going with running the following on your terminal:

$ pip install -r requirements.txt

Here, requirements.txt is provided in the GitHub repository of the project, and has the following contents (which is the previously given table in a text file):

wxPython==4.0.5
numpy==1.18.1
scipy==1.4.1
matplotlib==3.1.2
requests==2.22.0
opencv-contrib-python==4.2.0.32
opencv-python==4.2.0.32
rawpy==0.14.0
ExifRead==2.1.2
tensorflow==2.0.1

Alternatively, you can follow the instructions in Appendix B, Setting Up a Docker Container, to get everything working with a Docker container.

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/OpenCV-4-with-Python-Blueprints-Second-Edition. In case there's an update to the code, it will 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

Download the color images

Conventions used

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

CodeInText: 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: "We will use argparse as we want our script to accept arguments."

A block of code is set as follows:

import argparse

import cv2
import numpy as np

from classes import CLASSES_90
from sort import Sort

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

$ python chapter8.py collect

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: "Select System info from the Administration panel."

Warnings or important notes appear like this.
Tips and tricks appear like this.
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete